[Parallel] Process smaller chunk of files at once (#1587)

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Tomas Votruba 2021-12-28 14:53:11 +01:00 committed by GitHub
parent fa7249028c
commit 29838d0c0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 90 additions and 34 deletions

View File

@ -33,7 +33,7 @@ jobs:
- config utils scoper.php
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 10
steps:
# workaround for missing secret in fork PRs - see https://github.com/actions/checkout/issues/298

View File

@ -54,6 +54,11 @@ final class GenerateChangelogCommand extends Command
*/
private const HASH = 'hash';
/**
* @var string
*/
private const MESSAGE = 'message';
protected function configure(): void
{
$this->setName(CommandNaming::classToName(self::class));
@ -131,9 +136,9 @@ final class GenerateChangelogCommand extends Command
}
// clean commit from duplicating issue number
$commitMatch = Strings::match($commit['message'], '#(.*?)( \(\#\d+\))?$#ms');
$commitMatch = Strings::match($commit[self::MESSAGE], '#(.*?)( \(\#\d+\))?$#ms');
$commit = $commitMatch[1] ?? $commit['message'];
$commit = $commitMatch[1] ?? $commit[self::MESSAGE];
$changelogLine = sprintf(
'* %s (%s)%s%s',
@ -156,7 +161,7 @@ final class GenerateChangelogCommand extends Command
return self::SUCCESS;
}
protected function createThanks(string|null $thanks): string
private function createThanks(string|null $thanks): string
{
if ($thanks === null) {
return '';

View File

@ -19,8 +19,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
// parallel
$parameters->set(Option::PARALLEL, false);
$parameters->set(Option::PARALLEL_MAX_NUMBER_OF_PROCESSES, 20);
$parameters->set(Option::PARALLEL_JOB_SIZE, 60);
$parameters->set(Option::PARALLEL_MAX_NUMBER_OF_PROCESSES, 16);
$parameters->set(Option::PARALLEL_JOB_SIZE, 20);
// FQN class importing
$parameters->set(Option::AUTO_IMPORT_NAMES, false);

View File

@ -24,8 +24,6 @@ use Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__ . '/mysql-to-mysqli.php');
$services = $containerConfigurator->services();
$services->set(Php4ConstructorRector::class);

View File

@ -78,8 +78,10 @@ CODE_SAMPLE
/**
* @param MethodCall|StaticCall|ClassMethod $node
*/
public function refactor(Node $node): MethodCall | StaticCall | ClassMethod
public function refactor(Node $node): MethodCall | StaticCall | ClassMethod | null
{
$hasChanged = false;
foreach ($this->replacedArguments as $replacedArgument) {
if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType(
$node,
@ -92,10 +94,17 @@ CODE_SAMPLE
continue;
}
$this->argumentDefaultValueReplacer->processReplaces($node, $replacedArgument);
$replacedNode = $this->argumentDefaultValueReplacer->processReplaces($node, $replacedArgument);
if ($replacedNode instanceof Node) {
$hasChanged = true;
}
}
return $node;
if ($hasChanged) {
return $node;
}
return null;
}
/**

View File

@ -67,17 +67,25 @@ CODE_SAMPLE
/**
* @param FuncCall $node
*/
public function refactor(Node $node): FuncCall
public function refactor(Node $node): FuncCall|null
{
$hasChanged = false;
foreach ($this->replacedArguments as $replacedArgument) {
if (! $this->isName($node->name, $replacedArgument->getFunction())) {
continue;
}
$this->argumentDefaultValueReplacer->processReplaces($node, $replacedArgument);
$changedNode = $this->argumentDefaultValueReplacer->processReplaces($node, $replacedArgument);
if ($changedNode instanceof Node) {
$hasChanged = true;
}
}
return $node;
if ($hasChanged) {
return $node;
}
return null;
}
/**

View File

@ -82,16 +82,30 @@ CODE_SAMPLE
return null;
}
$hasChanged = false;
foreach ($patterns as $pattern) {
foreach (self::COMPLEX_PATTERN_TO_SIMPLE as $complexPattern => $simple) {
$pattern->value = Strings::replace(
$originalValue = $pattern->value;
$simplifiedValue = Strings::replace(
$pattern->value,
'#' . preg_quote($complexPattern, '#') . '#',
$simple
);
if ($originalValue === $simplifiedValue) {
continue;
}
$pattern->value = $simplifiedValue;
$hasChanged = true;
}
}
return $node;
if ($hasChanged) {
return $node;
}
return null;
}
}

View File

@ -69,6 +69,8 @@ CODE_SAMPLE
if ($this->isName($node, 'mysql_list_dbs')) {
$node->name = new Name(self::MYSQLI_QUERY);
$node->args[0] = new Arg(new String_('SHOW DATABASES'));
return $node;
}
if ($this->isName(
@ -79,14 +81,18 @@ CODE_SAMPLE
$node->args[0]->value = $this->joinStringWithNode('SHOW COLUMNS FROM', $node->args[1]->value);
unset($node->args[1]);
return $node;
}
if ($this->isName($node, 'mysql_list_tables') && $node->args[0] instanceof Arg) {
$node->name = new Name(self::MYSQLI_QUERY);
$node->args[0]->value = $this->joinStringWithNode('SHOW TABLES FROM', $node->args[0]->value);
return $node;
}
return $node;
return null;
}
private function processMysqlCreateDb(FuncCall $funcCall): ?FuncCall

View File

@ -61,18 +61,27 @@ CODE_SAMPLE
/**
* @param FuncCall $node
*/
public function refactor(Node $node): FuncCall
public function refactor(Node $node): FuncCall|null
{
$hasChanged = false;
foreach ($node->args as $nodeArg) {
if (! $nodeArg instanceof Arg) {
continue;
}
if ($nodeArg->byRef) {
$nodeArg->byRef = false;
if (! $nodeArg->byRef) {
continue;
}
$nodeArg->byRef = false;
$hasChanged = true;
}
return $node;
if ($hasChanged) {
return $node;
}
return null;
}
}

View File

@ -49,7 +49,7 @@ final class RandomFunctionRector extends AbstractRector implements MinPhpVersion
/**
* @param FuncCall $node
*/
public function refactor(Node $node): FuncCall
public function refactor(Node $node): FuncCall|null
{
foreach (self::OLD_TO_NEW_FUNCTION_NAMES as $oldFunctionName => $newFunctionName) {
if ($this->isName($node, $oldFunctionName)) {
@ -65,7 +65,7 @@ final class RandomFunctionRector extends AbstractRector implements MinPhpVersion
}
}
return $node;
return null;
}
public function provideMinPhpVersion(): int

View File

@ -87,15 +87,22 @@ CODE_SAMPLE
return null;
}
$hasChanged = false;
foreach ($regexArguments as $regexArgument) {
if (StringUtils::isMatch($regexArgument->value, self::THREE_BACKSLASH_FOR_ESCAPE_NEXT_REGEX)) {
continue;
}
$this->escapeStringNode($regexArgument);
$hasChanged = true;
}
return $node;
if ($hasChanged) {
return $node;
}
return null;
}
private function escapeStringNode(String_ $string): void

View File

@ -99,6 +99,10 @@ CODE_SAMPLE
public function refactor(Node $node): ?Node
{
$scope = $node->getAttribute(AttributeKey::SCOPE);
if (! $scope instanceof Scope) {
return null;
}
if ($this->shouldSkipProperty($node, $scope)) {
return null;
}

View File

@ -62,17 +62,13 @@ final class RegexPatternArgumentManipulator
/**
* @return String_[]
*/
public function matchCallArgumentWithRegexPattern(Expr $expr): array
public function matchCallArgumentWithRegexPattern(FuncCall|StaticCall $call): array
{
if ($expr instanceof FuncCall) {
return $this->processFuncCall($expr);
if ($call instanceof FuncCall) {
return $this->processFuncCall($call);
}
if ($expr instanceof StaticCall) {
return $this->processStaticCall($expr);
}
return [];
return $this->processStaticCall($call);
}
/**

View File

@ -356,7 +356,7 @@ final class AstResolver
return null;
}
$reflectionFunction = $this->reflectionProvider->getFunction($funcCall->name, $scope);
return $this->resolveFunctionFromFunctionReflection($reflectionFunction);
$functionReflection = $this->reflectionProvider->getFunction($funcCall->name, $scope);
return $this->resolveFunctionFromFunctionReflection($functionReflection);
}
}