Skip to content

Commit

Permalink
Merge pull request #36 from inpsyde/remove-has-service-check
Browse files Browse the repository at this point in the history
Remove unnecessary and expensive hasService check
  • Loading branch information
tfrommen authored Jul 3, 2023
2 parents 0bde4d1 + 88e2825 commit 20f81d9
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/Container/ContainerConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 20f81d9

Please sign in to comment.