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

autowire constructor with more parameters #877

Open
theking2 opened this issue Jan 24, 2024 · 1 comment
Open

autowire constructor with more parameters #877

theking2 opened this issue Jan 24, 2024 · 1 comment

Comments

@theking2
Copy link

theking2 commented Jan 24, 2024

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;
    }
}
@mnapoli
Copy link
Member

mnapoli commented Jan 24, 2024

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

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