@@ -256,12 +256,13 @@ public function bind($abstract, $concrete = null, $shared = false)
256256 */
257257 protected function getClosure ($ abstract , $ concrete )
258258 {
259- return function ($ container , $ parameters = []) use ($ abstract , $ concrete ) {
259+ return function (Container $ container , $ parameters = []) use ($ abstract , $ concrete ) {
260260 if ($ abstract == $ concrete ) {
261261 return $ container ->build ($ concrete );
262262 }
263263
264- return $ container ->make ($ concrete , $ parameters );
264+ // To prevent extra call to resolving callbacks, we make the object silently.
265+ return $ container ->resolveSilent ($ concrete , $ parameters );
265266 };
266267 }
267268
@@ -633,6 +634,19 @@ public function get($id)
633634 * @return mixed
634635 */
635636 protected function resolve ($ abstract , $ parameters = [])
637+ {
638+ $ this ->resolveSilent ($ abstract , $ parameters , false );
639+ }
640+
641+ /**
642+ * Resolve the given type from the container.
643+ *
644+ * @param string $abstract
645+ * @param array $parameters
646+ * @param bool $silent
647+ * @return mixed
648+ */
649+ private function resolveSilent ($ abstract , $ parameters = [], $ silent = true )
636650 {
637651 $ abstract = $ this ->getAlias ($ abstract );
638652
@@ -674,8 +688,9 @@ protected function resolve($abstract, $parameters = [])
674688 $ this ->instances [$ abstract ] = $ object ;
675689 }
676690
677- $ this ->fireResolvingCallbacks ($ abstract , $ object );
678-
691+ if (! $ silent ) {
692+ $ this ->fireResolvingCallbacks ($ abstract , $ object );
693+ }
679694 // Before returning, we will also set the resolved flag to "true" and pop off
680695 // the parameter overrides for this build. After those two things are done
681696 // we will be ready to return back the fully constructed class instance.
0 commit comments