Skip to content

Commit ea9c481

Browse files
authored
Make Blueprint Resolver Statically (#55607)
1 parent f9a96f7 commit ea9c481

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/Illuminate/Database/Schema/Builder.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use InvalidArgumentException;
1010
use LogicException;
1111

12+
/**
13+
* @template TResolver of \Closure(string, \Closure, string): \Illuminate\Database\Schema\Blueprint
14+
*/
1215
class Builder
1316
{
1417
use Macroable;
@@ -30,9 +33,9 @@ class Builder
3033
/**
3134
* The Blueprint resolver callback.
3235
*
33-
* @var \Closure
36+
* @var TResolver|null
3437
*/
35-
protected $resolver;
38+
protected static $resolver = null;
3639

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

632-
if (isset($this->resolver)) {
633-
return call_user_func($this->resolver, $connection, $table, $callback);
635+
if (static::$resolver !== null) {
636+
return call_user_func(static::$resolver, $connection, $table, $callback);
634637
}
635638

636639
return Container::getInstance()->make(Blueprint::class, compact('connection', 'table', 'callback'));
@@ -698,11 +701,11 @@ public function getConnection()
698701
/**
699702
* Set the Schema Blueprint resolver callback.
700703
*
701-
* @param \Closure $resolver
704+
* @param TResolver|null $resolver
702705
* @return void
703706
*/
704-
public function blueprintResolver(Closure $resolver)
707+
public function blueprintResolver(?Closure $resolver)
705708
{
706-
$this->resolver = $resolver;
709+
static::$resolver = $resolver;
707710
}
708711
}

0 commit comments

Comments
 (0)