File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -229,9 +229,10 @@ public static function isIdentifier($value): bool
229
229
}
230
230
231
231
232
- public static function isNamespaceIdentifier ($ value ): bool
232
+ public static function isNamespaceIdentifier ($ value, bool $ allowLeadingSlash = FALSE ): bool
233
233
{
234
- return is_string ($ value ) && preg_match ('#^ ' . Helpers::PHP_IDENT . '( \\\\' . Helpers::PHP_IDENT . ')*\z# ' , $ value );
234
+ $ re = '#^ ' . ($ allowLeadingSlash ? '\\\\? ' : '' ) . Helpers::PHP_IDENT . '( \\\\' . Helpers::PHP_IDENT . ')*\z# ' ;
235
+ return is_string ($ value ) && preg_match ($ re , $ value );
235
236
}
236
237
237
238
Original file line number Diff line number Diff line change @@ -17,3 +17,6 @@ Assert::true(Helpers::isNamespaceIdentifier('Item\Item'));
17
17
Assert::false (Helpers::isNamespaceIdentifier ('Item \\\\Item ' ));
18
18
Assert::false (Helpers::isNamespaceIdentifier ('\\Item ' ));
19
19
Assert::false (Helpers::isNamespaceIdentifier ('Item \\' ));
20
+
21
+ Assert::true (Helpers::isNamespaceIdentifier ('\\Item ' , TRUE ));
22
+ Assert::false (Helpers::isNamespaceIdentifier ('Item \\' , TRUE ));
You can’t perform that action at this time.
0 commit comments