Skip to content

Commit

Permalink
#11 Extended check in ::has
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackBonjour committed Oct 23, 2024
1 parent bfadd6c commit 227e3de
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,16 @@ public function get(string $id): mixed

public function has(string $id): bool
{
if (array_key_exists($id, $this->services) || isset($this->factories[$id])) {
if (
array_key_exists($id, $this->services)
|| array_key_exists($id, $this->resolvedServices)
|| isset($this->factories[$id])
|| isset($this->invokables[$id])
) {
return true;
}

foreach ($this->abstractFactories as $abstractFactory) {
if ($abstractFactory->canCreate($this, $id)) {
return true;
}
}

return false;
return $this->getAbstractFactory($id) !== null;
}

public function offsetExists(mixed $offset): bool
Expand Down

0 comments on commit 227e3de

Please sign in to comment.