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:
parent
6670dd31e1
commit
9880e2bede
@ -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
|
||||
);
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user