Skip to content

Price enum case values through InitializerExprTypeResolver in EnumSanityRule - #6275

Merged
ondrejmirtes merged 1 commit into
2.2.xfrom
enum-sanity-initializer-expr
Aug 26, 2026
Merged

ondrejmirtes merged 1 commit into
2.2.xfrom
enum-sanity-initializer-expr

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Extracted from resolve-type-rewrite-2 (extraction series, follows #6274).

The backing-type check was the last place in EnumSanityRule pricing an enum case value via $scope->getType() — the not-backed-enum message a few lines above already prices the very same $stmt->expr through InitializerExprTypeResolver. Enum case values are constant initializer expressions, so the initializer resolver is the right tool in both places; the rule now uses it consistently.

No behavioral difference is expected or observed — case values cannot reference runtime scope state.

Gates: full suite 21155 tests / 96002 assertions green, make phpstan clean, make cs clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01R7pqAkCx4xP6WYxBo2nMJE

…ityRule

The rule fires on InClassNode before the enum body is walked; case values
are initializer expressions, so the initializer resolver (already used by
the not-backed-enum message) is the right source - not Scope::getType()
on the yet-unprocessed node.
@ondrejmirtes
ondrejmirtes merged commit 1746e51 into 2.2.x Aug 26, 2026
182 of 185 checks passed
@ondrejmirtes
ondrejmirtes deleted the enum-sanity-initializer-expr branch August 26, 2026 11:54
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.

1 participant