MDL-76362 various: Avoid passing nulls to functions that don't allow nulls

PHP 8.1 is more strict on the parameter type. Functions such as trim(), strlen(), str_replace(), etc
show notice when null is passed as an argument
This commit is contained in:
Marina Glancy
2023-01-23 09:16:06 +08:00
committed by Andrew Nicols
parent d83368a475
commit 2dd7290ccb
69 changed files with 105 additions and 102 deletions
+1 -1
View File
@@ -260,7 +260,7 @@ class EvalMath {
if (is_null($o2)) return $this->trigger(get_string('unexpectedclosingbracket', 'mathslib'));
else $output[] = $o2;
}
if (preg_match('/^('.self::$namepat.')\($/', $stack->last(2), $matches)) { // did we just close a function?
if (preg_match('/^('.self::$namepat.')\($/', $stack->last(2) ?? '', $matches)) { // did we just close a function?
$fnn = $matches[1]; // get the function name
$arg_count = $stack->pop(); // see how many arguments there were (cleverly stored on the stack, thank you)
$fn = $stack->pop();