Skip to content

Commit 1746e51

Browse files
committed
Price enum case values through InitializerExprTypeResolver in EnumSanityRule
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.
1 parent 24cde24 commit 1746e51

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎src/Rules/Classes/EnumSanityRule.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function processNode(Node $node, Scope $scope): array
190190
continue;
191191
}
192192

193-
$exprType = $scope->getType($stmt->expr);
193+
$exprType = $this->initializerExprTypeResolver->getType($stmt->expr, InitializerExprContext::fromScope($scope));
194194
$scalarType = $enumNode->scalarType->toLowerString() === 'int' ? new IntegerType() : new StringType();
195195
if ($scalarType->isSuperTypeOf($exprType)->yes()) {
196196
$constantValues = $exprType->getConstantScalarValues();

0 commit comments

Comments
 (0)