Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] First class callable syntax #53806

Draft
wants to merge 1 commit into
base: 11.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ public function values()
*/
public function zip($items)
{
$arrayableItems = array_map(fn ($items) => $this->getArrayableItems($items), func_get_args());
$arrayableItems = array_map($this->getArrayableItems(...), func_get_args());

$params = array_merge([fn () => new static(func_get_args()), $this->items], $arrayableItems);

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ protected function resolveVariadicClass(ReflectionParameter $parameter)
return $this->make($className);
}

return array_map(fn ($abstract) => $this->resolve($abstract), $concrete);
return array_map($this->resolve(...), $concrete);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Concerns/CompilesJsonPaths.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function wrapJsonPath($value, $delimiter = '->')
$value = preg_replace("/([\\\\]+)?\\'/", "''", $value);

$jsonPath = (new Collection(explode($delimiter, $value)))
->map(fn ($segment) => $this->wrapJsonPathSegment($segment))
->map($this->wrapJsonPathSegment(...))
->join('.');

return "'$".(str_starts_with($jsonPath, '[') ? '' : '.').$jsonPath."'";
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/DatabaseTransactionsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected function removeCommittedTransactionsThatAreChildrenOf(DatabaseTransact
// also need to remove. We will recurse down the children of all removed transaction
// instances until there are no more deeply nested child transactions for removal.
$removedTransactions->each(
fn ($transaction) => $this->removeCommittedTransactionsThatAreChildrenOf($transaction)
$this->removeCommittedTransactionsThatAreChildrenOf(...)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public function qualifyColumn($column)
public function qualifyColumns($columns)
{
return (new BaseCollection($columns))
->map(fn ($column) => $this->qualifyColumn($column))
->map($this->qualifyColumn(...))
->all();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Migrations/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public function getMigrationFiles($paths)
->flatMap(fn ($path) => str_ends_with($path, '.php') ? [$path] : $this->files->glob($path.'/*_*.php'))
->filter()
->values()
->keyBy(fn ($file) => $this->getMigrationName($file))
->keyBy($this->getMigrationName(...))
->sortBy(fn ($file, $key) => $key)
->all();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4112,7 +4112,7 @@ protected function forSubQuery()
public function getColumns()
{
return ! is_null($this->columns)
? array_map(fn ($column) => $this->grammar->getValue($column), $this->columns)
? array_map($this->grammar->getValue(...), $this->columns)
: [];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ protected function wrapJsonPathAttributes($path)
$quote = func_num_args() === 2 ? func_get_arg(1) : "'";

return (new Collection($path))
->map(fn ($attribute) => $this->parseJsonPathArrayKeys($attribute))
->map($this->parseJsonPathArrayKeys(...))
->collapse()
->map(function ($attribute) use ($quote) {
return filter_var($attribute, FILTER_VALIDATE_INT) !== false
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/Console/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function handle()
->filter(function ($data, $key) {
return $this->option('only') ? in_array($this->toSearchKeyword($key), $this->sections()) : true;
})
->pipe(fn ($data) => $this->display($data));
->pipe($this->display(...));

$this->newLine();

Expand Down Expand Up @@ -270,7 +270,7 @@ protected function sections()
{
return (new Collection(explode(',', $this->option('only') ?? '')))
->filter()
->map(fn ($only) => $this->toSearchKeyword($only))
->map($this->toSearchKeyword(...))
->all();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function handle(PackageManifest $manifest)

(new Collection($manifest->manifest))
->keys()
->each(fn ($description) => $this->components->task($description))
->each($this->components->task(...))
Copy link
Member

@timacdonald timacdonald Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it could be a breaking change?

$this->components->task method will receive the $description as it previously did but it will also receive the each callbacks $index as the second parameter, where it is expecting a callable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed this is a breaking change.

Screenshot 2024-12-10 at 09 19 31

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, totally missed that!

->whenNotEmpty(fn () => $this->newLine());
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Process/FakeProcessDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function id(int $processId)
public function output(array|string $output)
{
if (is_array($output)) {
(new Collection($output))->each(fn ($line) => $this->output($line));
(new Collection($output))->each($this->output(...));

return $this;
}
Expand All @@ -76,7 +76,7 @@ public function output(array|string $output)
public function errorOutput(array|string $output)
{
if (is_array($output)) {
(new Collection($output))->each(fn ($line) => $this->errorOutput($line));
(new Collection($output))->each($this->errorOutput(...));

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function fragments(?array $fragments = null)
{
return is_null($fragments)
? $this->allFragments()
: (new Collection($fragments))->map(fn ($f) => $this->fragment($f))->implode('');
: (new Collection($fragments))->map($this->fragment(...))->implode('');
}

/**
Expand Down
Loading