From 88e28251628f7f3f9540a485a455738172ae4064 Mon Sep 17 00:00:00 2001 From: Thorsten Frommen Date: Fri, 30 Jun 2023 18:51:12 +0200 Subject: [PATCH] Remove unnecessary and expensive hasService check Signed-off-by: Thorsten Frommen --- src/Container/ContainerConfigurator.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Container/ContainerConfigurator.php b/src/Container/ContainerConfigurator.php index 9f24878..a6d849d 100644 --- a/src/Container/ContainerConfigurator.php +++ b/src/Container/ContainerConfigurator.php @@ -73,20 +73,16 @@ public function addFactory(string $id, callable $factory): void */ public function addService(string $id, callable $service): void { - if ($this->hasService($id)) { - /* - * We are being intentionally permissive here, - * allowing a simple workflow for *intentional* overrides - * while accepting the (small?) risk of *accidental* overrides - * that could be hard to notice and debug. - */ - - /* - * Clear a factory flag in case it was a factory. - * If needs be, it will get re-added after this function completes. - */ - unset($this->factoryIds[$id]); - } + /* + * We are being intentionally permissive here, + * allowing a simple workflow for *intentional* overrides + * while accepting the (small?) risk of *accidental* overrides + * that could be hard to notice and debug. + * + * Clear a factory flag in case it was a factory. + * If needs be, it will get re-added after this function completes. + */ + unset($this->factoryIds[$id]); $this->services[$id] = $service; }