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
Set class and method reflection in the MethodReturnStatementNode. #2515
Set class and method reflection in the MethodReturnStatementNode. #2515
Conversation
You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x. |
4ee3018
to
e394afd
Compare
not sure if github is broken atm but i can't seem to change the target to |
} | ||
|
||
$methodReflection = $methodScope->getFunction(); | ||
if (!$methodReflection instanceof MethodReflection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is the best way to get the reflections to pass into the node
18fa72f
to
d0c3fa6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MethodReturnStatementsNode is read in NodeScopeResolver around line 4417, we could access ClassReflection on $node
instead of $scope
there too :)
src/Analyser/NodeScopeResolver.php
Outdated
@@ -593,12 +593,25 @@ private function processStmtNode( | |||
|
|||
$gatheredReturnStatements[] = new ReturnStatement($scope, $node); | |||
}, StatementContext::createTopLevel()); | |||
|
|||
$classReflection = $methodScope->getClassReflection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do this on $scope
and then you don't need to check for null
- because of if (!$scope->isInClass()) {
on line 526.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the isInClass
thing a custom type-specifier in phpstan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not anymore, it just has @phpstan-assert
above it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i didn't know they could do that, nice
d0c3fa6
to
1b06588
Compare
Thank you! |
Is this what you meant by #2514 (comment) ?