Skip to content

Commit

Permalink
[Parallel] Fix missing --xdebug in WorkerCommand line on WorkerComman…
Browse files Browse the repository at this point in the history
…dLineFactory when --xdebug provided (#5398)

* [Parallel] Fix missing --xdebug in WorkerCommand line on WorkerCommandLineFactory when --xdebug provided

* register XDEBUG to ProcessConfigureDecorator

* add unit test

* use XdebugHandler
  • Loading branch information
samsonasik committed Dec 28, 2023
1 parent 109d734 commit f54a79b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages-tests/Parallel/Command/WorkerCommandLineFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ public static function provideDataSpacedMainScript(): Iterator
],
"'" . PHP_BINARY . "' '" . self::SPACED_DUMMY_MAIN_SCRIPT . "' '" . $cliInputOptionsAsString . "' worker --debug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi",
];

yield [
[
self::COMMAND => 'process',
Option::SOURCE => ['src'],
'--' . Option::OUTPUT_FORMAT => ConsoleOutputFormatter::NAME,
'--' . Option::DEBUG => true,
'--' . Option::XDEBUG => true,
],
"'" . PHP_BINARY . "' '" . self::SPACED_DUMMY_MAIN_SCRIPT . "' '" . $cliInputOptionsAsString . "' worker --debug --xdebug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi",
];
}

/**
Expand Down Expand Up @@ -160,6 +171,17 @@ public static function provideData(): Iterator
],
"'" . PHP_BINARY . "' '" . self::DUMMY_MAIN_SCRIPT . "' '" . $cliInputOptionsAsString . "' worker --debug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi",
];

yield [
[
self::COMMAND => 'process',
Option::SOURCE => ['src'],
'--' . Option::OUTPUT_FORMAT => ConsoleOutputFormatter::NAME,
'--' . Option::DEBUG => true,
'--' . Option::XDEBUG => true,
],
"'" . PHP_BINARY . "' '" . self::DUMMY_MAIN_SCRIPT . "' '" . $cliInputOptionsAsString . "' worker --debug --xdebug --port 2000 --identifier 'identifier' 'src' --output-format 'json' --no-ansi",
];
}

private function prepareProcessCommandDefinition(): InputDefinition
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function doRun(InputInterface $input, OutputInterface $output): int
{
// @fixes https://github.com/rectorphp/rector/issues/2205
$isXdebugAllowed = $input->hasParameterOption('--xdebug');
if (! $isXdebugAllowed) {
if ($isXdebugAllowed) {
$xdebugHandler = new XdebugHandler('rector');
$xdebugHandler->check();
unset($xdebugHandler);
Expand Down
2 changes: 2 additions & 0 deletions src/Console/ProcessConfigureDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ public static function decorate(Command $command): void

$command->addOption(Option::PARALLEL_PORT, null, InputOption::VALUE_REQUIRED);
$command->addOption(Option::PARALLEL_IDENTIFIER, null, InputOption::VALUE_REQUIRED);

$command->addOption(Option::XDEBUG, null, InputOption::VALUE_NONE, 'Display xdebug output.');
}
}

0 comments on commit f54a79b

Please sign in to comment.