the string "0" is a valid service identifier

This commit is contained in:
Christian Flothmann 2019-01-15 14:43:24 +01:00
parent 7789a99968
commit caca373383
2 changed files with 6 additions and 2 deletions

View File

@ -496,7 +496,7 @@ class XmlFileLoader extends FileLoader
switch ($arg->getAttribute('type')) {
case 'service':
if (!$arg->getAttribute('id')) {
if ('' === $arg->getAttribute('id')) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file));
}
if ($arg->hasAttribute('strict')) {
@ -549,7 +549,7 @@ class XmlFileLoader extends FileLoader
* @param \DOMNode $node
* @param mixed $name
*
* @return array
* @return \DOMElement[]
*/
private function getChildren(\DOMNode $node, $name)
{

View File

@ -61,5 +61,9 @@
</service>
<service id="alias_for_foo" alias="foo" />
<service id="another_alias_for_foo" alias="foo" public="false" />
<service id="0" class="FooClass" />
<service id="1" class="FooClass">
<argument type="service" id="0" />
</service>
</services>
</container>