Skip to content

Commit 008a887

Browse files
authored
refactor(testing): optimize ClassLoader detection in phpunit-patch (#7592)
1 parent bbc3580 commit 008a887

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

phpunit-patch.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@
1515
(function () {
1616
/** @var null|ClassLoader $classLoader */
1717
$classLoader = null;
18-
foreach ([
19-
__DIR__ . '/../../vendor/autoload.php',
20-
__DIR__ . '/../../autoload.php',
21-
] as $file) {
22-
if (file_exists($file)) {
23-
$classLoader = require $file;
18+
foreach (spl_autoload_functions() as $loader) {
19+
if (is_array($loader) && $loader[0] instanceof ClassLoader) {
20+
$classLoader = $loader[0];
2421
break;
2522
}
2623
}
27-
if (! $classLoader instanceof ClassLoader) {
24+
if (! $classLoader) {
2825
return;
2926
}
3027
if ($file = $classLoader->findFile(TestCase::class)) {

0 commit comments

Comments
 (0)