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
getNativeTypeon 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?