diff --git a/src/Psalm/Type/ParseTree.php b/src/Psalm/Type/ParseTree.php index 7a45f9737..dd9bd682e 100644 --- a/src/Psalm/Type/ParseTree.php +++ b/src/Psalm/Type/ParseTree.php @@ -465,7 +465,7 @@ class ParseTree case '::': $nexter_token = $i + 2 < $c ? $type_tokens[$i + 2] : null; - if (!$nexter_token || !preg_match('/^[A-Z_0-9]+$/', $nexter_token)) { + if (!$nexter_token || !preg_match('/^[A-Z_][A-Z_0-9]*$/', $nexter_token)) { throw new TypeParseTreeException( 'Invalid class constant ' . $nexter_token ); diff --git a/tests/EnumTest.php b/tests/EnumTest.php index 664a78a83..2dff92a4b 100644 --- a/tests/EnumTest.php +++ b/tests/EnumTest.php @@ -156,6 +156,19 @@ class EnumTest extends TestCase A::foo("for");', 'error_message' => 'InvalidArgument', ], + 'selfClassConstBadValue' => [ + ' 'InvalidDocblock', + ], ]; } }