Skip to content

Commit 8f6a983

Browse files
authored
Merge pull request #9776 from samsonasik/refactor-enable-fn-to-first
refactor: enable FunctionLikeToFirstClassCallableRector to convert arrow function to first class callable
2 parents b6ed83f + 6e12861 commit 8f6a983

File tree

7 files changed

+7
-11
lines changed

7 files changed

+7
-11
lines changed

rector.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
2222
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
2323
use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
24-
use Rector\CodingStyle\Rector\FunctionLike\FunctionLikeToFirstClassCallableRector;
2524
use Rector\Config\RectorConfig;
2625
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
2726
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
@@ -173,9 +172,6 @@
173172
// possibly isset() on purpose, on updated Config classes property accross versions
174173
IssetOnPropertyObjectToPropertyExistsRector::class,
175174

176-
// needs separate PR for activation to allow more depth review
177-
FunctionLikeToFirstClassCallableRector::class,
178-
179175
AssertFuncCallToPHPUnitAssertRector::class => [
180176
// use $this inside static closure
181177
__DIR__ . '/tests/system/AutoReview/FrameworkCodeTest.php',

system/Database/BaseBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@ public function onConstraint($set)
21132113
if (is_string($set)) {
21142114
$set = explode(',', $set);
21152115

2116-
$set = array_map(static fn ($key): string => trim($key), $set);
2116+
$set = array_map(trim(...), $set);
21172117
}
21182118

21192119
if ($set instanceof RawSql) {
@@ -2157,7 +2157,7 @@ public function setQueryAsData($query, ?string $alias = null, $columns = null):
21572157
if (is_string($query)) {
21582158
if ($columns !== null && is_string($columns)) {
21592159
$columns = explode(',', $columns);
2160-
$columns = array_map(static fn ($key): string => trim($key), $columns);
2160+
$columns = array_map(trim(...), $columns);
21612161
}
21622162

21632163
$columns = (array) $columns;

system/Database/Postgre/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ protected function _indexData(string $table): array
382382
$obj = new stdClass();
383383
$obj->name = $row->indexname;
384384
$_fields = explode(',', preg_replace('/^.*\((.+?)\)$/', '$1', trim($row->indexdef)));
385-
$obj->fields = array_map(static fn ($v): string => trim($v), $_fields);
385+
$obj->fields = array_map(trim(...), $_fields);
386386

387387
if (str_starts_with($row->indexdef, 'CREATE UNIQUE INDEX pk')) {
388388
$obj->type = 'PRIMARY';

system/Database/SQLSRV/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ protected function _indexData(string $table): array
266266
$obj->name = $row->index_name;
267267

268268
$_fields = explode(',', trim($row->index_keys));
269-
$obj->fields = array_map(static fn ($v): string => trim($v), $_fields);
269+
$obj->fields = array_map(trim(...), $_fields);
270270

271271
if (str_contains($row->index_description, 'primary key located on')) {
272272
$obj->type = 'PRIMARY';

system/Database/SQLSRV/Forge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ protected function _attributeType(array &$attributes)
398398
// https://learn.microsoft.com/en-us/sql/t-sql/data-types/char-and-varchar-transact-sql?view=sql-server-ver16#remarks
399399
$maxLength = max(
400400
array_map(
401-
static fn ($value): int => strlen($value),
401+
strlen(...),
402402
$attributes['CONSTRAINT'],
403403
),
404404
);

system/Events/Events.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static function initialize()
8585
}
8686

8787
$files = array_filter(array_map(
88-
static fn (string $file): false|string => realpath($file),
88+
realpath(...),
8989
$files,
9090
));
9191

system/Router/AutoRouterImproved.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private function searchLastDefaultController(): bool
209209
}
210210

211211
$namespaces = array_map(
212-
fn ($segment): string => $this->translateURI($segment),
212+
$this->translateURI(...),
213213
$segments,
214214
);
215215

0 commit comments

Comments
 (0)