1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Prevent leading-number constants in docblocks

This commit is contained in:
Matthew Brown 2018-08-08 21:36:33 -04:00
parent 6670dd31e1
commit 9880e2bede
2 changed files with 14 additions and 1 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_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
);

View File

@ -156,6 +156,19 @@ class EnumTest extends TestCase
A::foo("for");',
'error_message' => 'InvalidArgument',
],
'selfClassConstBadValue' => [
'<?php
class A {
const FOO = "foo";
const BAR = "bar";
/**
* @param (self::1FOO | self::BAR) $s
*/
public static function foo(string $s) : void {}
}',
'error_message' => 'InvalidDocblock',
],
];
}
}