diff --git a/src/Traits/ParamTrait.php b/src/Traits/ParamTrait.php index 10fda07..eb19883 100644 --- a/src/Traits/ParamTrait.php +++ b/src/Traits/ParamTrait.php @@ -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; }