Skip to content

Commit

Permalink
default values for classes
Browse files Browse the repository at this point in the history
  • Loading branch information
reinvanoyen committed Jan 16, 2020
1 parent f028b39 commit 88cbe68
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,19 @@ private function create(string $contract, array $arguments = [])
}

// Get the class from the container
$injections[] = $this->get($className);
if ($this->has($className)) {

$injections[] = $this->get($className);
continue;
}

// Check if the argument has a default value
if ($parameter->isDefaultValueAvailable()) {

// Inject the default value (most probably null)
$injections[] = $parameter->getDefaultValue();
continue;
}

continue;

Expand Down

0 comments on commit 88cbe68

Please sign in to comment.