Skip to content

Commit

Permalink
refactor: skip CompactToVariablesRector
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 7, 2024
1 parent 21b8877 commit 37e6329
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -171,6 +172,8 @@

// Unnecessary (string) is inserted
NullToStrictStringFuncCallArgRector::class,

CompactToVariablesRector::class,
])
// auto import fully qualified class names
->withImportNames(removeUnusedImports: true)
Expand Down
2 changes: 1 addition & 1 deletion system/Commands/Generators/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ protected function prepare(string $class): string
$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'));
}
}
6 changes: 3 additions & 3 deletions system/Commands/Translation/LocalizationFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private function findTranslationsInFile($file): array
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) {
Expand Down Expand Up @@ -228,7 +228,7 @@ private function findTranslationsInFile($file): array
}
}

return ['foundLanguageKeys' => $foundLanguageKeys, 'badLanguageKeys' => $badLanguageKeys];
return compact('foundLanguageKeys', 'badLanguageKeys');
}

private function isIgnoredFile(SplFileInfo $file): bool
Expand Down Expand Up @@ -384,6 +384,6 @@ private function findLanguageKeysInFiles(array $files): array
$badLanguageKeys = array_merge($findInFile['badLanguageKeys'], $badLanguageKeys);
}

return ['foundLanguageKeys' => $foundLanguageKeys, 'badLanguageKeys' => $badLanguageKeys, 'countFiles' => $countFiles];
return compact('foundLanguageKeys', 'badLanguageKeys', 'countFiles');
}
}
6 changes: 3 additions & 3 deletions system/Test/Fabricator.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function setOverrides(array $overrides = [], $persist = true): self
*/
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;
}
Expand All @@ -284,7 +284,7 @@ public function setUnique(string $field, bool $reset = false, int $maxRetries =
*/
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;
}
Expand All @@ -298,7 +298,7 @@ public function setOptional(string $field, float $weight = 0.5, mixed $default =
*/
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;
}
Expand Down

0 comments on commit 37e6329

Please sign in to comment.