Skip to content

Commit

Permalink
Merge pull request #1 from hugoramosandrade/1.0.1
Browse files Browse the repository at this point in the history
bugfix - solve properties with uniontypes
  • Loading branch information
hugoramosandrade authored Aug 1, 2024
2 parents 225926d + 7742dd7 commit 07ad477
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/Container/DI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hugoandrade/container-di",
"type": "library",
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"autoload": {
"psr-4": {
Expand Down

0 comments on commit 07ad477

Please sign in to comment.