From 21b88776202eeb57140411c17f7c1627cdc636af Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 5 Dec 2024 23:58:11 +0700 Subject: [PATCH] refactor: Apply code quality level 27 for rector --- rector.php | 2 +- system/Commands/Generators/ModelGenerator.php | 2 +- system/Commands/Translation/LocalizationFinder.php | 6 +++--- system/Test/Fabricator.php | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rector.php b/rector.php index 64abc9a73541..5058e5f2ab70 100644 --- a/rector.php +++ b/rector.php @@ -210,4 +210,4 @@ // keep '\\' prefix string on string '\Foo\Bar' StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true, ]) - ->withCodeQualityLevel(24); + ->withCodeQualityLevel(27); diff --git a/system/Commands/Generators/ModelGenerator.php b/system/Commands/Generators/ModelGenerator.php index 5450bda79b4c..f611b52f028a 100644 --- a/system/Commands/Generators/ModelGenerator.php +++ b/system/Commands/Generators/ModelGenerator.php @@ -130,6 +130,6 @@ protected function prepare(string $class): string $return = "'{$return}'"; } - return $this->parseTemplate($class, ['{dbGroup}', '{table}', '{return}'], [$dbGroup, $table, $return], compact('dbGroup')); + return $this->parseTemplate($class, ['{dbGroup}', '{table}', '{return}'], [$dbGroup, $table, $return], ['dbGroup' => $dbGroup]); } } diff --git a/system/Commands/Translation/LocalizationFinder.php b/system/Commands/Translation/LocalizationFinder.php index e7d4eff69663..7010fb8c74c2 100644 --- a/system/Commands/Translation/LocalizationFinder.php +++ b/system/Commands/Translation/LocalizationFinder.php @@ -195,7 +195,7 @@ private function findTranslationsInFile($file): array preg_match_all('/lang\(\'([._a-z0-9\-]+)\'\)/ui', $fileContent, $matches); if ($matches[1] === []) { - return compact('foundLanguageKeys', 'badLanguageKeys'); + return ['foundLanguageKeys' => $foundLanguageKeys, 'badLanguageKeys' => $badLanguageKeys]; } foreach ($matches[1] as $phraseKey) { @@ -228,7 +228,7 @@ private function findTranslationsInFile($file): array } } - return compact('foundLanguageKeys', 'badLanguageKeys'); + return ['foundLanguageKeys' => $foundLanguageKeys, 'badLanguageKeys' => $badLanguageKeys]; } private function isIgnoredFile(SplFileInfo $file): bool @@ -384,6 +384,6 @@ private function findLanguageKeysInFiles(array $files): array $badLanguageKeys = array_merge($findInFile['badLanguageKeys'], $badLanguageKeys); } - return compact('foundLanguageKeys', 'badLanguageKeys', 'countFiles'); + return ['foundLanguageKeys' => $foundLanguageKeys, 'badLanguageKeys' => $badLanguageKeys, 'countFiles' => $countFiles]; } } diff --git a/system/Test/Fabricator.php b/system/Test/Fabricator.php index 8da0c60fc089..c34213c5cf6b 100644 --- a/system/Test/Fabricator.php +++ b/system/Test/Fabricator.php @@ -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] = compact('reset', 'maxRetries'); + $this->modifiedFields['unique'][$field] = ['reset' => $reset, 'maxRetries' => $maxRetries]; return $this; } @@ -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] = compact('weight', 'default'); + $this->modifiedFields['optional'][$field] = ['weight' => $weight, 'default' => $default]; return $this; } @@ -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] = compact('validator', 'maxRetries'); + $this->modifiedFields['valid'][$field] = ['validator' => $validator, 'maxRetries' => $maxRetries]; return $this; }