Skip to content

Commit

Permalink
Merge pull request #9 from php-sap/8-missing-optional-output-causes-e…
Browse files Browse the repository at this point in the history
…rror

cast only existing values #8
  • Loading branch information
gregor-j authored Jan 18, 2022
2 parents aaeedce + 804911c commit 46b785b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Traits/ParamTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@ private function castOutputValues(array $outputs, array $result): array
$return = [];
foreach ($outputs as $output) {
$key = $output->getName();
$value = $output->cast($result[$key]);
$return[$key] = $value;
if (array_key_exists($key, $result)) {
$return[$key] = $output->cast($result[$key]);
} elseif (!$output->isOptional()) {
throw new FunctionCallException(sprintf(
'Missing result value \'%s\' for function call \'%s\'!',
$key,
$this->getName()
));
}
}
return $return;
}
Expand Down

0 comments on commit 46b785b

Please sign in to comment.