Skip to content

Commit

Permalink
Resolver: better exception when normalizeEntity() fails due to servic…
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 16, 2024
1 parent c1d4186 commit 50beb32
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/DI/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,11 @@ private function normalizeEntity(Statement $statement): string|array|Reference|n
}

if ($item instanceof Definition) {
$name = current(array_keys($this->builder->getDefinitions(), $item, strict: true));
if ($name === false) {
throw new ServiceCreationException(sprintf("Service '%s' not found in definitions.", $item->getName()));
}
if ($this->builder->getDefinition($item->getName()) !== $item) {
throw new ServiceCreationException(sprintf("Service '%s' does not match the expected service.", $item->getName()));

$item = new Reference($name);
}
$item = new Reference($item->getName());
}

if ($item instanceof Reference) {
Expand Down

0 comments on commit 50beb32

Please sign in to comment.