Fix #5020: phpstan could handle $class::someMethod syntax better#5000
Fix #5020: phpstan could handle $class::someMethod syntax better#5000staabm wants to merge 12 commits intophpstan:2.1.xfrom
Conversation
- When $expr->class is an Expr (variable), resolve method reflection and parameters acceptor using getObjectTypeOrClassStringObjectType() so by-reference parameters and other argument analysis work correctly - Guard $this invalidation and constructor property initialization blocks with $expr->class instanceof Name to prevent $other::__construct() from incorrectly affecting $this - New regression test in tests/PHPStan/Analyser/nsrt/bug-5020.php
|
You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x. |
| [ | ||
| 'Call to static method DateTimeImmutable::createFromFormat() on a separate line has no effect.', | ||
| 13, | ||
| ], |
There was a problem hiding this comment.
I think it makes sense, that we see the error on line 13. I feel this one was missing before
There was a problem hiding this comment.
Isn't related to the fact you can extend \DateTimeImmutable and override createFromFormat with impure method ?
Maybe not for DateTimeImmutable (dunno if it's final), but it seems possible for any non final class no ?
So we should add a test with a random non final class (?)
There was a problem hiding this comment.
I think you are right.
the code atm is understood as "static call to DateTimeImmutable::createFromFormat()" but not as a "late static binding call to $x::createFromFormat()".
and DateTimeImmutable::createFromFormat() did not throw on PHP7.x - therefore we get the test-error only on PHP 7.4
|
This pull request has been marked as ready for review. |
inspired by #4911
Fixes phpstan/phpstan#5020