Skip to content

Commit

Permalink
Fix issue in AurynContainer::has
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Dec 9, 2023
1 parent cd973a1 commit 6c2db01
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions src/Container/AurynContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function get($id)
*/
public function has($id)
{
if (array_key_exists($id, $this->has)) return $this->has[$id];
if (array_key_exists($id, $this->items)) return true;

$filter = Injector::I_BINDINGS | Injector::I_DELEGATES;

Expand All @@ -113,40 +113,15 @@ public function has($id)
*/
public function set($id, $concrete)
{
$params = is_array($concrete) ? $concrete : array();

if (! $concrete || is_array($concrete))
{
$params = is_array($concrete) ? $concrete : array();

$this->items[$id] = $this->injector->make($id, $params);

return $this;
$concrete = $this->injector->make($id, $params);
}

$this->items[$id] = $concrete;

// Tries to set the instance as shareable ---
try
{
$this->injector->share($concrete);
}
// @codeCoverageIgnoreStart
catch (\Exception $error) {}
// @codeCoverageIgnoreEnd
// ------------------------------------------

// Also create an alias if available ---
try
{
/** @var object $concrete */
$class = get_class($concrete);

$this->injector->alias($id, $class);
}
// @codeCoverageIgnoreStart
catch (\Exception $error) {}
// @codeCoverageIgnoreEnd
// -------------------------------------

return $this;
}

Expand Down

0 comments on commit 6c2db01

Please sign in to comment.