From 6c2db01429262ba5ad8caed533e3a05540243542 Mon Sep 17 00:00:00 2001 From: Rougin Gutib Date: Sun, 10 Dec 2023 00:48:45 +0800 Subject: [PATCH] Fix issue in AurynContainer::has --- src/Container/AurynContainer.php | 33 ++++---------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/Container/AurynContainer.php b/src/Container/AurynContainer.php index ae364403..264519f2 100644 --- a/src/Container/AurynContainer.php +++ b/src/Container/AurynContainer.php @@ -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; @@ -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; }