Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malfunctioning use of variadic arguments in combination with autowired #289

Closed
pierotto opened this issue Jul 13, 2023 · 1 comment
Closed

Comments

@pierotto
Copy link

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.

@dg
Copy link
Member

dg commented Sep 20, 2023

This change was due to the fact that PHP 8 supports named parameters whose names are passed to variadics parameters. If I understand correctly, there was a problem of skipping the first $barClass parameter and just passing services to $bazClasses, right? I'll find a solution.

dg added a commit that referenced this issue Sep 21, 2023
dg added a commit that referenced this issue Sep 21, 2023
dg added a commit that referenced this issue Sep 21, 2023
dg added a commit that referenced this issue Sep 22, 2023
dg added a commit that referenced this issue Sep 22, 2023
dg added a commit that referenced this issue Sep 23, 2023
dg added a commit that referenced this issue Sep 29, 2023
dg added a commit that referenced this issue Sep 29, 2023
dg added a commit that referenced this issue Oct 2, 2023
@dg dg closed this as completed Oct 9, 2023
dg added a commit that referenced this issue Oct 15, 2023
dg added a commit that referenced this issue Oct 15, 2023
dg added a commit that referenced this issue Oct 18, 2023
dg added a commit that referenced this issue Oct 18, 2023
dg added a commit that referenced this issue Oct 18, 2023
dg added a commit that referenced this issue Oct 18, 2023
dg added a commit that referenced this issue Oct 18, 2023
dg added a commit that referenced this issue Oct 30, 2023
dg added a commit that referenced this issue Nov 2, 2023
dg added a commit that referenced this issue Nov 2, 2023
dg added a commit that referenced this issue Nov 2, 2023
dg added a commit that referenced this issue Nov 2, 2023
dg added a commit that referenced this issue Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants