Skip to content

Commit 6e13421

Browse files
authored
[9.x] Update Container\Util::unwrapIfClosure to match value helper (#36995)
* Match Util::unwrapIfClosure to value helper * Use helper when applicable
1 parent 8f31b64 commit 6e13421

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Illuminate/Container/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ protected function getLastParameterOverride()
961961
protected function resolvePrimitive(ReflectionParameter $parameter)
962962
{
963963
if (! is_null($concrete = $this->getContextualConcrete('$'.$parameter->getName()))) {
964-
return $concrete instanceof Closure ? $concrete($this) : $concrete;
964+
return Util::unwrapIfClosure($concrete, $this);
965965
}
966966

967967
if ($parameter->isDefaultValueAvailable()) {

src/Illuminate/Container/Util.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ public static function arrayWrap($value)
3333
* From global value() helper in Illuminate\Support.
3434
*
3535
* @param mixed $value
36+
* @param mixed ...$args
3637
* @return mixed
3738
*/
38-
public static function unwrapIfClosure($value)
39+
public static function unwrapIfClosure($value, ...$args)
3940
{
40-
return $value instanceof Closure ? $value() : $value;
41+
return $value instanceof Closure ? $value(...$args) : $value;
4142
}
4243

4344
/**

0 commit comments

Comments
 (0)