mnapoli/PHP-DI — pull request #168 by ezzatron (2014-06-13 04:46:01+00:00)
Title: Uninstantiable defaulted constructor parameter injection issue

I keep encountering this issue, so I thought I'd have a crack at a fix. Unfortunately it wasn't as simple as it initially seemed, so this is only a test case to demonstrate the issue.

A common pattern we use in my workplace is to have defaulted constructor parameters. We also use interfaces for just about everything, so the class may look something like this:

```php
class Foo implements FooInterface
{
public function __construct(BarInterface $bar, BazInterface $baz = null)
{
if (null === $baz) {
$baz = new Baz;
}

$this->bar = $bar;
$this->baz = $baz;
}

// ...
}
```

So I would add definitions to our container something like:

```php
return array(
'BarInterface' => DI\object('Bar'),
'FooInterface' => DI\object('Foo'),
);
```

Leaving out a definition for `BazInterface` beacuse we just want to use the default. Now when you request `FooInterface` from the container:

```php
$container->get('FooInterface');
```

You get a nasty exception something like:

Entry BazInterface cannot be resolved: BazInterface is not instantiable

The *expected* result is that `get()` returns an instance of `Foo` using the default value for `$baz`.

This PR includes a rough integration test that currently fails because of the issue mentioned above. It is not intended to be merged as it doesn't follow the style of your other tests, but should be good enough to aid in diagnosing the cause of the issue.

Thanks!