Price enum case values through InitializerExprTypeResolver in EnumSanityRule - #6275
Merged
Merged
Conversation
…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.
This was referenced Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from
resolve-type-rewrite-2(extraction series, follows #6274).The backing-type check was the last place in
EnumSanityRulepricing an enum case value via$scope->getType()— the not-backed-enum message a few lines above already prices the very same$stmt->exprthroughInitializerExprTypeResolver. 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 phpstanclean,make csclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01R7pqAkCx4xP6WYxBo2nMJE