diff --git a/bin/rector.php b/bin/rector.php index 5860ed1b7d0..48a0cc6e8bb 100755 --- a/bin/rector.php +++ b/bin/rector.php @@ -6,6 +6,7 @@ use Rector\Bootstrap\RectorConfigsResolver; use Rector\ChangesReporting\Output\JsonOutputFormatter; use Rector\Configuration\Option; +use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\Console\Style\SymfonyStyleFactory; use Rector\DependencyInjection\LazyContainerFactory; use Rector\DependencyInjection\RectorContainerFactory; @@ -127,6 +128,14 @@ public function loadIfExistsAndNotLoadedYet(string $filePath): void $autoloadIncluder->autoloadRectorInstalledAsGlobalDependency(); $autoloadIncluder->autoloadFromCommandLine(); +// a different extra autoload changes what PHPStan can resolve, so cached results +// must not survive it: register it before the configuration hash is computed. +// ArgvInput handles both "--autoload-file path" and "--autoload-file=path" +$autoloadFileOption = (new ArgvInput())->getParameterOption(['--autoload-file', '-a'], null); +if (is_string($autoloadFileOption) && $autoloadFileOption !== '') { + SimpleParameterProvider::setParameter(Option::AUTOLOAD_FILE, realpath($autoloadFileOption) ?: $autoloadFileOption); +} + $rectorConfigsResolver = new RectorConfigsResolver(); try {