Skip to content

Commit 15f5754

Browse files
committed
Build parallel worker command line from Configuration
1 parent cbe736a commit 15f5754

7 files changed

Lines changed: 176 additions & 358 deletions

File tree

‎phpstan.neon‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ parameters:
9999
- src/StaticTypeMapper/Naming/NameScopeFactory.php
100100
- utils/phpstan/src/Rule/NoResolveClassReflectionInForeachRule.php
101101

102+
# services are instantiated by the container via reflection, which shipmonk cannot see
103+
-
104+
identifier: shipmonk.deadMethod
105+
message: '#::__construct$#'
106+
102107
# called magically by parent
103108
-
104109
message: '#^Unused Rector\\PhpParser\\Printer\\BetterStandardPrinter\:\:(pInterpolatedStringPart|pStmt_FileNode)$#'

‎src/Application/ApplicationFileProcessor.php‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use Rector\ValueObject\FileProcessResult;
2828
use Rector\ValueObject\ProcessResult;
2929
use Rector\ValueObject\Reporting\FileDiff;
30-
use Symfony\Component\Console\Input\InputInterface;
3130
use Throwable;
3231

3332
final class ApplicationFileProcessor
@@ -54,7 +53,7 @@ public function __construct(
5453
) {
5554
}
5655

57-
public function run(Configuration $configuration, InputInterface $input): ProcessResult
56+
public function run(Configuration $configuration): ProcessResult
5857
{
5958
// scope the cache to this run's --only / --only-suffix selection before any cache read/write
6059
$this->changedFilesDetector->setActiveScope($configuration->getOnlyRules(), $configuration->getOnlySuffix(), $configuration->getFilters());
@@ -97,7 +96,7 @@ public function run(Configuration $configuration, InputInterface $input): Proces
9796
}
9897

9998
if ($configuration->isParallel()) {
100-
$processResult = $this->runParallel($filePaths, $input, $postFileCallback);
99+
$processResult = $this->runParallel($filePaths, $configuration, $postFileCallback);
101100
} else {
102101
$processResult = $this->processFiles($filePaths, $configuration, $preFileCallback, $postFileCallback);
103102
}
@@ -260,7 +259,7 @@ private function restoreErrorHandler(): void
260259
*/
261260
private function runParallel(
262261
array $filePaths,
263-
InputInterface $input,
262+
Configuration $configuration,
264263
callable $postFileCallback,
265264
): ProcessResult {
266265
$mainScript = $this->resolveCalledRectorBinary();
@@ -277,7 +276,7 @@ private function runParallel(
277276
$schedule = $this->scheduleFactory->create($cpuCores, $jobSize, $maxNumberOfProcesses, $filePaths);
278277

279278
// mimics see https://github.com/phpstan/phpstan-src/commit/9124c66dcc55a222e21b1717ba5f60771f7dda92#diff-387b8f04e0db7a06678eb52ce0c0d0aff73e0d7d8fc5df834d0a5fbec198e5daR139
280-
return $this->parallelFileProcessor->process($schedule, $mainScript, $postFileCallback, $input);
279+
return $this->parallelFileProcessor->process($schedule, $mainScript, $postFileCallback, $configuration);
281280
}
282281

283282
/**

‎src/Console/Command/ProcessCommand.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
172172

173173
// MAIN PHASE
174174
// 2. run Rector
175-
$processResult = $this->applicationFileProcessor->run($configuration, $input);
175+
$processResult = $this->applicationFileProcessor->run($configuration);
176176

177177
// REPORTING PHASE
178178
// 3. reporting phaseRunning 2nd time with collectors data

‎src/Parallel/Application/ParallelFileProcessor.php‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use React\Socket\TcpServer;
1313
use Rector\Configuration\Option;
1414
use Rector\Configuration\Parameter\SimpleParameterProvider;
15-
use Rector\Console\Command\ProcessCommand;
1615
use Rector\Console\ExitCode;
1716
use Rector\Parallel\Command\WorkerCommandLineFactory;
1817
use Rector\Parallel\Enum\Action;
@@ -24,9 +23,9 @@
2423
use Rector\Parallel\ValueObject\ParallelProcess;
2524
use Rector\Parallel\ValueObject\ProcessPool;
2625
use Rector\Parallel\ValueObject\Schedule;
26+
use Rector\ValueObject\Configuration;
2727
use Rector\ValueObject\Error\SystemError;
2828
use Rector\ValueObject\ProcessResult;
29-
use Symfony\Component\Console\Input\InputInterface;
3029
use Throwable;
3130

3231
/**
@@ -58,7 +57,7 @@ public function process(
5857
Schedule $schedule,
5958
string $mainScript,
6059
callable $postFileCallback,
61-
InputInterface $input
60+
Configuration $configuration
6261
): ProcessResult {
6362
// reversed, so that array_pop() hands out the jobs in bucket order
6463
$jobsPerWorker = array_map(
@@ -157,7 +156,7 @@ public function process(
157156
&$systemErrorsCount,
158157
&$reachedSystemErrorsCountLimit,
159158
$mainScript,
160-
$input,
159+
$configuration,
161160
$serverPort,
162161
$streamSelectLoop,
163162
$timeoutInSeconds,
@@ -172,9 +171,8 @@ public function process(
172171

173172
$workerCommandLine = $this->workerCommandLineFactory->create(
174173
$mainScript,
175-
ProcessCommand::class,
176174
'worker',
177-
$input,
175+
$configuration,
178176
$processIdentifier,
179177
$serverPort,
180178
);

0 commit comments

Comments
 (0)