Skip to content

Scope->rememberConstructorScope should not remember the function scope #3944

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

Merged
merged 7 commits into from
Apr 18, 2025

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Apr 18, 2025

When remembering the scope we should not remember the scope-function, as otherwise analyzing instance-method parameters would see the remembered$scope->getFunction() as __construct instead of null.

we only want to remember the types

closes spaze/phpstan-disallowed-calls#323

@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

public function processNode(Node $node, Scope $scope): array
{
if ($scope->getFunction() !== null) {
throw new ShouldNotHappenException('All names in the tests should not have a scope function.');
Copy link
Member

Choose a reason for hiding this comment

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

"function scope", not "scope function". Function is the adjective here 😊

}

return [
RuleErrorBuilder::message(sprintf('Name %s found in scope-function null', $node->toString()))->identifier('test.instanceOfMethodsParameterRule')->build(),
Copy link
Member

Choose a reason for hiding this comment

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

function scope

@ondrejmirtes ondrejmirtes merged commit 488b65f into phpstan:2.1.x Apr 18, 2025
416 of 417 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the fix-scope branch April 19, 2025 07:49
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.

PHPStan 2.1.12 compatibility
3 participants