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] Enhance doc blocks of the Migrator class #52033

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Convert closures to arrow functions
  • Loading branch information
imanghafoori1 committed Jul 5, 2024
commit cc4f2fde61ab0cd67994a508e02d7d48aad64f84
35 changes: 16 additions & 19 deletions src/Illuminate/Database/Migrations/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ public function run($paths = [], array $options = [])
protected function pendingMigrations($files, $ran)
{
return Collection::make($files)
->reject(function ($file) use ($ran) {
return in_array($this->getMigrationName($file), $ran);
})->values()->all();
->reject(fn ($file) => in_array($this->getMigrationName($file), $ran))
->values()
->all();
}

/**
Expand Down Expand Up @@ -344,9 +344,7 @@ protected function resetMigrations(array $migrations, array $paths, $pretend = f
// Since the getRan method that retrieves the migration name just gives us the
// migration name, we will format the names into objects with the name as a
// property on the objects so that we can pass it to the rollback method.
$migrations = collect($migrations)->map(function ($m) {
return (object) ['migration' => $m];
})->all();
$migrations = collect($migrations)->map(fn ($m) => (object) ['migration' => $m])->all();

return $this->rollbackMigrations(
$migrations, $paths, compact('pretend')
Expand Down Expand Up @@ -430,9 +428,10 @@ protected function pretendToRun($migration, $method)

$this->write(TwoColumnDetail::class, $name);

$this->write(BulletList::class, collect($this->getQueries($migration, $method))->map(function ($query) {
return $query['query'];
}));
$this->write(
BulletList::class,
collect($this->getQueries($migration, $method))->map(fn ($query) => $query['query'])
);
}

/**
Expand Down Expand Up @@ -536,13 +535,13 @@ protected function getMigrationClass(string $migrationName): string
*/
public function getMigrationFiles($paths)
{
return Collection::make($paths)->flatMap(function ($path) {
return str_ends_with($path, '.php') ? [$path] : $this->files->glob($path.'/*_*.php');
})->filter()->values()->keyBy(function ($file) {
return $this->getMigrationName($file);
})->sortBy(function ($file, $key) {
return $key;
})->all();
return Collection::make($paths)
->flatMap(fn ($path) => str_ends_with($path, '.php') ? [$path] : $this->files->glob($path.'/*_*.php'))
->filter()
->values()
->keyBy(fn ($file) => $this->getMigrationName($file))
->sortBy(fn ($file, $key) => $key)
->all();
}

/**
Expand Down Expand Up @@ -613,9 +612,7 @@ public function usingConnection($name, callable $callback)

$this->setConnection($name);

return tap($callback(), function () use ($previousConnection) {
$this->setConnection($previousConnection);
});
return tap($callback(), fn () => $this->setConnection($previousConnection));
}

/**
Expand Down