Skip to content

Infer non-negative offsets for mandatory regex groups - #6323

Open
gwosti wants to merge 1 commit into
phpstan:2.3.xfrom
gwosti:fix/regex-mandatory-group-offsets
Open

gwosti wants to merge 1 commit into
phpstan:2.3.xfrom
gwosti:fix/regex-mandatory-group-offsets

Conversation

@gwosti

@gwosti gwosti commented Sep 1, 2026

Copy link
Copy Markdown

Summary

  • Infer non-negative offsets for full matches and mandatory PREG_OFFSET_CAPTURE groups.
  • Preserve -1 for potentially unmatched groups and add focused regression coverage.

Closes phpstan/phpstan#14959

Validation

  • php vendor/bin/phpunit tests/PHPStan/Analyser/NodeScopeResolverTest.php --filter bug-14959
  • make tests && make phpstan
  • make lint && make cs && composer validate --no-interaction

@ondrejmirtes
ondrejmirtes force-pushed the fix/regex-mandatory-group-offsets branch from 48adf11 to 5f51c6d Compare October 31, 2026 13:31
@ondrejmirtes
ondrejmirtes changed the base branch from 2.2.x to 2.3.x October 31, 2026 13:31
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.

Incorrect lower bound -1 for offset in mandatory preg_match() groups when 0 (non-negative-int) is expected

2 participants