Skip to content

Commit 9ec5138

Browse files
authored
chore: Bump Rector to 2.6.3, clean up deprecated rules, and re-run it (#10474)
* Bump Rector to 2.6.3, clean up deprecated rules, and re-run it * fix return type
1 parent 6df2fe3 commit 9ec5138

13 files changed

Lines changed: 17 additions & 25 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"phpunit/phpcov": "^9.0.2 || ^10.0",
3030
"phpunit/phpunit": "^10.5.16 || ^11.2",
3131
"predis/predis": "^3.0",
32-
"rector/rector": "2.6.1",
32+
"rector/rector": "2.6.3",
3333
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3434
},
3535
"replace": {

rector.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
2626
use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector;
2727
use Rector\DeadCode\Rector\Property\RemoveDefaultValueFromAssignedPropertyRector;
28-
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
29-
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
30-
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
31-
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
3228
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
3329
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
3430
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
@@ -37,7 +33,6 @@
3733
use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector;
3834
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
3935
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
40-
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
4136
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
4237
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
4338
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
@@ -179,15 +174,10 @@
179174
DeclareStrictTypesRector::class,
180175
UnderscoreToCamelCaseVariableNameRector::class,
181176
SimplifyUselessVariableRector::class,
182-
RemoveAlwaysElseRector::class,
183177
PassStrictParameterToFunctionParameterRector::class,
184-
ChangeNestedForeachIfsToEarlyContinueRector::class,
185-
ChangeIfElseValueAssignToEarlyReturnRector::class,
186-
PreparedValueToEarlyReturnRector::class,
187178
RemoveErrorSuppressInTryCatchStmtsRector::class,
188179
FuncGetArgsToVariadicParamRector::class,
189180
MakeInheritedMethodVisibilitySameAsParentRector::class,
190-
DisallowedEmptyRuleFixerRector::class,
191181
PrivatizeFinalClassPropertyRector::class,
192182
VersionCompareFuncCallToConstantRector::class,
193183
AddClosureVoidReturnTypeWhereNoReturnRector::class,

system/CLI/InputOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function input(?string $prefix = null): string
5151
$input = fgets(fopen('php://stdin', 'rb'));
5252

5353
if ($input === false) {
54-
$input = '';
54+
return '';
5555
}
5656

5757
return $input;

system/Config/DotEnv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ protected function sanitizeValue(string $value): string
204204
protected function resolveNestedVariables(string $value): string
205205
{
206206
if (str_contains($value, '$')) {
207-
$value = preg_replace_callback(
207+
return preg_replace_callback(
208208
'/\${([a-zA-Z0-9_\.]+)}/',
209209
function ($matchedPatterns) {
210210
$nestedVariable = $this->getVariable($matchedPatterns[1]);

system/Database/Postgre/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function compileIgnore(string $statement)
5757
$sql = parent::compileIgnore($statement);
5858

5959
if ($sql !== '') {
60-
$sql = ' ' . trim($sql);
60+
return ' ' . trim($sql);
6161
}
6262

6363
return $sql;

system/Files/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private function getSizeByUnitInternal(int $fileSizeBase, FileSizeUnit $unit, in
218218
$size = $this->getSize() / $divider;
219219

220220
if ($unit !== FileSizeUnit::B) {
221-
$size = number_format($size, $precision);
221+
return number_format($size, $precision);
222222
}
223223

224224
return $size;

system/HTTP/ResponseTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function getXML()
224224
$body = $this->body;
225225

226226
if ($this->bodyFormat !== 'xml') {
227-
$body = service('format')->getFormatter('application/xml')->format($body);
227+
return service('format')->getFormatter('application/xml')->format($body);
228228
}
229229

230230
return $body;
@@ -249,7 +249,7 @@ protected function formatBody($body, string $format)
249249

250250
// Nothing much to do for a string...
251251
if (! is_string($body) || $format === 'json-unencoded') {
252-
$body = service('format')->getFormatter($mime)->format($body);
252+
return service('format')->getFormatter($mime)->format($body);
253253
}
254254

255255
return $body;

system/HTTP/SiteURI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function getIndexPageRoutePath(string $routePath): string
188188
$indexPageRoutePath = $indexPage . $routePath;
189189

190190
if ($indexPageRoutePath === '/') {
191-
$indexPageRoutePath = '';
191+
return '';
192192
}
193193

194194
return $indexPageRoutePath;
@@ -420,7 +420,7 @@ public function baseUrl($relativePath = '', ?string $scheme = null): string
420420
private function stringifyRelativePath($relativePath): string
421421
{
422422
if (is_array($relativePath)) {
423-
$relativePath = implode('/', $relativePath);
423+
return implode('/', $relativePath);
424424
}
425425

426426
return $relativePath;

system/Helpers/url_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ function prep_url(string $str = '', bool $secure = false): string
423423

424424
// force replace http:// with https://
425425
if ($secure) {
426-
$str = preg_replace('/^(?:http):/i', 'https:', $str);
426+
return preg_replace('/^(?:http):/i', 'https:', $str);
427427
}
428428

429429
return $str;

system/Honeypot/Honeypot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function prepareTemplate(string $template): string
111111
$template = str_ireplace('{name}', $this->config->name, $template);
112112

113113
if ($this->config->hidden) {
114-
$template = str_ireplace('{template}', $template, $this->config->container);
114+
return str_ireplace('{template}', $template, $this->config->container);
115115
}
116116

117117
return $template;

0 commit comments

Comments
 (0)