-
Notifications
You must be signed in to change notification settings - Fork 523
Failing test for #4657 #477
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
Conversation
While using the debugger I found that the problem occurs while resolving is_null($value). This code: https://github.com/phpstan/phpstan-src/blob/6d523028e399c15dc77aec3affd2ea97ff735925/src/Rules/Comparison/ImpossibleCheckTypeHelper.php#L177-L186 gets $sureTypes = [ Node\Expr\Variable , Type\NullType ]. When treatPhpDocTypesAsCertain = false, it will call `getNativeType` on the variable. That resolves to `null`. It's probably because the `$value = null;` declaration on the top. It does not know that the value is also passed as reference to a callback.
Interesting: When I remove this: phpstan-src/src/Rules/Comparison/ImpossibleCheckTypeHelper.php Lines 182 to 186 in 6d52302
with $argumentType = $scope->getType($sureType[0]);
my test passes, but a lot other tests fail (obviously). I wonder, my bug file does not contain any PHPDoc, so why does |
@ruudk That's about wrong information being in This is all the code that's related to processing closures:
|
@ondrejmirtes Thanks for pointing this out. I believe I solved it. Is it the way to go? |
Yeah, looks fine, just do all the necessary |
Added them to my test file, are there more places where I should add it? |
@ruudk If you write some nonsense there you'll realized those asserts aren't executed. You need to add the file as a dataProvider in NodeScopeResolver::testFileAsserts(). |
Thank you! |
See phpstan/phpstan#4657
While using the debugger I found that the problem occurs while resolving
is_null($value)
.This code:
phpstan-src/src/Rules/Comparison/ImpossibleCheckTypeHelper.php
Lines 177 to 186 in 6d52302
gets $sureTypes = [ Node\Expr\Variable , Type\NullType ].
When treatPhpDocTypesAsCertain = false, it will call
getNativeType
on the variable. That resolves tonull
.It's probably because the
$value = null;
declaration on the top.It does not know that the value is also passed as reference to a callback.
Any advice how to debug this further?