Skip to content

XML service arguments with attribute id="0" are treated as not having it at all. #29854

Closed
@szymach

Description

@szymach

Symfony version(s) affected: checked on 3.4.21

Description
Hello,

In an older version of a library I use, there as a compiler pass that uses annotations to automatically tag services whose classes have it. It defines services as having the actual class, but the id attribute is an incremented integer index starting from 0. This causes the XmlFileLoader to throw an exception due to variable casting.

I know this method of creating services is obsolete, but I am wondering whether not allowing a service with id 0 (which here is anonymous and only used in a collection parameter of another service) should be prohibited. Perhaps the linked condition should strictly check for null and empty string instead of casting it to a boolean.

None of this is a big issue to me, just thought I would report it.

Additional context

I run into this issue only while performing a debug:container command, the application itself runs without an exception for some reason.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions