Skip to content

Respect treatPhpDocAsCertain in isset check#674

Merged
ondrejmirtes merged 3 commits intophpstan:masterfrom
VincentLanglet:isset
Sep 16, 2021
Merged

Respect treatPhpDocAsCertain in isset check#674
ondrejmirtes merged 3 commits intophpstan:masterfrom
VincentLanglet:isset

Conversation

@VincentLanglet
Copy link
Copy Markdown
Contributor

@VincentLanglet
Copy link
Copy Markdown
Contributor Author

Some tests are failing, but I'm not sure it's related to my PR @ondrejmirtes

$type = $this->treatPhpDocTypesAsCertain
? $scope->getType($expr->var)
: $scope->getNativeType($expr->var);
$dimType = $scope->getType($expr->dim);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please write a test that verifies $dimType should get the same treatment, and them commit a fix for $dimType as well? Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but could you help me to write it/understand this code ?
I don't know what is $dimType.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend phpast.com to get familiar with the AST from PHP-Parser

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be better though, it doesn't show the node class names :/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ! phpast.com help me to understand that dim was the key of the array.
I added a test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants