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
merged 1 commit into from
Dec 15, 2022
Merged

Conversation

herndlm
Copy link
Contributor

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

@herndlm
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
@ondrejmirtes
Copy link
Member

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants