MDL-80005 core: Update coding standards for core\param

This commit is contained in:
Andrew Nicols 2023-11-06 13:13:36 +08:00
parent d937e01550
commit a61658da17
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14

View File

@ -21,6 +21,8 @@ use core_text;
use invalid_parameter_exception;
use moodle_exception;
// phpcs:disable Generic.CodeAnalysis.EmptyStatement.DetectedIf
/**
* Parameter validation helpers for Moodle.
*
@ -527,7 +529,7 @@ enum param: string {
throw new invalid_parameter_exception($debuginfo);
}
}
if (is_array($param) or is_object($param)) {
if (is_array($param) || is_object($param)) {
throw new invalid_parameter_exception($debuginfo);
}
@ -535,9 +537,9 @@ enum param: string {
if ($this->canonical() === self::FLOAT) {
// Do not detect precision loss here.
if (is_float($param) or is_int($param)) {
if (is_float($param) || is_int($param)) {
// These always fit.
} else if (!is_numeric($param) or !preg_match('/^[\+-]?[0-9]*\.?[0-9]*(e[-+]?[0-9]+)?$/i', (string)$param)) {
} else if (!is_numeric($param) || !preg_match('/^[\+-]?[0-9]*\.?[0-9]*(e[-+]?[0-9]+)?$/i', (string)$param)) {
throw new invalid_parameter_exception($debuginfo);
}
} else if ((string) $param !== (string) $cleaned) {