-
Notifications
You must be signed in to change notification settings - Fork 48
False positive in PHPStan 1.4.8 with assertNotSame
with instances of the same class
#120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
/cc @herndlm Probably worth changing the code to only work for Variable node? |
🤦♂️ weird, I thought this should not happen because very similar looking comparisons in https://github.com/phpstan/phpstan-src/blob/1.4.8/tests/PHPStan/Rules/Comparison/data/impossible-method-call.php#L75 and https://github.com/phpstan/phpstan-src/blob/1.4.8/tests/PHPStan/Rules/Comparison/data/impossible-method-call.php#L87 are fine
sounds like a solution. somehow reproducing that in PHPStan directly would be nice too when I try to fix it ;) |
Oh look at that, apparently only those static factory-like methods are problems. See phpstan/phpstan-webmozart-assert#122. I'm not sure anymore if limiting it to Variable nodes is the right solution. Maybe there's a bug hidden somewhere else. |
It's not a problem for But it's a problem for anything that can be remembered in SpecifiedTypes by TypeSpecifier. |
Right, while I was doing a quick test I was actually comparing the type with a node class and thought something is weird. Limiting it to Variable nodes seems to be doing the trick. Give me a couple of minutes.. |
@herndlm Thanks for working on this! ❤️ |
Looks like the same problem existed in a truthy scope with === already. I'm trying to fix that too, and I'm having a hard time creating failing tests for the falsey scope. Which is why this will take a bit longer than a couple of minutes :) |
@ondrejmirtes do we need a regression test here? or better: do you want one? :) |
Yes, please send it 😊 |
Fixed in PHPStan 1.4.9 https://github.com/phpstan/phpstan/releases/tag/1.4.9 |
Thanks, @ondrejmirtes and @herndlm! ❤️ |
This update gets rid of a false positive: phpstan/phpstan-phpunit#120 Resolves: #97163 Releases: main, 11.5 Change-Id: I6f7ecd909a127b5940b928d81c94ab7b3404cd49 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73870 Tested-by: core-ci <[email protected]> Tested-by: Benni Mack <[email protected]> Tested-by: Oliver Bartsch <[email protected]> Reviewed-by: Benni Mack <[email protected]> Reviewed-by: Oliver Bartsch <[email protected]>
This update gets rid of a false positive: phpstan/phpstan-phpunit#120 Resolves: #97163 Releases: main, 11.5 Change-Id: I6f7ecd909a127b5940b928d81c94ab7b3404cd49 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73896 Reviewed-by: Oliver Klee <[email protected]> Reviewed-by: Oliver Bartsch <[email protected]> Tested-by: core-ci <[email protected]> Tested-by: Oliver Bartsch <[email protected]>
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Using phpstan/phpstan-phpunit 1.0.0 and phpstan/phpstan 1.4.8, the following code creates a false positive:
This is the error (with different line numbers):
This problem is new with PHPStan 1.4.8 (as it did no occur with PHPStan 1.4.7).
You can find the complete build with the problem at oliverklee/ext-oelib#904.
(I was not able to use the PHPStan playground for this as I currently do not know of any way of including PHPUnit in it: https://phpstan.org/r/c7fa7bda-1024-45c3-957d-7b91de41b844)
The text was updated successfully, but these errors were encountered: