diff --git a/code/Report.php b/code/Report.php index b934b579..6120a4c3 100644 --- a/code/Report.php +++ b/code/Report.php @@ -218,7 +218,7 @@ class Report extends ViewableData */ protected function sanitiseClassName($class) { - return str_replace('\\', '-', $class); + return str_replace('\\', '-', $class ?? ''); } @@ -286,12 +286,12 @@ class Report extends ViewableData $reports = ClassInfo::subclassesFor(get_called_class()); $reportsArray = []; - if ($reports && count($reports) > 0) { + if ($reports && count($reports ?? []) > 0) { $excludedReports = static::get_excluded_reports(); // Collect reports into array with an attribute for 'sort' foreach ($reports as $report) { // Don't use the Report superclass, or any excluded report classes - if (in_array($report, $excludedReports)) { + if (in_array($report, $excludedReports ?? [])) { continue; } $reflectionClass = new ReflectionClass($report); @@ -484,7 +484,7 @@ class Report extends ViewableData $results = $this->extend($methodName, $member); if ($results && is_array($results)) { // Remove NULLs - $results = array_filter($results, function ($v) { + $results = array_filter($results ?? [], function ($v) { return !is_null($v); }); // If there are any non-NULL responses, then return the lowest one of them. diff --git a/code/ReportAdmin.php b/code/ReportAdmin.php index 19a1fc24..83aa57cb 100644 --- a/code/ReportAdmin.php +++ b/code/ReportAdmin.php @@ -139,7 +139,7 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider */ protected function unsanitiseClassName($class) { - return str_replace('-', '\\', $class); + return str_replace('-', '\\', $class ?? ''); } /** @@ -155,7 +155,7 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider */ public static function has_reports() { - return sizeof(Report::get_reports()) > 0; + return sizeof(Report::get_reports() ?? []) > 0; } /** diff --git a/code/SideReportView.php b/code/SideReportView.php index 171ef960..d80058b9 100644 --- a/code/SideReportView.php +++ b/code/SideReportView.php @@ -79,9 +79,9 @@ class SideReportView extends ViewableData // Formatting, a la TableListField if (!empty($info['formatting'])) { - $format = str_replace('$value', "__VAL__", $info['formatting']); - $format = preg_replace('/\$([A-Za-z0-9-_]+)/', '$record->$1', $format); - $format = str_replace('__VAL__', '$val', $format); + $format = str_replace('$value', "__VAL__", $info['formatting'] ?? ''); + $format = preg_replace('/\$([A-Za-z0-9-_]+)/', '$record->$1', $format ?? ''); + $format = str_replace('__VAL__', '$val', $format ?? ''); $val = eval('return "' . $format . '";'); } @@ -90,7 +90,7 @@ class SideReportView extends ViewableData $classClause = ""; if (isset($info['title'])) { - $cssClass = preg_replace('/[^A-Za-z0-9]+/', '', $info['title']); + $cssClass = preg_replace('/[^A-Za-z0-9]+/', '', $info['title'] ?? ''); $classClause = "class=\"$cssClass\""; }