Skip to content

Malfunctioning use of variadic arguments in combination with autowired #289

@pierotto

Description

@pierotto

Version: 3.1.2, the error has been present since release 3.0.16 and above

Bug Description

class FooClass
{
    public function __construct(
        BarClass $barClass,
        BazClassInterface ...$bazClasses
    )
}

The error occurs with the following service configuration.

Example 1:

fooClass:
    factory: FooClass
    arguments:
        - @bazClass1
        - @bazClass2

With this configuration, DI is trying to inject the service "bazClass1" into the argument "$barClass".

Example 2:

fooClass:
    factory: FooClass
    arguments:
        bazClasses:
            - @bazClass1
            - @bazClass2

With this configuration, DI is trying to inject an array into the argument "$bazClasses".

Expected Behavior

The expected behavior is that even with a named argument, DI does not convert the variadic parameter into an array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions