Skip to content

False Positive on Match Arm Comparison with Incremented Bounded Integer#5003

Open
VincentLanglet wants to merge 3 commits intophpstan:2.1.xfrom
VincentLanglet:fix/11310
Open

False Positive on Match Arm Comparison with Incremented Bounded Integer#5003
VincentLanglet wants to merge 3 commits intophpstan:2.1.xfrom
VincentLanglet:fix/11310

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Feb 19, 2026

Inspired from #4968

Closes phpstan/phpstan#11310

phpstan-bot and others added 2 commits February 19, 2026 20:06
- MutatingScope::enterMatch() re-evaluated the condition type after the
  scope had already been updated by processing the increment expression,
  causing $i++ to be seen as int<1, max> instead of int<0, max>
- Pass the pre-computed condition type and native type from
  NodeScopeResolver to enterMatch() so it uses the correct types
- New regression test in tests/PHPStan/Rules/Comparison/data/bug-11310.php

Closes phpstan/phpstan#11310
Automated fix attempt 1 for CI failures.
@VincentLanglet VincentLanglet marked this pull request as ready for review February 19, 2026 20:01
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

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.

2 participants

Comments