diff --git a/reportbuilder/classes/local/helpers/format.php b/reportbuilder/classes/local/helpers/format.php index 2662cd5bee8..722856acecd 100644 --- a/reportbuilder/classes/local/helpers/format.php +++ b/reportbuilder/classes/local/helpers/format.php @@ -35,7 +35,7 @@ class format { /** * Returns formatted date. * - * @param int $value Unix timestamp + * @param int|null $value Unix timestamp * @param stdClass $row * @param string|null $format Format string for strftime * @return string @@ -47,20 +47,26 @@ class format { /** * Returns yes/no string depending on the given value * - * @param bool $value + * @param bool|null $value * @return string */ public static function boolean_as_text($value): string { + if ($value === null) { + return ''; + } return (bool) $value ? get_string('yes') : get_string('no'); } /** * Returns float value as a percentage * - * @param float $value + * @param float|null $value * @return string */ public static function percent($value): string { + if ($value === null) { + return ''; + } return get_string('percents', 'moodle', format_float((float) $value)); } } diff --git a/reportbuilder/classes/local/report/column.php b/reportbuilder/classes/local/report/column.php index d0177c3e4e6..159c80caeeb 100644 --- a/reportbuilder/classes/local/report/column.php +++ b/reportbuilder/classes/local/report/column.php @@ -481,6 +481,7 @@ final class column { * The type of the $value parameter passed to the callback is determined by calling {@see set_type}, however note that * if the column is part of a report source and can be aggregated using one of the "Group concatenation" methods then the * type should be omitted if it's not string + * For entities that can to be left joined to a report, the first argument to their column callbacks must be nullable. * * function($value, stdClass $row[, $additionalarguments]): string * @@ -649,6 +650,9 @@ final class column { */ private function get_default_value(array $values) { $value = reset($values); + if ($value === null) { + return $value; + } // Ensure default value is cast to it's strict type. switch ($this->get_type()) {