MDL-78192 external: allow nullable non-scalar params and results

This commit is contained in:
Petr Skoda
2023-06-23 11:12:08 +02:00
parent 3cd84747cb
commit 16729b7f02
7 changed files with 117 additions and 12 deletions
+6 -1
View File
@@ -33,14 +33,18 @@ abstract class external_description {
/** @var mixed Default value */
public $default;
/** @var bool Allow null values */
public $allownull;
/**
* Contructor.
*
* @param string $desc Description of element
* @param int $required Whether the element value is required. Valid values are VALUE_DEFAULT, VALUE_REQUIRED, VALUE_OPTIONAL.
* @param mixed $default The default value
* @param bool $allownull Allow null value
*/
public function __construct($desc, $required, $default) {
public function __construct($desc, $required, $default, $allownull = NULL_NOTALLOWED) {
if (!in_array($required, [VALUE_DEFAULT, VALUE_REQUIRED, VALUE_OPTIONAL], true)) {
$requiredstr = $required;
if (is_array($required)) {
@@ -52,5 +56,6 @@ abstract class external_description {
$this->desc = $desc;
$this->required = $required;
$this->default = $default;
$this->allownull = (bool)$allownull;
}
}