diff --git a/app/Container/DI.php b/app/Container/DI.php index 130d4c2..fb6c054 100644 --- a/app/Container/DI.php +++ b/app/Container/DI.php @@ -60,7 +60,11 @@ protected function resolve(string $class): object $constructorParams = []; foreach ($params as $param) { $dependencyClass = $param->getType(); - if ($dependencyClass instanceof \ReflectionType) { + if ($param->isDefaultValueAvailable()) { + $constructorParams[] = $param->getDefaultValue(); + } else if ($dependencyClass instanceof \ReflectionUnionType) { + throw new ContainerException("Can't resolve entry."); + } else if ($dependencyClass instanceof \ReflectionType) { /** @var ReflectionType $dependencyClass */ $type = $dependencyClass->getName(); if (class_exists($type)) { diff --git a/composer.json b/composer.json index f306f01..9b0db4e 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "hugoandrade/container-di", "type": "library", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "autoload": { "psr-4": {