Skip to content

Commit 20f81d9

Browse files
authored
Merge pull request #36 from inpsyde/remove-has-service-check
Remove unnecessary and expensive hasService check
2 parents 0bde4d1 + 88e2825 commit 20f81d9

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

src/Container/ContainerConfigurator.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,16 @@ public function addFactory(string $id, callable $factory): void
7373
*/
7474
public function addService(string $id, callable $service): void
7575
{
76-
if ($this->hasService($id)) {
77-
/*
78-
* We are being intentionally permissive here,
79-
* allowing a simple workflow for *intentional* overrides
80-
* while accepting the (small?) risk of *accidental* overrides
81-
* that could be hard to notice and debug.
82-
*/
83-
84-
/*
85-
* Clear a factory flag in case it was a factory.
86-
* If needs be, it will get re-added after this function completes.
87-
*/
88-
unset($this->factoryIds[$id]);
89-
}
76+
/*
77+
* We are being intentionally permissive here,
78+
* allowing a simple workflow for *intentional* overrides
79+
* while accepting the (small?) risk of *accidental* overrides
80+
* that could be hard to notice and debug.
81+
*
82+
* Clear a factory flag in case it was a factory.
83+
* If needs be, it will get re-added after this function completes.
84+
*/
85+
unset($this->factoryIds[$id]);
9086

9187
$this->services[$id] = $service;
9288
}

0 commit comments

Comments
 (0)