Skip to content

Infer static call exceptions from the actual arguments - #7164

Open
simPod wants to merge 1 commit into
phpstan:2.4.xfrom
simPod:fix/dynamic-static-throws
Open

simPod wants to merge 1 commit into
phpstan:2.4.xfrom
simPod:fix/dynamic-static-throws

Conversation

@simPod

@simPod simPod commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

A static call on a class-string can be analyzed twice: once with a synthetic call that has no arguments and once with the actual call. A dynamic throw type extension can correctly rule out an exception for the real arguments, but the synthetic call separately adds it back.

When the method is resolved, compute its throw point only from the actual call. Keep the existing fallback for unresolved calls and preserve exceptions from evaluating the receiver, method name, and arguments. Apply the same change to the Turbo handler.

Closes phpstan/phpstan#15837.

@staabm

staabm commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

In the PHPStan context We usually prefer a issue-report with concrete examples and context.

Its way more useful for us compared to a pull request

@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes
ondrejmirtes changed the base branch from 2.3.x to 2.4.x December 3, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False checked exceptions on static calls through a known class-string

3 participants