Framework Update

This commit is contained in:
2024-01-31 22:15:08 +08:00
parent b5ff5e8b5f
commit 20678a6a0c
1459 changed files with 25954 additions and 16153 deletions
+23 -13
View File
@@ -631,9 +631,7 @@ class Container implements ArrayAccess, ContainerContract
*/
public function wrap(Closure $callback, array $parameters = [])
{
return function () use ($callback, $parameters) {
return $this->call($callback, $parameters);
};
return fn () => $this->call($callback, $parameters);
}
/**
@@ -648,7 +646,25 @@ class Container implements ArrayAccess, ContainerContract
*/
public function call($callback, array $parameters = [], $defaultMethod = null)
{
return BoundMethod::call($this, $callback, $parameters, $defaultMethod);
$pushedToBuildStack = false;
if (is_array($callback) && ! in_array(
$className = (is_string($callback[0]) ? $callback[0] : get_class($callback[0])),
$this->buildStack,
true
)) {
$this->buildStack[] = $className;
$pushedToBuildStack = true;
}
$result = BoundMethod::call($this, $callback, $parameters, $defaultMethod);
if ($pushedToBuildStack) {
array_pop($this->buildStack);
}
return $result;
}
/**
@@ -659,9 +675,7 @@ class Container implements ArrayAccess, ContainerContract
*/
public function factory($abstract)
{
return function () use ($abstract) {
return $this->make($abstract);
};
return fn () => $this->make($abstract);
}
/**
@@ -1065,9 +1079,7 @@ class Container implements ArrayAccess, ContainerContract
return $this->make($className);
}
return array_map(function ($abstract) {
return $this->resolve($abstract);
}, $concrete);
return array_map(fn ($abstract) => $this->resolve($abstract), $concrete);
}
/**
@@ -1428,9 +1440,7 @@ class Container implements ArrayAccess, ContainerContract
*/
public function offsetSet($key, $value): void
{
$this->bind($key, $value instanceof Closure ? $value : function () use ($value) {
return $value;
});
$this->bind($key, $value instanceof Closure ? $value : fn () => $value);
}
/**