Skip to content

Commit

Permalink
Vendor packages type hints are not always present.
Browse files Browse the repository at this point in the history
Because some vendor don't use type hints in their vendor packages the code died on trying to get a class name from the variable. By checking first if parameter type isn't empty we can avoid this and the rest of the code can continue.
  • Loading branch information
GeoffreyDijkstra committed Jan 17, 2020
1 parent 85d5550 commit 06440a8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/DependencyInjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ public static function instantiate(string $class)

foreach ($arguments->getParameters() as $parameter) {
$name = $parameter->getName();
$type = $parameter->getType()->getName();

if (!$parameter->getType()->isBuiltin()) {
if (!empty($parameter->getType()) && !$parameter->getType()->isBuiltin()) {
// This is a neat trick so we can use a override, interface or class implementation for this class.
if ($configuration->has($name)) {
$parameters[] = static::instantiate($configuration->get($name));
Expand All @@ -114,7 +113,7 @@ public static function instantiate(string $class)
}

// Instantiate the class and store it internally and in parameters array.
$parameters[] = static::instantiate($type);
$parameters[] = static::instantiate($parameter->getType()->getName());

continue;
}
Expand Down

0 comments on commit 06440a8

Please sign in to comment.