Skip to content

Commit

Permalink
Laravel 11.33: Patch Container
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-rubel committed Nov 21, 2024
1 parent 299623e commit 474c551
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Overrides/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -1135,6 +1141,10 @@ protected function resolvePrimitive(ReflectionParameter $parameter)
return [];
}

if ($parameter->hasType() && $parameter->allowsNull()) {
return null;
}

$this->unresolvablePrimitive($parameter);
}

Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 474c551

Please sign in to comment.