Skip to content

Commit bacbc4b

Browse files
authored
[12.x] Use first-class callable syntax to improve static analysis (#53924)
* Use first-class callable syntax to improve static analysis * Fix syntax error * Revert first-class callable syntax for possibly non-existing methods
1 parent 8660d95 commit bacbc4b

File tree

29 files changed

+48
-48
lines changed

29 files changed

+48
-48
lines changed

src/Illuminate/Cache/CacheManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ protected function setEventDispatcher(Repository $repository)
332332
*/
333333
public function refreshEventDispatcher()
334334
{
335-
array_map([$this, 'setEventDispatcher'], $this->stores);
335+
array_map($this->setEventDispatcher(...), $this->stores);
336336
}
337337

338338
/**

src/Illuminate/Cache/TagSet.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(Store $store, array $names = [])
4040
*/
4141
public function reset()
4242
{
43-
array_walk($this->names, [$this, 'resetTag']);
43+
array_walk($this->names, $this->resetTag(...));
4444
}
4545

4646
/**
@@ -63,7 +63,7 @@ public function resetTag($name)
6363
*/
6464
public function flush()
6565
{
66-
array_walk($this->names, [$this, 'flushTag']);
66+
array_walk($this->names, $this->flushTag(...));
6767
}
6868

6969
/**
@@ -93,7 +93,7 @@ public function getNamespace()
9393
*/
9494
protected function tagIds()
9595
{
96-
return array_map([$this, 'tagId'], $this->names);
96+
return array_map($this->tagId(...), $this->names);
9797
}
9898

9999
/**

src/Illuminate/Collections/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function doesntContain($key, $operator = null, $value = null)
232232
public function crossJoin(...$lists)
233233
{
234234
return new static(Arr::crossJoin(
235-
$this->items, ...array_map([$this, 'getArrayableItems'], $lists)
235+
$this->items, ...array_map($this->getArrayableItems(...), $lists)
236236
));
237237
}
238238

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public function mapToGroups(callable $callback)
412412
{
413413
$groups = $this->mapToDictionary($callback);
414414

415-
return $groups->map([$this, 'make']);
415+
return $groups->map($this->make(...));
416416
}
417417

418418
/**

src/Illuminate/Console/Scheduling/ScheduleListCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function handle(Schedule $schedule)
8686
*/
8787
private function getCronExpressionSpacing($events)
8888
{
89-
$rows = $events->map(fn ($event) => array_map('mb_strlen', preg_split("/\s+/", $event->expression)));
89+
$rows = $events->map(fn ($event) => array_map(mb_strlen(...), preg_split("/\s+/", $event->expression)));
9090

9191
return (new Collection($rows[0] ?? []))->keys()->map(fn ($key) => $rows->max($key))->all();
9292
}

src/Illuminate/Database/Grammar.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class Grammar
3333
*/
3434
public function wrapArray(array $values)
3535
{
36-
return array_map([$this, 'wrap'], $values);
36+
return array_map($this->wrap(...), $values);
3737
}
3838

3939
/**
@@ -186,7 +186,7 @@ protected function isJsonSelector($value)
186186
*/
187187
public function columnize(array $columns)
188188
{
189-
return implode(', ', array_map([$this, 'wrap'], $columns));
189+
return implode(', ', array_map($this->wrap(...), $columns));
190190
}
191191

192192
/**
@@ -197,7 +197,7 @@ public function columnize(array $columns)
197197
*/
198198
public function parameterize(array $values)
199199
{
200-
return implode(', ', array_map([$this, 'parameter'], $values));
200+
return implode(', ', array_map($this->parameter(...), $values));
201201
}
202202

203203
/**

src/Illuminate/Database/Query/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4220,7 +4220,7 @@ public function addBinding($value, $type = 'where')
42204220

42214221
if (is_array($value)) {
42224222
$this->bindings[$type] = array_values(array_map(
4223-
[$this, 'castBinding'],
4223+
$this->castBinding(...),
42244224
array_merge($this->bindings[$type], $value),
42254225
));
42264226
} else {
@@ -4270,7 +4270,7 @@ public function cleanBindings(array $bindings)
42704270
->reject(function ($binding) {
42714271
return $binding instanceof ExpressionContract;
42724272
})
4273-
->map([$this, 'castBinding'])
4273+
->map($this->castBinding(...))
42744274
->values()
42754275
->all();
42764276
}

src/Illuminate/Database/Schema/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function getTypes()
239239
public function hasColumn($table, $column)
240240
{
241241
return in_array(
242-
strtolower($column), array_map('strtolower', $this->getColumnListing($table))
242+
strtolower($column), array_map(strtolower(...), $this->getColumnListing($table))
243243
);
244244
}
245245

@@ -252,7 +252,7 @@ public function hasColumn($table, $column)
252252
*/
253253
public function hasColumns($table, array $columns)
254254
{
255-
$tableColumns = array_map('strtolower', $this->getColumnListing($table));
255+
$tableColumns = array_map(strtolower(...), $this->getColumnListing($table));
256256

257257
foreach ($columns as $column) {
258258
if (! in_array(strtolower($column), $tableColumns)) {

src/Illuminate/Foundation/AliasLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function register()
164164
*/
165165
protected function prependToLoaderStack()
166166
{
167-
spl_autoload_register([$this, 'load'], true, true);
167+
spl_autoload_register($this->load(...), true, true);
168168
}
169169

170170
/**

src/Illuminate/Foundation/Console/RouteListCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ protected function getHeaders()
299299
*/
300300
protected function getColumns()
301301
{
302-
return array_map('strtolower', $this->headers);
302+
return array_map(strtolower(...), $this->headers);
303303
}
304304

305305
/**
@@ -320,7 +320,7 @@ protected function parseColumns(array $columns)
320320
}
321321
}
322322

323-
return array_map('strtolower', $results);
323+
return array_map(strtolower(...), $results);
324324
}
325325

326326
/**

0 commit comments

Comments
 (0)