28
28
use function interface_exists ;
29
29
use function is_file ;
30
30
use function is_string ;
31
+ use function opcache_invalidate ;
31
32
use function restore_error_handler ;
32
33
use function set_error_handler ;
33
34
use function spl_autoload_functions ;
@@ -134,12 +135,23 @@ public function locateIdentifier(Reflector $reflector, Identifier $identifier):
134
135
if ($ locateResult === null ) {
135
136
return null ;
136
137
}
137
- [$ potentiallyLocatedFile , $ className , $ startLine ] = $ locateResult ;
138
+ [$ potentiallyLocatedFiles , $ className , $ startLine ] = $ locateResult ;
138
139
if ($ startLine !== null ) {
139
140
$ this ->startLineByClass [strtolower ($ className )] = $ startLine ;
140
141
}
141
142
142
- 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 ;
143
155
}
144
156
145
157
private function findReflection (Reflector $ reflector , string $ file , Identifier $ identifier , ?int $ startLine ): ?Reflection
@@ -312,7 +324,7 @@ private function getReflectionClass(string $className): ?ReflectionClass
312
324
* that it cannot find the file, so we squelch the errors by overriding the
313
325
* error handler temporarily.
314
326
*
315
- * @return array{string, string, int|null}|null
327
+ * @return array{string[] , string, int|null}|null
316
328
*/
317
329
private function locateClassByName (string $ className ): ?array
318
330
{
@@ -323,7 +335,7 @@ private function locateClassByName(string $className): ?array
323
335
return null ;
324
336
}
325
337
326
- return [$ filename , $ reflection ->getName (), $ reflection ->getStartLine () !== false ? $ reflection ->getStartLine () : null ];
338
+ return [[ $ filename] , $ reflection ->getName (), $ reflection ->getStartLine () !== false ? $ reflection ->getStartLine () : null ];
327
339
}
328
340
329
341
if (!$ this ->disableRuntimeReflectionProvider ) {
@@ -333,8 +345,8 @@ private function locateClassByName(string $className): ?array
333
345
$ this ->silenceErrors ();
334
346
335
347
try {
336
- /** @var array{string, string, null}|null */
337
- return FileReadTrapStreamWrapper::withStreamWrapperOverride (
348
+ /** @var array{string[] , string, null}|null */
349
+ $ result = FileReadTrapStreamWrapper::withStreamWrapperOverride (
338
350
static function () use ($ className ): ?array {
339
351
$ functions = spl_autoload_functions ();
340
352
if ($ functions === false ) {
@@ -350,14 +362,23 @@ static function () use ($className): ?array {
350
362
*
351
363
* This will not be `null` when the autoloader tried to read a file.
352
364
*/
353
- if (FileReadTrapStreamWrapper::$ autoloadLocatedFile !== null ) {
354
- return [FileReadTrapStreamWrapper::$ autoloadLocatedFile , $ className , null ];
365
+ if (FileReadTrapStreamWrapper::$ autoloadLocatedFiles !== [] ) {
366
+ return [FileReadTrapStreamWrapper::$ autoloadLocatedFiles , $ className , null ];
355
367
}
356
368
}
357
369
358
370
return null ;
359
371
},
360
372
);
373
+ if ($ result === null ) {
374
+ return null ;
375
+ }
376
+
377
+ foreach ($ result [0 ] as $ file ) {
378
+ opcache_invalidate ($ file , true );
379
+ }
380
+
381
+ return $ result ;
361
382
} finally {
362
383
restore_error_handler ();
363
384
}
0 commit comments