Skip to content

Commit 46b785b

Browse files
authored
Merge pull request #9 from php-sap/8-missing-optional-output-causes-error
cast only existing values #8
2 parents aaeedce + 804911c commit 46b785b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Traits/ParamTrait.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,15 @@ private function castOutputValues(array $outputs, array $result): array
7979
$return = [];
8080
foreach ($outputs as $output) {
8181
$key = $output->getName();
82-
$value = $output->cast($result[$key]);
83-
$return[$key] = $value;
82+
if (array_key_exists($key, $result)) {
83+
$return[$key] = $output->cast($result[$key]);
84+
} elseif (!$output->isOptional()) {
85+
throw new FunctionCallException(sprintf(
86+
'Missing result value \'%s\' for function call \'%s\'!',
87+
$key,
88+
$this->getName()
89+
));
90+
}
8491
}
8592
return $return;
8693
}

0 commit comments

Comments
 (0)