Skip to content

Commit 25d59b2

Browse files
committed
Check if resolve is pending when firing callbacks
1 parent 24c77c0 commit 25d59b2

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Illuminate/Container/Container.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ protected function getCallbacksForType($abstract, $object, array $callbacksPerTy
10481048
$results = [];
10491049

10501050
foreach ($callbacksPerType as $type => $callbacks) {
1051-
if ($type === $abstract || ($object instanceof $type && ! in_array($type, $this->resolveStack))) {
1051+
if (! $this->pendingInResolveStack($object) && ($type === $abstract || $object instanceof $type)) {
10521052
$results = array_merge($results, $callbacks);
10531053
}
10541054
}
@@ -1070,6 +1070,24 @@ protected function fireCallbackArray($object, array $callbacks)
10701070
}
10711071
}
10721072

1073+
/**
1074+
* Check if object or a generalisation is pending in the resolve stack
1075+
*
1076+
* @param object $object
1077+
*
1078+
* @return bool
1079+
*/
1080+
protected function pendingInResolveStack($object)
1081+
{
1082+
foreach ($this->resolveStack as $resolving) {
1083+
if ($resolving !== end($this->resolveStack) && $object instanceof $resolving) {
1084+
return true;
1085+
}
1086+
}
1087+
1088+
return false;
1089+
}
1090+
10731091
/**
10741092
* Get the container's bindings.
10751093
*

0 commit comments

Comments
 (0)