Do not treat definition of functions and class-likes as unreachable#2263
Do not treat definition of functions and class-likes as unreachable#2263ondrejmirtes merged 2 commits intophpstan:1.10.xfrom
Conversation
|
What is the blockers to merge it? |
|
Oh interesting, this looks super close to what I did in #2279, which explains the conflicts, which makes this not mergable. I wasn't even aware of this PR when I did those changes. It also closed one of the linked issues here. Most likely it makes sense that somebody checks what's still different / missing and adds those missing changes or adapts my changes to also fix the other issue. I would gladly do that, but can't because I'm traveling. |
|
I've just rebased the branch and merged @herndlm's changes and mine. |
ondrejmirtes
left a comment
There was a problem hiding this comment.
And also please add a note in the PR description that this closes #8319, thanks.
| ]); | ||
| $this->analyse([__DIR__ . '/data/bug-4002_class.php'], []); | ||
| $this->analyse([__DIR__ . '/data/bug-4002_interface.php'], []); | ||
| $this->analyse([__DIR__ . '/data/bug-4002_trait.php'], []); |
There was a problem hiding this comment.
For each test* method, only a single analyse() call should be made. So these calls should each have their own test method.
There was a problem hiding this comment.
I've split the method.
|
Thank you! |
PHPStan treats the statement right after always-terminating statement, like
returnorexit, as unreachable statement.With this PR, definition of classes, interfaces, traits and functions on top level will not marked as unreachable.
Nop nodes will be ignored as well.
I haven't implemented PHP's early binding mechanism since it is so complicated.
This may cause some false negative on code like this, but I think the advantage of decreasing false positive is larger.
Closes phpstan/phpstan#4002
Closes phpstan/phpstan#8966
Closes phpstan/phpstan#8319 (although the early binding mechanism is not completely compatible with that of PHP)