File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/Reflection/BetterReflection/SourceLocator Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 13
13
class OptimizedPsrAutoloaderLocator implements SourceLocator
14
14
{
15
15
16
+ /** @var array<string, OptimizedSingleFileSourceLocator> */
17
+ private array $ locators = [];
18
+
16
19
public function __construct (
17
20
private PsrAutoloaderMapping $ mapping ,
18
21
private OptimizedSingleFileSourceLocatorRepository $ optimizedSingleFileSourceLocatorRepository ,
@@ -22,16 +25,28 @@ public function __construct(
22
25
23
26
public function locateIdentifier (Reflector $ reflector , Identifier $ identifier ): ?Reflection
24
27
{
28
+ foreach ($ this ->locators as $ locator ) {
29
+ $ reflection = $ locator ->locateIdentifier ($ reflector , $ identifier );
30
+ if ($ reflection === null ) {
31
+ continue ;
32
+ }
33
+
34
+ return $ reflection ;
35
+ }
36
+
25
37
foreach ($ this ->mapping ->resolvePossibleFilePaths ($ identifier ) as $ file ) {
26
38
if (!is_file ($ file )) {
27
39
continue ;
28
40
}
29
41
30
- $ reflection = $ this ->optimizedSingleFileSourceLocatorRepository ->getOrCreate ($ file )->locateIdentifier ($ reflector , $ identifier );
42
+ $ locator = $ this ->optimizedSingleFileSourceLocatorRepository ->getOrCreate ($ file );
43
+ $ reflection = $ locator ->locateIdentifier ($ reflector , $ identifier );
31
44
if ($ reflection === null ) {
32
45
continue ;
33
46
}
34
47
48
+ $ this ->locators [$ file ] = $ locator ;
49
+
35
50
return $ reflection ;
36
51
}
37
52
You can’t perform that action at this time.
0 commit comments