Skip to content

Commit bfa7a49

Browse files
authored
refactor: Enable Rector Code Quality set (#10429)
1 parent c542e41 commit bfa7a49

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

rector.php

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

1414
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
1515
use Rector\CodeQuality\Rector\BooleanNot\NegatedAndsToPositiveOrsRector;
16-
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
16+
use Rector\CodeQuality\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector;
1717
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
1818
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
1919
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
20-
use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector;
2120
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
2221
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
2322
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
@@ -49,13 +48,14 @@
4948
use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector;
5049
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
5150
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
51+
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\SafeDeclareStrictTypesRector;
5252
use Utils\Rector\PassStrictParameterToFunctionParameterRector;
5353
use Utils\Rector\RemoveErrorSuppressInTryCatchStmtsRector;
5454
use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;
5555

5656
return RectorConfig::configure()
5757
->withPhpSets(php82: true)
58-
->withPreparedSets(deadCode: true, instanceOf: true, phpunitCodeQuality: true)
58+
->withPreparedSets(deadCode: true, codeQuality: true, instanceOf: true, phpunitCodeQuality: true)
5959
->withComposerBased(phpunit: true)
6060
->withParallel(120, 8, 10)
6161
->withCache(
@@ -177,6 +177,8 @@
177177

178178
// to be applied in separate PRs to ease review
179179
NegatedAndsToPositiveOrsRector::class,
180+
SafeDeclareStrictTypesRector::class,
181+
LocallyCalledStaticMethodToNonStaticRector::class,
180182
])
181183
// auto import fully qualified class names
182184
->withImportNames()
@@ -193,8 +195,6 @@
193195
RemoveErrorSuppressInTryCatchStmtsRector::class,
194196
FuncGetArgsToVariadicParamRector::class,
195197
MakeInheritedMethodVisibilitySameAsParentRector::class,
196-
SimplifyEmptyCheckOnEmptyArrayRector::class,
197-
TernaryEmptyArrayArrayDimFetchToCoalesceRector::class,
198198
DisallowedEmptyRuleFixerRector::class,
199199
PrivatizeFinalClassPropertyRector::class,
200200
VersionCompareFuncCallToConstantRector::class,
@@ -208,5 +208,4 @@
208208
->withConfiguredRule(RenameConstantRector::class, [
209209
'FILTER_DEFAULT' => 'FILTER_UNSAFE_RAW',
210210
])
211-
->withCodeQualityLevel(61)
212211
->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
}

0 commit comments

Comments
 (0)