Skip to content

Commit

Permalink
fix to prevent invoking construct with missing arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanak-michal committed Aug 9, 2021
1 parent ddf3ab9 commit fdb0b29
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Deepr.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ final class Deepr

/**
* Apply query on specific Collection instance
* @see setOptions()
* @param Collection $root
* @param array $query
* @param array $options
* @return array
* @throws Exception
* @see setOptions()
*/
public function invokeQuery(Collection $root, array $query, array $options = []): array
{
Expand Down Expand Up @@ -188,8 +188,9 @@ private function getInstance(array $args): IComponent
$invokeArgs = [];
if ($reflection->getConstructor()) {
foreach ($reflection->getConstructor()->getParameters() as $parameter) {
if (array_key_exists($parameter->getName(), $args))
$invokeArgs[] = $args[$parameter->getName()];
$invokeArgs[] = array_key_exists($parameter->getName(), $args)
? $args[$parameter->getName()]
: $parameter->getDefaultValue();
}
}

Expand Down

0 comments on commit fdb0b29

Please sign in to comment.