16
16
use PHPStan \Reflection \BetterReflection \SourceLocator \AutoloadSourceLocator ;
17
17
use PHPStan \Reflection \BetterReflection \SourceLocator \ComposerJsonAndInstalledJsonSourceLocatorMaker ;
18
18
use PHPStan \Reflection \BetterReflection \SourceLocator \FileNodesFetcher ;
19
+ use PHPStan \Reflection \BetterReflection \SourceLocator \OptimizedSingleFileSourceLocatorRepository ;
19
20
use PHPStan \Reflection \BetterReflection \SourceLocator \PhpVersionBlacklistSourceLocator ;
20
21
use ReflectionClass ;
21
22
use function dirname ;
@@ -35,6 +36,7 @@ final class TestCaseSourceLocatorFactory
35
36
*/
36
37
public function __construct (
37
38
private ComposerJsonAndInstalledJsonSourceLocatorMaker $ composerJsonAndInstalledJsonSourceLocatorMaker ,
39
+ private OptimizedSingleFileSourceLocatorRepository $ optimizedSingleFileSourceLocatorRepository ,
38
40
private Parser $ phpParser ,
39
41
private Parser $ php8Parser ,
40
42
private FileNodesFetcher $ fileNodesFetcher ,
@@ -57,7 +59,13 @@ public function create(): SourceLocator
57
59
$ this ->excludePaths ,
58
60
]));
59
61
if ($ classLoaderReflection ->hasProperty ('vendorDir ' ) && ! isset (self ::$ composerSourceLocatorsCache [$ cacheKey ])) {
60
- $ composerLocators = [];
62
+ $ composerLocators = [
63
+ $ this ->optimizedSingleFileSourceLocatorRepository ->getOrCreate (
64
+ PHP_VERSION_ID < 80500
65
+ ? __DIR__ . '/../../stubs/runtime/Attribute84.php '
66
+ : __DIR__ . '/../../stubs/runtime/Attribute85.php ' ,
67
+ ),
68
+ ];
61
69
$ vendorDirProperty = $ classLoaderReflection ->getProperty ('vendorDir ' );
62
70
$ vendorDirProperty ->setAccessible (true );
63
71
foreach ($ classLoaders as $ classLoader ) {
0 commit comments