Skip to content

[12.x] Make Blueprint Resolver Statically #55607

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

Merged
merged 1 commit into from
Apr 30, 2025
Merged
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
17 changes: 10 additions & 7 deletions src/Illuminate/Database/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use InvalidArgumentException;
use LogicException;

/**
* @template TResolver of \Closure(string, \Closure, string): \Illuminate\Database\Schema\Blueprint
*/
class Builder
{
use Macroable;
Expand All @@ -30,9 +33,9 @@ class Builder
/**
* The Blueprint resolver callback.
*
* @var \Closure
* @var TResolver|null
*/
protected $resolver;
protected static $resolver = null;

/**
* The default string length for migrations.
Expand Down Expand Up @@ -629,8 +632,8 @@ protected function createBlueprint($table, ?Closure $callback = null)
{
$connection = $this->connection;

if (isset($this->resolver)) {
return call_user_func($this->resolver, $connection, $table, $callback);
if (static::$resolver !== null) {
return call_user_func(static::$resolver, $connection, $table, $callback);
}

return Container::getInstance()->make(Blueprint::class, compact('connection', 'table', 'callback'));
Expand Down Expand Up @@ -698,11 +701,11 @@ public function getConnection()
/**
* Set the Schema Blueprint resolver callback.
*
* @param \Closure $resolver
* @param TResolver|null $resolver
* @return void
*/
public function blueprintResolver(Closure $resolver)
public function blueprintResolver(?Closure $resolver)
{
$this->resolver = $resolver;
static::$resolver = $resolver;
}
}