From 9c8e314010e5671c6c2e5100a5acf725306ecbad Mon Sep 17 00:00:00 2001 From: Jake Whiteley Date: Sat, 10 Nov 2018 18:49:33 +0000 Subject: [PATCH] Ensure aliases return the correct stored object --- src/ObjectStorage.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ObjectStorage.php b/src/ObjectStorage.php index 26a4c16..21cd6bb 100644 --- a/src/ObjectStorage.php +++ b/src/ObjectStorage.php @@ -87,6 +87,10 @@ public function instance(string $key, $object) */ public function store(string $key, $object) { + if (isset($this->aliases[$key])) { + $key = $this->aliases[$key]; + } + $this->store[$key] = $object; } @@ -193,7 +197,7 @@ public function getStored(string $key) * @since 1.0.0 * * @param string $key Object key. - * @return object + * @return callable */ public function getFactory(string $key) { @@ -295,8 +299,8 @@ protected function removeAliasFor($key) * * @since 1.0.0 * - * @throws Hodl\Exceptions\InvalidKeyException if the key if not a valid class name. - * @throws Hodl\Exceptions\KeyExistsException if the key already exists. + * @throws \Hodl\Exceptions\InvalidKeyException If the key if not a valid class name. + * @throws \Hodl\Exceptions\KeyExistsException If the key already exists. * * @param string $key The key to check. */