Skip to content
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

Fix node PHPDoc type hints #2053

merged 1 commit into from Dec 15, 2022


Copy link

@herndlm herndlm commented Dec 5, 2022

Those 3 methods are also called with properties that are determined more dynamically like e.g.

foreach ($node->getSubNodeNames() as $subNodeName) {
    $subNode = $node->{$subNodeName};
    $this->processNodes($subNode, $nodeCallback, $endNodeCallback);

and $subNode can be null here for e.g. $node->stmts.

noticed this when trying to enforce native union type hints for params return types via phpcs. btw what is the reason this is not done yet? BC for public methods I suppose?

Copy link
Contributor Author

herndlm commented Dec 5, 2022

I do wonder though why PHPStan did not report this. Looks like the type is mixed, implicit mixed I suppose?

@ondrejmirtes ondrejmirtes merged commit 0378682 into phpstan:1.9.x Dec 15, 2022
376 of 377 checks passed
Copy link

Thank you! :) Yeah, PHPStan is on level 8, and you can't expect any useful typechecking with $node->{$subNodeName} :)

@herndlm herndlm deleted the fix-node-type-hints branch December 15, 2022 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants