@@ -1287,33 +1287,7 @@ public function classFileExists($class, &$path = '')
1287
1287
1288
1288
$ directories = array_merge ($ directories , $ this ->getPaths ());
1289
1289
1290
- foreach ($ directories as $ dir ) {
1291
- $ fullPath = $ dir . '/ ' . $ path ;
1292
- if ($ this ->classFileExistsCheckContent ($ fullPath , $ namespace , $ className )) {
1293
- return true ;
1294
- }
1295
- $ classParts = explode ('/ ' , $ path , 3 );
1296
- if (count ($ classParts ) >= 3 ) {
1297
- // Check if it's PSR-4 class with trimmed vendor and package name parts
1298
- $ trimmedFullPath = $ dir . '/ ' . $ classParts [2 ];
1299
- if ($ this ->classFileExistsCheckContent ($ trimmedFullPath , $ namespace , $ className )) {
1300
- return true ;
1301
- }
1302
- }
1303
- $ classParts = explode ('/ ' , $ path , 4 );
1304
- if (count ($ classParts ) >= 4 ) {
1305
- // Check if it's a library under framework directory
1306
- $ trimmedFullPath = $ dir . '/ ' . $ classParts [3 ];
1307
- if ($ this ->classFileExistsCheckContent ($ trimmedFullPath , $ namespace , $ className )) {
1308
- return true ;
1309
- }
1310
- $ trimmedFullPath = $ dir . '/ ' . $ classParts [2 ] . '/ ' . $ classParts [3 ];
1311
- if ($ this ->classFileExistsCheckContent ($ trimmedFullPath , $ namespace , $ className )) {
1312
- return true ;
1313
- }
1314
- }
1315
- }
1316
- return false ;
1290
+ return $ this ->checkDirectories ($ path , $ directories , $ namespace , $ className );
1317
1291
}
1318
1292
1319
1293
/**
@@ -1555,4 +1529,45 @@ protected function getFilesSubset(array $dirPatterns, $fileNamePattern, $exclude
1555
1529
}
1556
1530
return $ fileSet ;
1557
1531
}
1532
+
1533
+ /**
1534
+ * Check class exists in searchable directories.
1535
+ *
1536
+ * @param string $path
1537
+ * @param array $directories
1538
+ * @param string $namespace
1539
+ * @param string $className
1540
+ * @return bool
1541
+ */
1542
+ private function checkDirectories (&$ path , $ directories , $ namespace , $ className )
1543
+ {
1544
+ foreach ($ directories as $ dir ) {
1545
+ $ fullPath = $ dir . '/ ' . $ path ;
1546
+ if ($ this ->classFileExistsCheckContent ($ fullPath , $ namespace , $ className )) {
1547
+ return true ;
1548
+ }
1549
+ $ classParts = explode ('/ ' , $ path , 3 );
1550
+ if (count ($ classParts ) >= 3 ) {
1551
+ // Check if it's PSR-4 class with trimmed vendor and package name parts
1552
+ $ trimmedFullPath = $ dir . '/ ' . $ classParts [2 ];
1553
+ if ($ this ->classFileExistsCheckContent ($ trimmedFullPath , $ namespace , $ className )) {
1554
+ return true ;
1555
+ }
1556
+ }
1557
+ $ classParts = explode ('/ ' , $ path , 4 );
1558
+ if (count ($ classParts ) >= 4 ) {
1559
+ // Check if it's a library under framework directory
1560
+ $ trimmedFullPath = $ dir . '/ ' . $ classParts [3 ];
1561
+ if ($ this ->classFileExistsCheckContent ($ trimmedFullPath , $ namespace , $ className )) {
1562
+ return true ;
1563
+ }
1564
+ $ trimmedFullPath = $ dir . '/ ' . $ classParts [2 ] . '/ ' . $ classParts [3 ];
1565
+ if ($ this ->classFileExistsCheckContent ($ trimmedFullPath , $ namespace , $ className )) {
1566
+ return true ;
1567
+ }
1568
+ }
1569
+ }
1570
+
1571
+ return false ;
1572
+ }
1558
1573
}
0 commit comments