@@ -135,12 +135,23 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):
135135 if ($ locateResult === null ) {
136136 return null ;
137137 }
138- [$ potentiallyLocatedFile , $ className , $ startLine ] = $ locateResult ;
138+ [$ potentiallyLocatedFiles , $ className , $ startLine ] = $ locateResult ;
139139 if ($ startLine !== null ) {
140140 $ this ->startLineByClass [strtolower ($ className )] = $ startLine ;
141141 }
142142
143- return $ this ->findReflection ($ reflector , $ potentiallyLocatedFile , new Identifier ($ className , $ identifier ->getType ()), $ startLine );
143+ $ newIdentifier = new Identifier ($ className , $ identifier ->getType ());
144+
145+ foreach ($ potentiallyLocatedFiles as $ potentiallyLocatedFile ) {
146+ $ reflection = $ this ->findReflection ($ reflector , $ potentiallyLocatedFile , $ newIdentifier , $ startLine );
147+ if ($ reflection === null ) {
148+ continue ;
149+ }
150+
151+ return $ reflection ;
152+ }
153+
154+ return null ;
144155 }
145156
146157 private function findReflection (Reflector $ reflector , string $ file , Identifier $ identifier , ?int $ startLine ): ?Reflection
@@ -313,7 +324,7 @@ private function getReflectionClass(string $className): ?ReflectionClass
313324 * that it cannot find the file, so we squelch the errors by overriding the
314325 * error handler temporarily.
315326 *
316- * @return array{string, string, int|null}|null
327+ * @return array{string[] , string, int|null}|null
317328 */
318329 private function locateClassByName (string $ className ): ?array
319330 {
@@ -324,7 +335,7 @@ private function locateClassByName(string $className): ?array
324335 return null ;
325336 }
326337
327- return [$ filename , $ reflection ->getName (), $ reflection ->getStartLine () !== false ? $ reflection ->getStartLine () : null ];
338+ return [[ $ filename] , $ reflection ->getName (), $ reflection ->getStartLine () !== false ? $ reflection ->getStartLine () : null ];
328339 }
329340
330341 if (!$ this ->disableRuntimeReflectionProvider ) {
@@ -334,7 +345,7 @@ private function locateClassByName(string $className): ?array
334345 $ this ->silenceErrors ();
335346
336347 try {
337- /** @var array{string, string, null}|null */
348+ /** @var array{string[] , string, null}|null */
338349 $ result = FileReadTrapStreamWrapper::withStreamWrapperOverride (
339350 static function () use ($ className ): ?array {
340351 $ functions = spl_autoload_functions ();
@@ -351,8 +362,8 @@ static function () use ($className): ?array {
351362 *
352363 * This will not be `null` when the autoloader tried to read a file.
353364 */
354- if (FileReadTrapStreamWrapper::$ autoloadLocatedFile !== null ) {
355- return [FileReadTrapStreamWrapper::$ autoloadLocatedFile , $ className , null ];
365+ if (FileReadTrapStreamWrapper::$ autoloadLocatedFiles !== [] ) {
366+ return [FileReadTrapStreamWrapper::$ autoloadLocatedFiles , $ className , null ];
356367 }
357368 }
358369
@@ -363,7 +374,9 @@ static function () use ($className): ?array {
363374 return null ;
364375 }
365376
366- opcache_invalidate ($ result [0 ], true );
377+ foreach ($ result [0 ] as $ file ) {
378+ opcache_invalidate ($ file , true );
379+ }
367380
368381 return $ result ;
369382 } finally {
0 commit comments