Skip to content

Commit f0a8295

Browse files
committed
TypeString::isKeyword(): correctly handle FQN null/true/false
Includes tests.
1 parent 4c3d9d3 commit f0a8295

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

PHPCSUtils/Utils/TypeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static function isKeyword($type)
129129
return false;
130130
}
131131

132-
$typeLC = \strtolower(\trim($type));
132+
$typeLC = \strtolower(\ltrim(\trim($type), '\\'));
133133
return isset(self::$keywordTypes[$typeLC]);
134134
}
135135

Tests/Utils/TypeString/IsKeywordTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ public static function dataIsKeywordValid()
117117
];
118118
}
119119

120+
$data['true: fully qualified'] = ['type' => '\true'];
121+
$data['false: fully qualified'] = ['type' => '\false'];
122+
$data['null: fully qualified'] = ['type' => '\null'];
123+
$data['true: fully qualified, uppercase'] = ['type' => '\TRUE'];
124+
$data['false: fully qualified, uppercase'] = ['type' => '\FALSE'];
125+
$data['null: fully qualified, uppercase'] = ['type' => '\NULL'];
126+
120127
return $data;
121128
}
122129

0 commit comments

Comments
 (0)