Skip to content

Commit

Permalink
Fix and simplify discovering composer autoloader project path
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 14, 2024
1 parent f16d85a commit 2cc6cda
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions bin/phpstan
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,30 @@ use Symfony\Component\Console\Helper\ProgressBar;
require_once $autoloaderInWorkingDirectory;
}

$autoloadProjectAutoloaderFile = function (string $file) use (&$composerAutoloaderProjectPaths): void {
$path = dirname(__DIR__) . $file;
if (!extension_loaded('phar')) {
$path = dirname(__DIR__, 3) . '/autoload.php';
if (!extension_loaded('phar')) {
if (@is_file($path)) {
$composerAutoloaderProjectPaths[] = dirname($path, 2);

require_once $path;
}
} else {
$pharPath = \Phar::running(false);
if ($pharPath === '') {
if (@is_file($path)) {
$composerAutoloaderProjectPaths[] = dirname($path, 2);

require_once $path;
}
} else {
$pharPath = \Phar::running(false);
if ($pharPath === '') {
if (@is_file($path)) {
$composerAutoloaderProjectPaths[] = dirname($path, 2);

require_once $path;
}
} else {
$path = dirname($pharPath) . $file;
if (@is_file($path)) {
$composerAutoloaderProjectPaths[] = dirname($path, 2);
$path = dirname($pharPath, 3) . '/autoload.php';
if (@is_file($path)) {
$composerAutoloaderProjectPaths[] = dirname($path, 2);

require_once $path;
}
require_once $path;
}
}
};

$autoloadProjectAutoloaderFile('/../../autoload.php');
}

/** @var array<callable>|false $autoloadFunctionsAfter */
$autoloadFunctionsAfter = spl_autoload_functions();
Expand Down

0 comments on commit 2cc6cda

Please sign in to comment.