From 83ea365220f3e78926aeb59c35456f19e188f13a Mon Sep 17 00:00:00 2001 From: Gregor Date: Mon, 2 Mar 2020 10:05:42 +0100 Subject: [PATCH] cast function call parameters to strings or arrays The SAPNWRFC module by Piers Harding on PHP 5.5 would throw an exception in case parameters were anything other than strings. All other modules (saprfc by Koucky on PHP 5.5 and sapnwrfc by Kralik on PHP 7.x) don't behave that way. --- src/Traits/ParamTrait.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Traits/ParamTrait.php b/src/Traits/ParamTrait.php index 7aefab5..bbe4fdc 100644 --- a/src/Traits/ParamTrait.php +++ b/src/Traits/ParamTrait.php @@ -28,7 +28,7 @@ private function getInputParams($inputs, $params) foreach ($inputs as $input) { $key = $input->getName(); if (array_key_exists($key, $params)) { - $result[$key] = $params[$key]; + $result[$key] = $this->typeCastParam($params[$key]); } elseif (!$input->isOptional()) { throw new FunctionCallException(sprintf( 'Missing parameter \'%s\' for function call \'%s\'!', @@ -40,6 +40,25 @@ private function getInputParams($inputs, $params) return $result; } + /** + * Typecast a remote function call parameter. + * + * The SAPNWRFC module by Piers Harding on PHP 5.5 would throw an exception + * in case parameters were anything other than strings. All other modules + * (saprfc by Koucky on PHP 5.5 and sapnwrfc by Kralik on PHP 7.x) don't + * behave that way. + * + * @param mixed $param The parameter to typecast. + * @return string|array + */ + private function typeCastParam($param) + { + if (is_array($param) || is_string($param)) { + return $param; + } + return (string)$param; + } + /** * Generate a function call parameter array from a list of known tables and the * previously set parameters.