66use PHPStan \BetterReflection \SourceLocator \Ast \Locator ;
77use PHPStan \BetterReflection \SourceLocator \SourceStubber \PhpStormStubsSourceStubber ;
88use PHPStan \BetterReflection \SourceLocator \Type \AggregateSourceLocator ;
9+ use PHPStan \BetterReflection \SourceLocator \Type \Composer \Psr \Psr4Mapping ;
910use PHPStan \BetterReflection \SourceLocator \Type \MemoizingSourceLocator ;
1011use PHPStan \BetterReflection \SourceLocator \Type \PhpInternalSourceLocator ;
1112use PHPStan \BetterReflection \SourceLocator \Type \SourceLocator ;
13+ use PHPStan \Reflection \BetterReflection \SourceLocator \OptimizedPsrAutoloaderLocatorFactory ;
1214use PHPStan \Reflection \BetterReflection \SourceLocator \OptimizedSingleFileSourceLocatorRepository ;
15+ use function dirname ;
1316
1417class StubSourceLocatorFactory
1518{
@@ -18,6 +21,7 @@ public function __construct(
1821 private Parser $ php8Parser ,
1922 private PhpStormStubsSourceStubber $ phpStormStubsSourceStubber ,
2023 private OptimizedSingleFileSourceLocatorRepository $ optimizedSingleFileSourceLocatorRepository ,
24+ private OptimizedPsrAutoloaderLocatorFactory $ optimizedPsrAutoloaderLocatorFactory ,
2125 private StubFilesProvider $ stubFilesProvider ,
2226 )
2327 {
@@ -31,6 +35,12 @@ public function create(): SourceLocator
3135 $ locators [] = $ this ->optimizedSingleFileSourceLocatorRepository ->getOrCreate ($ stubFile );
3236 }
3337
38+ $ locators [] = $ this ->optimizedPsrAutoloaderLocatorFactory ->create (
39+ Psr4Mapping::fromArrayMappings ([
40+ 'PHPStan \\' => [dirname (__DIR__ ) . '/ ' ],
41+ ]),
42+ );
43+
3444 $ locators [] = new PhpInternalSourceLocator ($ astPhp8Locator , $ this ->phpStormStubsSourceStubber );
3545
3646 return new MemoizingSourceLocator (new AggregateSourceLocator ($ locators ));
0 commit comments