1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #934 - allow numbers in class constant enums

This commit is contained in:
Matthew Brown 2018-08-08 20:36:16 -04:00
parent 226aa27686
commit 55be2c3ce4
2 changed files with 3 additions and 3 deletions

View File

@ -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
);

View File

@ -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");