Skip to content

Commit 83ea365

Browse files
committed
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.
1 parent 9acc6da commit 83ea365

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Traits/ParamTrait.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private function getInputParams($inputs, $params)
2828
foreach ($inputs as $input) {
2929
$key = $input->getName();
3030
if (array_key_exists($key, $params)) {
31-
$result[$key] = $params[$key];
31+
$result[$key] = $this->typeCastParam($params[$key]);
3232
} elseif (!$input->isOptional()) {
3333
throw new FunctionCallException(sprintf(
3434
'Missing parameter \'%s\' for function call \'%s\'!',
@@ -40,6 +40,25 @@ private function getInputParams($inputs, $params)
4040
return $result;
4141
}
4242

43+
/**
44+
* Typecast a remote function call parameter.
45+
*
46+
* The SAPNWRFC module by Piers Harding on PHP 5.5 would throw an exception
47+
* in case parameters were anything other than strings. All other modules
48+
* (saprfc by Koucky on PHP 5.5 and sapnwrfc by Kralik on PHP 7.x) don't
49+
* behave that way.
50+
*
51+
* @param mixed $param The parameter to typecast.
52+
* @return string|array
53+
*/
54+
private function typeCastParam($param)
55+
{
56+
if (is_array($param) || is_string($param)) {
57+
return $param;
58+
}
59+
return (string)$param;
60+
}
61+
4362
/**
4463
* Generate a function call parameter array from a list of known tables and the
4564
* previously set parameters.

0 commit comments

Comments
 (0)