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

Set class and method reflection in the MethodReturnStatementNode. #2515

Merged
merged 1 commit into from Jul 17, 2023

Conversation

mad-briller
Copy link
Contributor

Is this what you meant by #2514 (comment) ?

@phpstan-bot
Copy link
Collaborator

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.

@mad-briller
Copy link
Contributor Author

not sure if github is broken atm but i can't seem to change the target to 1.10.x cos the dropdown isn't opening

}

$methodReflection = $methodScope->getFunction();
if (!$methodReflection instanceof MethodReflection) {
Copy link
Contributor Author

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

@mad-briller mad-briller force-pushed the method-return-statement branch 2 times, most recently from 18fa72f to d0c3fa6 Compare July 7, 2023 16:24
@mad-briller mad-briller changed the base branch from 1.11.x to 1.10.x July 7, 2023 17:17
Copy link
Member

@ondrejmirtes ondrejmirtes left a 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 :)

@@ -593,12 +593,25 @@ private function processStmtNode(

$gatheredReturnStatements[] = new ReturnStatement($scope, $node);
}, StatementContext::createTopLevel());

$classReflection = $methodScope->getClassReflection();
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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

@ondrejmirtes ondrejmirtes merged commit 32ca340 into phpstan:1.10.x Jul 17, 2023
408 checks passed
@ondrejmirtes
Copy link
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
3 participants