Skip to content

Invalidate static expressions when a non-static expression is called - #4434

Open
takaram wants to merge 3 commits into
phpstan:2.1.xfrom
takaram:bug-13416
Open

Invalidate static expressions when a non-static expression is called#4434
takaram wants to merge 3 commits into
phpstan:2.1.xfrom
takaram:bug-13416

Conversation

@takaram

@takaram takaram commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

@ondrejmirtes

Copy link
Copy Markdown
Member

Please rebase this and fix conflicts, thank yuo.

@takaram

takaram commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

@ondrejmirtes
I rebased the branch.

Comment thread src/Analyser/NodeScopeResolver.php Outdated
Comment thread src/Analyser/MutatingScope.php

@staabm staabm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mutating testing suggests, we are missing a unit test for a call which maybe has side effects.

take inspiration from #4422 (comment) if you need a example on how this can be achieved.

}
}

$expressionTypes = $this->expressionTypes;

@staabm staabm Mar 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we could return early with return $this; when $classNamesToInvalidate is empty


if ($methodReflection !== null) {
if ($methodReflection->getName() === '__construct' || $methodReflection->hasSideEffects()->yes()) {
$shouldInvalidateExpr = $this->rememberPossiblyImpureFunctionValues

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe I misread the PR, but it seems the path where $this->rememberPossiblyImpureFunctionValues is false is not tested ?

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.

Incorrectly narrowed to previously asserted type, even if marked impure

3 participants