@@ -45,12 +45,12 @@ trait ClassNamespaceResolverTrait
4545 */
4646 protected static function createClassMap ($ dir ): array
4747 {
48- if (is_string ($ dir )) {
48+ if (\ is_string ($ dir )) {
4949 $ dir = new RecursiveIteratorIterator (new RecursiveDirectoryIterator ($ dir ));
5050 }
5151 $ map = [];
5252
53- if (is_array ($ dir ) || $ dir instanceof Traversable ) {
53+ if (\is_iterable ($ dir )) {
5454 foreach ($ dir as $ file ) {
5555 if (!$ file ->isFile ()) {
5656 continue ;
@@ -98,10 +98,19 @@ protected static function findClasses(string $path): array
9898 switch ($ token [0 ]) {
9999 case T_NAMESPACE :
100100 $ namespace = '' ;
101- // If there is a namespace, extract it
102- while (isset ($ tokens [++$ i ][1 ])) {
103- if (in_array ($ tokens [$ i ][0 ], [T_STRING , T_NS_SEPARATOR ])) {
104- $ namespace .= $ tokens [$ i ][1 ];
101+ // If there is a namespace, extract it (PHP 8 test)
102+ if (\defined ('T_NAME_QUALIFIED ' )){
103+ while (isset ($ tokens [++$ i ][1 ])) {
104+ if ($ tokens [$ i ][0 ] === T_NAME_QUALIFIED ) {
105+ $ namespace = $ tokens [$ i ][1 ];
106+ break ;
107+ }
108+ }
109+ }else {
110+ while (isset ($ tokens [++$ i ][1 ])) {
111+ if (\in_array ($ tokens [$ i ][0 ], [T_STRING , T_NS_SEPARATOR ], true )) {
112+ $ namespace .= $ tokens [$ i ][1 ];
113+ }
105114 }
106115 }
107116 $ namespace .= '\\' ;
@@ -118,7 +127,7 @@ protected static function findClasses(string $path): array
118127 if (T_DOUBLE_COLON === $ tokens [$ j ][0 ]) {
119128 $ isClassConstant = true ;
120129 break ;
121- } elseif (!in_array ($ tokens [$ j ][0 ], [T_WHITESPACE , T_DOC_COMMENT , T_COMMENT ], false )) {
130+ } elseif (!\ in_array ($ tokens [$ j ][0 ], [T_WHITESPACE , T_DOC_COMMENT , T_COMMENT ], false )) {
122131 break ;
123132 }
124133 }
@@ -140,6 +149,7 @@ protected static function findClasses(string $path): array
140149 break ;
141150 }
142151 }
152+
143153 return $ classes ;
144154 }
145155
0 commit comments