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

Autowiring should ignore optional parameters #171

mnapoli opened this Issue Jul 12, 2014 · 1 comment


None yet
1 participant

mnapoli commented Jul 12, 2014

from #168

class Foo
    public function __construct(Bar $bar = null)
        $this->bar = $bar ?: $this->createDefaultBar();

Today, by default PHP-DI will inject a Bar instance (because of autowiring). It should instead inject the default value, unless specified otherwise.

Fixing this will be a small BC break, but I think it's a necessary evil since it's quite problematic.

@mnapoli mnapoli added this to the 5.0 milestone Jul 12, 2014

@mnapoli mnapoli added the bug label Jul 12, 2014

@mnapoli mnapoli modified the milestones: 4.2, 5.0 Jul 12, 2014

mnapoli added a commit that referenced this issue Jul 29, 2014


This comment has been minimized.

Show comment
Hide comment

mnapoli Jul 29, 2014


Fixed in 4.2


mnapoli commented Jul 29, 2014

Fixed in 4.2

@mnapoli mnapoli closed this Jul 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment