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
229229 }
230230
231231
232- public static function isNamespaceIdentifier ($ value ): bool
232+ public static function isNamespaceIdentifier ($ value, bool $ allowLeadingSlash = FALSE ): bool
233233 {
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 );
235236 }
236237
237238
Original file line number Diff line number Diff line change @@ -17,3 +17,6 @@ Assert::true(Helpers::isNamespaceIdentifier('Item\Item'));
1717Assert::false (Helpers::isNamespaceIdentifier ('Item \\\\Item ' ));
1818Assert::false (Helpers::isNamespaceIdentifier ('\\Item ' ));
1919Assert::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