Skip to content

Factory named arguments wiring issue #48818

Closed
@v-m-i

Description

@v-m-i

Symfony version(s) affected

6.2.3 and 5.4.16

Description

If we have a factory that looks like this:

final class ExampleFactory
{
    public function __invoke(
        string $first = '',
        string $second = '',
    ): ExampleService
    {...}
}

And if we use it like this (based on Passing Arguments to the Factory Method documentation):

    $services->set(ExampleFactory::class);

    $services
        ->set(ExampleCommand::class)
        ->arg('$service',
                inline_service(ExampleService::class)
                ->factory(service(ExampleFactory::class))
                ->args(
                    [
                        '$second' => 'second',
                    ]
                )
        )

The factory will be called with

$factory('second');

instead of

$factory('', 'second');

Tested on 6.2.3 and 5.4.16, but it probably affects other versions too.

How to reproduce

Bug reproducer: https://github.com/v-m-i/symfony-argument-bug

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