Skip to content

Commit 81f4975

Browse files
authored
Merge pull request #9 from Aeliot-Tm/optimise-autoloader-detection
Optimize requiring of autoloader
2 parents 9666b94 + b296756 commit 81f4975

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

bin/pcsf-baseline

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@ use Aeliot\PhpCsFixerBaseline\Service\Builder;
55
use Aeliot\PhpCsFixerBaseline\Service\Saver;
66

77
$autoloaderPath = (static function (): string {
8+
if (isset($GLOBALS['_composer_autoload_path'])) {
9+
return $GLOBALS['_composer_autoload_path'];
10+
}
11+
812
$paths = [
9-
__DIR__ . '/vendor/autoload.php',
13+
__DIR__ . '/../../../../vendor/autoload.php',
1014
__DIR__ . '/../vendor/autoload.php',
1115
__DIR__ . '/../../vendor/autoload.php',
1216
__DIR__ . '/../../../vendor/autoload.php',
13-
__DIR__ . '/../../../../vendor/autoload.php',
1417
];
1518

16-
if (isset($GLOBALS['_composer_autoload_path'])) {
17-
array_unshift($paths, $GLOBALS['_composer_autoload_path']);
18-
}
19-
2019
foreach ($paths as $path) {
2120
if (file_exists($path)) {
22-
return realpath($path);
21+
return $path;
2322
}
2423
}
2524

0 commit comments

Comments
 (0)