6
6
use PHPStan \BetterReflection \SourceLocator \Ast \Locator ;
7
7
use PHPStan \BetterReflection \SourceLocator \SourceStubber \PhpStormStubsSourceStubber ;
8
8
use PHPStan \BetterReflection \SourceLocator \Type \AggregateSourceLocator ;
9
+ use PHPStan \BetterReflection \SourceLocator \Type \Composer \Psr \Psr4Mapping ;
9
10
use PHPStan \BetterReflection \SourceLocator \Type \MemoizingSourceLocator ;
10
11
use PHPStan \BetterReflection \SourceLocator \Type \PhpInternalSourceLocator ;
11
12
use PHPStan \BetterReflection \SourceLocator \Type \SourceLocator ;
13
+ use PHPStan \Reflection \BetterReflection \SourceLocator \OptimizedPsrAutoloaderLocatorFactory ;
12
14
use PHPStan \Reflection \BetterReflection \SourceLocator \OptimizedSingleFileSourceLocatorRepository ;
15
+ use function dirname ;
13
16
14
17
class StubSourceLocatorFactory
15
18
{
@@ -18,6 +21,7 @@ public function __construct(
18
21
private Parser $ php8Parser ,
19
22
private PhpStormStubsSourceStubber $ phpStormStubsSourceStubber ,
20
23
private OptimizedSingleFileSourceLocatorRepository $ optimizedSingleFileSourceLocatorRepository ,
24
+ private OptimizedPsrAutoloaderLocatorFactory $ optimizedPsrAutoloaderLocatorFactory ,
21
25
private StubFilesProvider $ stubFilesProvider ,
22
26
)
23
27
{
@@ -31,6 +35,12 @@ public function create(): SourceLocator
31
35
$ locators [] = $ this ->optimizedSingleFileSourceLocatorRepository ->getOrCreate ($ stubFile );
32
36
}
33
37
38
+ $ locators [] = $ this ->optimizedPsrAutoloaderLocatorFactory ->create (
39
+ Psr4Mapping::fromArrayMappings ([
40
+ 'PHPStan \\' => [dirname (__DIR__ ) . '/ ' ],
41
+ ]),
42
+ );
43
+
34
44
$ locators [] = new PhpInternalSourceLocator ($ astPhp8Locator , $ this ->phpStormStubsSourceStubber );
35
45
36
46
return new MemoizingSourceLocator (new AggregateSourceLocator ($ locators ));
0 commit comments