Skip to content

Commit ae53760

Browse files
committed
AutoloadSourceLocator - fix opcache corruption
1 parent bc000e8 commit ae53760

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Reflection/BetterReflection/SourceLocator/AutoloadSourceLocator.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use function interface_exists;
2929
use function is_file;
3030
use function is_string;
31+
use function opcache_invalidate;
3132
use function restore_error_handler;
3233
use function set_error_handler;
3334
use function spl_autoload_functions;
@@ -334,7 +335,7 @@ private function locateClassByName(string $className): ?array
334335

335336
try {
336337
/** @var array{string, string, null}|null */
337-
return FileReadTrapStreamWrapper::withStreamWrapperOverride(
338+
$result = FileReadTrapStreamWrapper::withStreamWrapperOverride(
338339
static function () use ($className): ?array {
339340
$functions = spl_autoload_functions();
340341
if ($functions === false) {
@@ -358,6 +359,13 @@ static function () use ($className): ?array {
358359
return null;
359360
},
360361
);
362+
if ($result === null) {
363+
return null;
364+
}
365+
366+
opcache_invalidate($result[0], true);
367+
368+
return $result;
361369
} finally {
362370
restore_error_handler();
363371
}

0 commit comments

Comments
 (0)