diff --git a/src/Container.php b/src/Container.php index 814d9f7..a9a9567 100644 --- a/src/Container.php +++ b/src/Container.php @@ -239,8 +239,10 @@ protected function resolve(ReflectionFunctionAbstract $function, array $params) if ($class = $parameter->getClass()) { if (true === $this->has($class->getName())) { $parameters[] = $this->get($class->getName()); - } else { + } elseif ($class->isInstantiable() === true) { $parameters[] = $this->factory($class->getName()); + } else { + $parameters[] = $parameter->isOptional() ? $parameter->getDefaultValue() : null; } } else { $name = $parameter->getName();