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

Add checks for Psalm reserved words in assertions

This commit is contained in:
Matthew Brown 2019-01-13 14:06:30 -05:00
parent 94aa51ba6d
commit 1de0e35545
2 changed files with 6 additions and 3 deletions

View File

@ -1513,7 +1513,10 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
$assertion_type = substr($assertion_type, 1);
}
if ($assertion_type !== 'falsy' && !isset($template_types[$assertion_type])) {
if ($assertion_type !== 'falsy'
&& !isset($template_types[$assertion_type])
&& !isset(Type::PSALM_RESERVED_WORDS[$assertion_type])
) {
$assertion_type = Type::getFQCLNFromString($assertion_type, $this->aliases);
}

View File

@ -41,7 +41,7 @@ abstract class Type
/**
* @var array<string, bool>
*/
public static $PSALM_RESERVED_WORDS = [
const PSALM_RESERVED_WORDS = [
'int' => true,
'string' => true,
'float' => true,
@ -762,7 +762,7 @@ abstract class Type
$type_tokens[$i] = $string_type_token = self::fixScalarTerms($string_type_token);
if (isset(self::$PSALM_RESERVED_WORDS[$string_type_token])) {
if (isset(self::PSALM_RESERVED_WORDS[$string_type_token])) {
continue;
}