Skip to content

Commit

Permalink
bug #29894 [DependencyInjection] the string "0" is a valid service id…
Browse files Browse the repository at this point in the history
…entifier (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[DependencyInjection] the string "0" is a valid service identifier

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29854
| License       | MIT
| Doc PR        |

Commits
-------

caca373 the string "0" is a valid service identifier
  • Loading branch information
fabpot committed Jan 15, 2019
2 parents 7789a99 + caca373 commit 0f0c30a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -496,7 +496,7 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $file, $lowercase =


switch ($arg->getAttribute('type')) { switch ($arg->getAttribute('type')) {
case 'service': 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)); throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file));
} }
if ($arg->hasAttribute('strict')) { if ($arg->hasAttribute('strict')) {
Expand Down Expand Up @@ -549,7 +549,7 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $file, $lowercase =
* @param \DOMNode $node * @param \DOMNode $node
* @param mixed $name * @param mixed $name
* *
* @return array * @return \DOMElement[]
*/ */
private function getChildren(\DOMNode $node, $name) private function getChildren(\DOMNode $node, $name)
{ {
Expand Down
Expand Up @@ -61,5 +61,9 @@
</service> </service>
<service id="alias_for_foo" alias="foo" /> <service id="alias_for_foo" alias="foo" />
<service id="another_alias_for_foo" alias="foo" public="false" /> <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> </services>
</container> </container>

0 comments on commit 0f0c30a

Please sign in to comment.