Skip to content

Service YML : Cannot use enum array or object as service parameter #50346

Closed as not planned
@nbrignol

Description

@nbrignol

Symfony version(s) affected

6.2

Description

I can pass one enum as argument to a service, but not an array or an object.

If I call the parameter directly from the container (getParameter("app.myParam")) I get the array or the object. The issue is only when I use it argument for my service.

How to reproduce

I have a service defined like this :

services: 
    My\Service:
        arguments:
            $myArg: '%app.myParam%'

✅ I can pass one enum like this, it is working fine.

parameters:
    app.myParam: !php/enum MyEnum::Test

🚫 but when I try to pass enums as array or as object I have an Warning: Undefined array key "app.myParam" error

parameters:
    app.myParam: [!php/enum MyEnum::Test]
parameters:
    app.myParam: 
        test: !php/enum MyEnum::Test

Possible Solution

No response

Additional Context

No response

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