refactor: skip CompactToVariablesRector

This commit is contained in:
Abdul Malik Ikhsan 2024-12-07 17:42:53 +07:00
parent 21b8877620
commit 37e63299f5
No known key found for this signature in database
GPG Key ID: 69AC5BC354C89BE6
4 changed files with 10 additions and 7 deletions

View File

@ -17,6 +17,7 @@ use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
@ -171,6 +172,8 @@ return RectorConfig::configure()
// Unnecessary (string) is inserted
NullToStrictStringFuncCallArgRector::class,
CompactToVariablesRector::class,
])
// auto import fully qualified class names
->withImportNames(removeUnusedImports: true)

View File

@ -130,6 +130,6 @@ class ModelGenerator extends BaseCommand
$return = "'{$return}'";
}
return $this->parseTemplate($class, ['{dbGroup}', '{table}', '{return}'], [$dbGroup, $table, $return], ['dbGroup' => $dbGroup]);
return $this->parseTemplate($class, ['{dbGroup}', '{table}', '{return}'], [$dbGroup, $table, $return], compact('dbGroup'));
}
}

View File

@ -195,7 +195,7 @@ class LocalizationFinder extends BaseCommand
preg_match_all('/lang\(\'([._a-z0-9\-]+)\'\)/ui', $fileContent, $matches);
if ($matches[1] === []) {
return ['foundLanguageKeys' => $foundLanguageKeys, 'badLanguageKeys' => $badLanguageKeys];
return compact('foundLanguageKeys', 'badLanguageKeys');
}
foreach ($matches[1] as $phraseKey) {
@ -228,7 +228,7 @@ class LocalizationFinder extends BaseCommand
}
}
return ['foundLanguageKeys' => $foundLanguageKeys, 'badLanguageKeys' => $badLanguageKeys];
return compact('foundLanguageKeys', 'badLanguageKeys');
}
private function isIgnoredFile(SplFileInfo $file): bool
@ -384,6 +384,6 @@ class LocalizationFinder extends BaseCommand
$badLanguageKeys = array_merge($findInFile['badLanguageKeys'], $badLanguageKeys);
}
return ['foundLanguageKeys' => $foundLanguageKeys, 'badLanguageKeys' => $badLanguageKeys, 'countFiles' => $countFiles];
return compact('foundLanguageKeys', 'badLanguageKeys', 'countFiles');
}
}

View File

@ -272,7 +272,7 @@ class Fabricator
*/
public function setUnique(string $field, bool $reset = false, int $maxRetries = 10000): static
{
$this->modifiedFields['unique'][$field] = ['reset' => $reset, 'maxRetries' => $maxRetries];
$this->modifiedFields['unique'][$field] = compact('reset', 'maxRetries');
return $this;
}
@ -284,7 +284,7 @@ class Fabricator
*/
public function setOptional(string $field, float $weight = 0.5, mixed $default = null): static
{
$this->modifiedFields['optional'][$field] = ['weight' => $weight, 'default' => $default];
$this->modifiedFields['optional'][$field] = compact('weight', 'default');
return $this;
}
@ -298,7 +298,7 @@ class Fabricator
*/
public function setValid(string $field, ?Closure $validator = null, int $maxRetries = 10000): static
{
$this->modifiedFields['valid'][$field] = ['validator' => $validator, 'maxRetries' => $maxRetries];
$this->modifiedFields['valid'][$field] = compact('validator', 'maxRetries');
return $this;
}