Skip to content

Commit 90e4a49

Browse files
committed
refactor: Enable Rector Code Quality set
1 parent c542e41 commit 90e4a49

6 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎rector.php‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313

1414
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
1515
use Rector\CodeQuality\Rector\BooleanNot\NegatedAndsToPositiveOrsRector;
16-
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
1716
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
1817
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
1918
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
20-
use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector;
2119
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
2220
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
2321
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
@@ -49,13 +47,14 @@
4947
use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector;
5048
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
5149
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
50+
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\SafeDeclareStrictTypesRector;
5251
use Utils\Rector\PassStrictParameterToFunctionParameterRector;
5352
use Utils\Rector\RemoveErrorSuppressInTryCatchStmtsRector;
5453
use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;
5554

5655
return RectorConfig::configure()
5756
->withPhpSets(php82: true)
58-
->withPreparedSets(deadCode: true, instanceOf: true, phpunitCodeQuality: true)
57+
->withPreparedSets(deadCode: true, codeQuality: true, instanceOf: true, phpunitCodeQuality: true)
5958
->withComposerBased(phpunit: true)
6059
->withParallel(120, 8, 10)
6160
->withCache(
@@ -177,6 +176,7 @@
177176

178177
// to be applied in separate PRs to ease review
179178
NegatedAndsToPositiveOrsRector::class,
179+
SafeDeclareStrictTypesRector::class,
180180
])
181181
// auto import fully qualified class names
182182
->withImportNames()
@@ -193,8 +193,6 @@
193193
RemoveErrorSuppressInTryCatchStmtsRector::class,
194194
FuncGetArgsToVariadicParamRector::class,
195195
MakeInheritedMethodVisibilitySameAsParentRector::class,
196-
SimplifyEmptyCheckOnEmptyArrayRector::class,
197-
TernaryEmptyArrayArrayDimFetchToCoalesceRector::class,
198196
DisallowedEmptyRuleFixerRector::class,
199197
PrivatizeFinalClassPropertyRector::class,
200198
VersionCompareFuncCallToConstantRector::class,
@@ -208,5 +206,4 @@
208206
->withConfiguredRule(RenameConstantRector::class, [
209207
'FILTER_DEFAULT' => 'FILTER_UNSAFE_RAW',
210208
])
211-
->withCodeQualityLevel(61)
212209
->reportUnusedSkips();

‎system/CLI/CLI.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10)
819819
if ($thisStep !== false) {
820820
// Don't allow div by zero or negative numbers....
821821
$thisStep = abs($thisStep);
822-
$totalSteps = $totalSteps < 1 ? 1 : $totalSteps;
822+
$totalSteps = max(1, $totalSteps);
823823

824824
$percent = (int) (($thisStep / $totalSteps) * 100);
825825
$step = (int) round($percent / 10);

‎system/Cookie/Cookie.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function getMaxAge(): int
366366
{
367367
$maxAge = $this->expires - Time::now()->getTimestamp();
368368

369-
return $maxAge >= 0 ? $maxAge : 0;
369+
return max($maxAge, 0);
370370
}
371371

372372
/**

‎system/Pager/Pager.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ protected function calculateCurrentPage(string $group)
434434

435435
$page = (int) (service('superglobals')->get($pageSelector, '1'));
436436

437-
$this->groups[$group]['currentPage'] = $page < 1 ? 1 : $page;
437+
$this->groups[$group]['currentPage'] = max(1, $page);
438438
}
439439
}
440440
}

‎system/Publisher/Publisher.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ final public static function discover(string $directory = 'Publishers', string $
138138
/**
139139
* Removes a directory and all its files and subdirectories.
140140
*/
141-
private static function wipeDirectory(string $directory): void
141+
private function wipeDirectory(string $directory): void
142142
{
143143
if (is_dir($directory)) {
144144
// Try a few times in case of lingering locks
@@ -190,7 +190,7 @@ public function __construct(?string $source = null, ?string $destination = null)
190190
public function __destruct()
191191
{
192192
if (isset($this->scratch)) {
193-
self::wipeDirectory($this->scratch);
193+
$this->wipeDirectory($this->scratch);
194194

195195
$this->scratch = null;
196196
}
@@ -345,7 +345,7 @@ final public function addUri(string $uri)
345345
*/
346346
final public function wipe()
347347
{
348-
self::wipeDirectory($this->destination);
348+
$this->wipeDirectory($this->destination);
349349

350350
return $this;
351351
}

‎tests/system/Security/SecurityTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function setUp(): void
4848
Services::injectMock('superglobals', new Superglobals(post: [], cookie: []));
4949
}
5050

51-
private static function createMockSecurity(SecurityConfig $config = new SecurityConfig()): MockSecurity
51+
private function createMockSecurity(SecurityConfig $config = new SecurityConfig()): MockSecurity
5252
{
5353
return new MockSecurity($config);
5454
}

0 commit comments

Comments
 (0)