Skip to content

Commit c475fc7

Browse files
authored
[parallel] bump default threads from 16 to 32 to keep up with modern technology (#6877)
* [config] remove def value * typo * skip if no paths found * [parallel] bump default threads from 16 to 32 to keep up with modern technology, alligned with phpstan setup * typo * [solid] make AbstractRector::leave() final, to avoid breaking removing mechanism in child classes
1 parent 394eb49 commit c475fc7

File tree

11 files changed

+33
-14
lines changed

11 files changed

+33
-14
lines changed

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
__DIR__ . '/build/build-preload.php',
3636
])
3737
->withRootFiles()
38-
->withImportNames(removeUnusedImports: true)
38+
->withImportNames()
3939
->withSkip([
4040
StringClassNameToClassConstantRector::class,
4141
// tests

rules/TypeDeclaration/Rector/StmtsAwareInterface/DeclareStrictTypesRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function beforeTraverse(array $nodes): ?array
6666
return null;
6767
}
6868

69-
if ($this->startWithShebang($this->file)) {
69+
if ($this->startsWithShebang($this->file)) {
7070
return null;
7171
}
7272

@@ -126,7 +126,7 @@ public function refactor(Node $node): ?Node
126126
return null;
127127
}
128128

129-
private function startWithShebang(File $file): bool
129+
private function startsWithShebang(File $file): bool
130130
{
131131
return str_starts_with($file->getFileContent(), '#!');
132132
}

src/Application/ApplicationFileProcessor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ public function __construct(
5858
public function run(Configuration $configuration, InputInterface $input): ProcessResult
5959
{
6060
$filePaths = $this->filesFinder->findFilesInPaths($configuration->getPaths(), $configuration);
61-
$this->missConfigurationReporter->reportVendorInPaths($filePaths);
62-
$this->missConfigurationReporter->reportStartWithShortOpenTag();
6361

6462
// no files found
6563
if ($filePaths === []) {
6664
return new ProcessResult([], []);
6765
}
6866

67+
$this->missConfigurationReporter->reportVendorInPaths($filePaths);
68+
$this->missConfigurationReporter->reportStartWithShortOpenTag();
69+
6970
$this->configureCustomErrorHandler();
7071

7172
/**

src/Config/RectorConfig.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Rector\Contract\Rector\ConfigurableRectorInterface;
1515
use Rector\Contract\Rector\RectorInterface;
1616
use Rector\DependencyInjection\Laravel\ContainerMemento;
17+
use Rector\Enum\Config\Defaults;
1718
use Rector\Exception\ShouldNotHappenException;
1819
use Rector\Skipper\SkipCriteriaResolver\SkippedClassResolver;
1920
use Rector\Validation\RectorConfigValidator;
@@ -93,8 +94,11 @@ public function disableParallel(): void
9394
SimpleParameterProvider::setParameter(Option::PARALLEL, false);
9495
}
9596

96-
public function parallel(int $processTimeout = 120, int $maxNumberOfProcess = 16, int $jobSize = 16): void
97-
{
97+
public function parallel(
98+
int $processTimeout = 120,
99+
int $maxNumberOfProcess = Defaults::PARALLEL_MAX_NUMBER_OF_PROCESS,
100+
int $jobSize = 16
101+
): void {
98102
SimpleParameterProvider::setParameter(Option::PARALLEL, true);
99103
SimpleParameterProvider::setParameter(Option::PARALLEL_JOB_TIMEOUT_IN_SECONDS, $processTimeout);
100104
SimpleParameterProvider::setParameter(Option::PARALLEL_MAX_NUMBER_OF_PROCESSES, $maxNumberOfProcess);

src/Configuration/RectorConfigBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Rector\Contract\Rector\ConfigurableRectorInterface;
2121
use Rector\Contract\Rector\RectorInterface;
2222
use Rector\Doctrine\Set\DoctrineSetList;
23+
use Rector\Enum\Config\Defaults;
2324
use Rector\Exception\Configuration\InvalidConfigurationException;
2425
use Rector\Php\PhpVersionResolver\ComposerJsonPhpVersionResolver;
2526
use Rector\PHPUnit\Set\PHPUnitSetList;
@@ -90,7 +91,7 @@ final class RectorConfigBuilder
9091

9192
private int $parallelTimeoutSeconds = 120;
9293

93-
private int $parallelMaxNumberOfProcess = 16;
94+
private int $parallelMaxNumberOfProcess = Defaults::PARALLEL_MAX_NUMBER_OF_PROCESS;
9495

9596
private int $parallelJobSize = 16;
9697

src/Console/Command/ProcessCommand.php

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

118118
// 2. add files and directories to static locator
119119
$this->dynamicSourceLocatorDecorator->addPaths($paths);
120-
if ($this->dynamicSourceLocatorDecorator->isPathsEmpty()) {
120+
if ($this->dynamicSourceLocatorDecorator->arePathsEmpty()) {
121121
// read from rector.php, no paths definition needs withPaths() config
122122
if ($paths === []) {
123123
$this->symfonyStyle->error(

src/Enum/Config/Defaults.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Enum\Config;
6+
7+
final class Defaults
8+
{
9+
/**
10+
* @var int
11+
*/
12+
public const PARALLEL_MAX_NUMBER_OF_PROCESS = 32;
13+
}

src/FamilyTree/NodeAnalyzer/ClassChildAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function resolveToStringNativeTypeFromAstResolver(PhpMethodReflection $p
8282

8383
if ($class instanceof ClassLike) {
8484
$classMethod = $class->getMethod($phpMethodReflection->getName());
85-
if ($classMethod instanceof ClassMethod && !$classMethod->returnType instanceof Node) {
85+
if ($classMethod instanceof ClassMethod && ! $classMethod->returnType instanceof Node) {
8686
return new MixedType();
8787
}
8888
}

src/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function provide(): SourceLocator
7878
return $this->aggregateSourceLocator = new AggregateSourceLocator($sourceLocators);
7979
}
8080

81-
public function isPathsEmpty(): bool
81+
public function arePathsEmpty(): bool
8282
{
8383
return $this->filePaths === [] && $this->directories === [];
8484
}

src/Rector/AbstractRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ final public function enterNode(Node $node): int|Node|null
190190
* Replacing nodes in leaveNode() method avoids infinite recursion
191191
* see"infinite recursion" in https://github.com/nikic/PHP-Parser/blob/master/doc/component/Walking_the_AST.markdown
192192
*/
193-
public function leaveNode(Node $node): array|int|Node|null
193+
final public function leaveNode(Node $node): array|int|Node|null
194194
{
195195
if ($node->hasAttribute(AttributeKey::ORIGINAL_NODE)) {
196196
return null;

0 commit comments

Comments
 (0)