diff --git a/src/Psalm/Type/ParseTree.php b/src/Psalm/Type/ParseTree.php index f8048882d..7a45f9737 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_]+$/', $nexter_token)) { + if (!$nexter_token || !preg_match('/^[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 98ef5817c..b8d5ca2d7 100644 --- a/tests/EnumTest.php +++ b/tests/EnumTest.php @@ -60,10 +60,10 @@ class EnumTest extends TestCase namespace Ns; class C { - const A = "bat"; + const A1 = "bat"; const B = "baz"; } - /** @psalm-param "foo"|"bar"|C::A|C::B $s */ + /** @psalm-param "foo"|"bar"|C::A1|C::B $s */ function foo($s) : void {} foo("foo"); foo("bar");