mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
ENH PHP 8.1 compatibility
This commit is contained in:
parent
6d565028c8
commit
0bceb0903c
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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\"";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user