@@ -145,10 +145,11 @@ public function getClassname(string $file): string
145145
146146 if ((isset ($ tokens [$ i - 2 ][1 ]) && ($ tokens [$ i - 2 ][1 ] === 'phpnamespace ' || $ tokens [$ i - 2 ][1 ] === 'namespace ' )) || ($ dlm && $ tokens [$ i - 1 ][0 ] === T_NS_SEPARATOR && $ token [0 ] === T_STRING )) {
147147 if (! $ dlm ) {
148- $ namespace = 0 ;
148+ $ namespace = '' ;
149149 }
150+
150151 if (isset ($ token [1 ])) {
151- $ namespace = $ namespace ? $ namespace . '\\' . $ token [1 ] : $ token [1 ];
152+ $ namespace = $ namespace !== '' ? $ namespace . '\\' . $ token [1 ] : $ token [1 ];
152153 $ dlm = true ;
153154 }
154155 } elseif ($ dlm && ($ token [0 ] !== T_NS_SEPARATOR ) && ($ token [0 ] !== T_STRING )) {
@@ -194,8 +195,9 @@ public function search(string $path, string $ext = 'php', bool $prioritizeApp =
194195
195196 foreach ($ this ->getNamespaces () as $ namespace ) {
196197 if (isset ($ namespace ['path ' ]) && is_file ($ namespace ['path ' ] . $ path )) {
197- $ fullPath = $ namespace ['path ' ] . $ path ;
198- $ fullPath = realpath ($ fullPath ) ?: $ fullPath ;
198+ $ fullPath = $ namespace ['path ' ] . $ path ;
199+ $ resolvedPath = realpath ($ fullPath );
200+ $ fullPath = $ resolvedPath !== false ? $ resolvedPath : $ fullPath ;
199201
200202 if ($ prioritizeApp ) {
201203 $ foundPaths [] = $ fullPath ;
@@ -272,14 +274,16 @@ protected function getNamespaces()
272274 */
273275 public function findQualifiedNameFromPath (string $ path )
274276 {
275- $ path = realpath ($ path ) ?: $ path ;
277+ $ resolvedPath = realpath ($ path );
278+ $ path = $ resolvedPath !== false ? $ resolvedPath : $ path ;
276279
277280 if (! is_file ($ path )) {
278281 return false ;
279282 }
280283
281284 foreach ($ this ->getNamespaces () as $ namespace ) {
282- $ namespace ['path ' ] = realpath ($ namespace ['path ' ]) ?: $ namespace ['path ' ];
285+ $ resolvedNamespacePath = realpath ($ namespace ['path ' ]);
286+ $ namespace ['path ' ] = $ resolvedNamespacePath !== false ? $ resolvedNamespacePath : $ namespace ['path ' ];
283287
284288 if ($ namespace ['path ' ] === '' ) {
285289 continue ;
@@ -331,8 +335,9 @@ public function listFiles(string $path): array
331335 helper ('filesystem ' );
332336
333337 foreach ($ this ->getNamespaces () as $ namespace ) {
334- $ fullPath = $ namespace ['path ' ] . $ path ;
335- $ fullPath = realpath ($ fullPath ) ?: $ fullPath ;
338+ $ fullPath = $ namespace ['path ' ] . $ path ;
339+ $ resolvedPath = realpath ($ fullPath );
340+ $ fullPath = $ resolvedPath !== false ? $ resolvedPath : $ fullPath ;
336341
337342 if (! is_dir ($ fullPath )) {
338343 continue ;
@@ -365,8 +370,9 @@ public function listNamespaceFiles(string $prefix, string $path): array
365370
366371 // autoloader->getNamespace($prefix) returns an array of paths for that namespace
367372 foreach ($ this ->autoloader ->getNamespace ($ prefix ) as $ namespacePath ) {
368- $ fullPath = rtrim ($ namespacePath , '/ ' ) . '/ ' . $ path ;
369- $ fullPath = realpath ($ fullPath ) ?: $ fullPath ;
373+ $ fullPath = rtrim ($ namespacePath , '/ ' ) . '/ ' . $ path ;
374+ $ resolvedPath = realpath ($ fullPath );
375+ $ fullPath = $ resolvedPath !== false ? $ resolvedPath : $ fullPath ;
370376
371377 if (! is_dir ($ fullPath )) {
372378 continue ;
@@ -392,8 +398,9 @@ public function listNamespaceFiles(string $prefix, string $path): array
392398 */
393399 protected function legacyLocate (string $ file , ?string $ folder = null )
394400 {
395- $ path = APPPATH . ($ folder === null ? $ file : $ folder . '/ ' . $ file );
396- $ path = realpath ($ path ) ?: $ path ;
401+ $ path = APPPATH . ($ folder === null ? $ file : $ folder . '/ ' . $ file );
402+ $ resolvedPath = realpath ($ path );
403+ $ path = $ resolvedPath !== false ? $ resolvedPath : $ path ;
397404
398405 if (is_file ($ path )) {
399406 return $ path ;
0 commit comments