From e18a35744d8126722d9a634a6990a85c95945613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Sch=C3=A4fer?= Date: Fri, 2 Feb 2024 21:52:53 +0100 Subject: [PATCH] Fix crash when enum case references other enum case --- .../PhpVisitor/Reflector/ClassLikeNodeScanner.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php index 7589c018f98..9dd33594e91 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php @@ -1437,10 +1437,16 @@ private function visitEnumDeclaration( $case_location = new CodeLocation($this->file_scanner, $stmt); if ($stmt->expr !== null) { + $expr = $stmt->expr; + + if ($expr instanceof PhpParser\Node\Expr\PropertyFetch) { + $expr = $expr->var; + } + $case_type = SimpleTypeInferer::infer( $this->codebase, new NodeDataProvider(), - $stmt->expr, + $expr, $this->aliases, $this->file_scanner, $storage->constants,