diff --git a/bin/rector.php b/bin/rector.php index 05394992ae8..d0e4b36d955 100755 --- a/bin/rector.php +++ b/bin/rector.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Composer\XdebugHandler\XdebugHandler; use Nette\Utils\Json; use Rector\Bootstrap\AutoloadFileParameterResolver; use Rector\Bootstrap\RectorConfigsResolver; @@ -123,6 +124,14 @@ public function loadIfExistsAndNotLoadedYet(string $filePath): void $autoloadIncluder->autoloadRectorInstalledAsGlobalDependency(); $autoloadIncluder->autoloadFromCommandLine(); +// restart without Xdebug before the container is built, so the restarted process does not repeat that work +if (! new ArgvInput()->hasParameterOption('--xdebug')) { + $xdebugHandler = new XdebugHandler('rector'); + $xdebugHandler->setPersistent(); + $xdebugHandler->check(); + unset($xdebugHandler); +} + AutoloadFileParameterResolver::resolveFromArgv($_SERVER['argv']); $rectorConfigsResolver = new RectorConfigsResolver(); diff --git a/src/Console/ConsoleApplication.php b/src/Console/ConsoleApplication.php index 80fd68a27c9..2fee6c57f73 100644 --- a/src/Console/ConsoleApplication.php +++ b/src/Console/ConsoleApplication.php @@ -4,7 +4,6 @@ namespace Rector\Console; -use Composer\XdebugHandler\XdebugHandler; use Rector\Application\VersionResolver; use Rector\ChangesReporting\Output\ConsoleOutputFormatter; use Rector\Configuration\Option; @@ -49,8 +48,6 @@ public function doRun(InputInterface $input, OutputInterface $output): int return ExitCode::SUCCESS; } - $this->enableXdebug($input); - $shouldFollowByNewline = false; // skip in this case, since generate content must be clear from meta-info @@ -165,15 +162,4 @@ private function addCustomOptions(InputDefinition $inputDefinition): void 'Clear cache before starting the execution of the command' )); } - - private function enableXdebug(InputInterface $input): void - { - $isXdebugAllowed = $input->hasParameterOption('--xdebug'); - if (! $isXdebugAllowed) { - $xdebugHandler = new XdebugHandler('rector'); - $xdebugHandler->setPersistent(); - $xdebugHandler->check(); - unset($xdebugHandler); - } - } }