Respect treatPhpDocAsCertain in isset check#674
Conversation
cb6cb0d to
292c174
Compare
292c174 to
37bda5e
Compare
|
Some tests are failing, but I'm not sure it's related to my PR @ondrejmirtes |
src/Rules/IssetCheck.php
Outdated
| $type = $this->treatPhpDocTypesAsCertain | ||
| ? $scope->getType($expr->var) | ||
| : $scope->getNativeType($expr->var); | ||
| $dimType = $scope->getType($expr->dim); |
There was a problem hiding this comment.
Can you please write a test that verifies $dimType should get the same treatment, and them commit a fix for $dimType as well? Thanks.
There was a problem hiding this comment.
Sure, but could you help me to write it/understand this code ?
I don't know what is $dimType.
There was a problem hiding this comment.
$dimType is the type of ArrayDimFetch::$dim. If you don't know what that is, please read this guide: https://phpstan.org/developing-extensions/abstract-syntax-tree
There was a problem hiding this comment.
I recommend phpast.com to get familiar with the AST from PHP-Parser
There was a problem hiding this comment.
it could be better though, it doesn't show the node class names :/
There was a problem hiding this comment.
Thanks ! phpast.com help me to understand that dim was the key of the array.
I added a test.
There was a problem hiding this comment.
it could be better though, it doesn't show the node class names :/
Yeah, it can be reconstructed with nodeType, but it could be great to have the full class directly
|
Thank you! |
Solve phpstan/phpstan#5620