diff --git a/api/src/Etemplate/Widget.php b/api/src/Etemplate/Widget.php index 78941148e3..a3f41e0f23 100644 --- a/api/src/Etemplate/Widget.php +++ b/api/src/Etemplate/Widget.php @@ -553,12 +553,21 @@ class Widget $method = new ReflectionMethod($this, $method_name); foreach($method->getParameters() as $index => $param) { - if(!$param->isOptional() && !array_key_exists($index,$params)) + if(!$param->isOptional() && !array_key_exists($index, $params)) { error_log("Missing required parameter {$param->getPosition()}: {$param->getName()}"); $call = false; } - if($param->isArray() && !is_array($params[$index])) + // Check to see if method wants an array, and we're providing it + $paramType = $param->getType(); + if(!$paramType) + { + continue; + } + $types = $paramType instanceof \ReflectionUnionType + ? $paramType->getTypes() + : [$paramType]; + if(in_array('array', array_map(fn(\ReflectionNamedType $t) => $t->getName(), $types)) && !is_array($params[$index])) { error_log("$method_name expects an array for {$param->getPosition()}: {$param->getName()}"); $params[$index] = (array)$params[$index];