PHP-DI icon indicating copy to clipboard operation
PHP-DI copied to clipboard

autowire constructor with more parameters

Open theking2 opened this issue 2 years ago • 1 comments

Is it possible to autowire a constructor with more than one parameters?

class Foo
{
    private $bar;
    private $string;

    public function __construct(Bar $bar, string $string, readonly int $int)
    {
        $this->bar = $bar;
        $this->string = $string;
    }
}

theking2 avatar Jan 24 '24 19:01 theking2

Yes, for example look at constructorParameter() in https://php-di.org/doc/php-definitions.html#autowired-objects

mnapoli avatar Jan 24 '24 21:01 mnapoli