Description
I just got bit that when using the decorates
syntax for a service definiton, that the decorates
requires the service name without leading @
.
As pointed out on the docs, this is correct:
bar:
public: false
class: stdClass
decorates: foo
arguments: ["@bar.inner"]
Yet I have written this code and thought it to be correct:
bar:
public: false
class: stdClass
decorates: @foo
arguments: ["@bar.inner"]
This then crashed by throwing a:
InvalidArgumentException in ContainerBuilder.php line 815:
The service definition "@foo" does not exist.
and it took me a bit and a xdebug session to figure out my typo.
Why isn't the @
here required for the service name? Is the current syntax inconsistent or do I lack an understanding of what the syntax refers to here? E.g. is the @
only used when a service is passed, and here it is only referencing a service name?
Maybe one can also improve the handling of Symfony\Component\DependencyInjection\ContainerBuilder::getDefinition($id)
to either strip an incomming @
from the beginning of the $id
or throw a message like
The service definition "@foo" does not exist. Did you maybe mean "foo" instead?`