Skip to content

AcceptsResult: cache Yes/No/Maybe - #5095

Merged
VincentLanglet merged 1 commit into
phpstan:2.1.xfrom
VincentLanglet:acceptsResults
Feb 28, 2026
Merged

VincentLanglet merged 1 commit into
phpstan:2.1.xfrom
VincentLanglet:acceptsResults

Conversation

@VincentLanglet

Copy link
Copy Markdown
Contributor

I found some useless variable in lazyMaxMin, and then I found that you cached Yes/no/maybe in SuperTypeOf but not AcceptResult @staabm. I think we can do the same.

@VincentLanglet
VincentLanglet changed the base branch from 2.2.x to 2.1.x February 28, 2026 13:25
@phpstan-bot

Copy link
Copy Markdown
Collaborator

You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x.

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

Thanks

callable $callback,
): self
{
$results = [];

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.

Would be nice phpstan would detect local variables which are only written but never read

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are feature requests for that. It'd be very easy to implement too I think. We'd need virtual expr nodes like PropertyInitializationExpr to track things in scope.

@VincentLanglet
VincentLanglet merged commit 075e0f5 into phpstan:2.1.x Feb 28, 2026
638 of 649 checks passed
phpstan-bot pushed a commit to phpstan-bot/phpstan-src that referenced this pull request Apr 7, 2026
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.

4 participants