From 474c5512d2f38d7065892a33727b1dcc83cca92d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Rub=C3=A9l?= Date: Thu, 21 Nov 2024 21:20:55 +0100 Subject: [PATCH] Laravel 11.33: Patch Container --- src/Overrides/Container.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Overrides/Container.php b/src/Overrides/Container.php index 2320583..5c66877 100644 --- a/src/Overrides/Container.php +++ b/src/Overrides/Container.php @@ -635,9 +635,13 @@ public function refresh($abstract, $target, $method) */ protected function rebound($abstract) { + if (! $callbacks = $this->getReboundCallbacks($abstract)) { + return; + } + $instance = $this->make($abstract); - foreach ($this->getReboundCallbacks($abstract) as $callback) { + foreach ($callbacks as $callback) { $callback($this, $instance); } } @@ -882,7 +886,9 @@ protected function resolve($abstract, $parameters = [], $raiseEvents = true) // Before returning, we will also set the resolved flag to "true" and pop off // the parameter overrides for this build. After those two things are done // we will be ready to return back the fully constructed class instance. - $this->resolved[$abstract] = true; + if (! $needsContextualBuild) { + $this->resolved[$abstract] = true; + } array_pop($this->with); @@ -1135,6 +1141,10 @@ protected function resolvePrimitive(ReflectionParameter $parameter) return []; } + if ($parameter->hasType() && $parameter->allowsNull()) { + return null; + } + $this->unresolvablePrimitive($parameter); } @@ -1394,7 +1404,7 @@ protected function fireAfterResolvingCallbacks($abstract, $object) /** * Fire all of the after resolving attribute callbacks. * - * @param \ReflectionAttribute[] $abstract + * @param \ReflectionAttribute[] $attributes * @param mixed $object * @return void */ @@ -1576,11 +1586,7 @@ public function flush() */ public static function getInstance() { - if (is_null(static::$instance)) { - static::$instance = new static; - } - - return static::$instance; + return static::$instance ??= new static; } /**