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

Autowiring should ignore optional parameters #171

Closed
mnapoli opened this issue Jul 12, 2014 · 1 comment
Closed

Autowiring should ignore optional parameters #171

mnapoli opened this issue Jul 12, 2014 · 1 comment
Labels
Milestone

Comments

@mnapoli
Copy link
Member

@mnapoli 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 added this to the 4.2 milestone Jul 12, 2014
@mnapoli mnapoli removed this from the 5.0 milestone Jul 12, 2014
@mnapoli mnapoli mentioned this issue Jul 12, 2014
Merged
11 tasks
mnapoli added a commit that referenced this issue Jul 29, 2014
@mnapoli
Copy link
Member Author

@mnapoli 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
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant