Skip to content

Commit 5d1b2c6

Browse files
authored
[Command] Fix to make additionalAutoloader->autoloadPaths() works on both parallel and non-parallel proccess (#6927)
1 parent 7feb6c8 commit 5d1b2c6

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/Console/Command/ProcessCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9696
}
9797

9898
$this->additionalAutoloader->autoloadInput($input);
99-
$this->additionalAutoloader->autoloadPaths();
10099

101100
$paths = $configuration->getPaths();
102101

@@ -144,6 +143,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
144143
return ExitCode::FAILURE;
145144
}
146145

146+
// autoload paths is register to DynamicSourceLocatorProvider,
147+
// so check after arePathsEmpty() above
148+
// check in no parallel since parallel will require register on its own process
149+
if (! $configuration->isParallel()) {
150+
$this->additionalAutoloader->autoloadPaths();
151+
}
152+
147153
// show debug info
148154
if ($configuration->isDebug()) {
149155
$this->reportLoadedComposerBasedSets();

src/Console/Command/WorkerCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use React\Socket\ConnectionInterface;
1111
use React\Socket\TcpConnector;
1212
use Rector\Application\ApplicationFileProcessor;
13+
use Rector\Autoloading\AdditionalAutoloader;
1314
use Rector\Configuration\ConfigurationFactory;
1415
use Rector\Configuration\ConfigurationRuleFilter;
1516
use Rector\Console\ProcessConfigureDecorator;
@@ -42,6 +43,7 @@ final class WorkerCommand extends Command
4243
private const RESULT = 'result';
4344

4445
public function __construct(
46+
private readonly AdditionalAutoloader $additionalAutoloader,
4547
private readonly DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator,
4648
private readonly ApplicationFileProcessor $applicationFileProcessor,
4749
private readonly MemoryLimiter $memoryLimiter,
@@ -100,6 +102,7 @@ private function runWorker(
100102
Configuration $configuration,
101103
OutputInterface $output
102104
): void {
105+
$this->additionalAutoloader->autoloadPaths();
103106
$this->dynamicSourceLocatorDecorator->addPaths($configuration->getPaths());
104107

105108
if ($configuration->isDebug()) {

0 commit comments

Comments
 (0)