Skip to content

[9.x] Update Container\Util::unwrapIfClosure to match value helper #36995

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 2 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ protected function getLastParameterOverride()
protected function resolvePrimitive(ReflectionParameter $parameter)
{
if (! is_null($concrete = $this->getContextualConcrete('$'.$parameter->getName()))) {
return $concrete instanceof Closure ? $concrete($this) : $concrete;
return Util::unwrapIfClosure($concrete, $this);
}

if ($parameter->isDefaultValueAvailable()) {
Expand Down
5 changes: 3 additions & 2 deletions src/Illuminate/Container/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ public static function arrayWrap($value)
* From global value() helper in Illuminate\Support.
*
* @param mixed $value
* @param mixed ...$args
* @return mixed
*/
public static function unwrapIfClosure($value)
public static function unwrapIfClosure($value, ...$args)
{
return $value instanceof Closure ? $value() : $value;
return $value instanceof Closure ? $value(...$args) : $value;
}

/**
Expand Down