laravel/framework — pull request #1644 by TheDistantSea (2013-06-14 10:39:34+00:00)
Title: Container: use default value for unbuildable optional dependencies if available

When Container is building an object it recursively tries to build any dependencies (constructor parameters) first. However, it does not handle unbuildable dependencies consistently.

For scalar types (which are all unbuildable) Container checks if the parameter has a default value and uses that if so.

For non-scalar types this check is not performed, so binding can fail even in cases where it would be possible to fall back to a default value. This patch enables this feature.

Example use case:

```php
abstract class Composite
{
public function __construct(Composite $parent = null) {}
}

class Whatever extends Composite {}

$container->make('Whatever'); // fails, but it really shouldn't
```