Compare commits

...

2 Commits

Author SHA1 Message Date
Guy Sartorelli
8e3d6cb3eb
Merge pull request #148 from creative-commoners/pulls/4/php81
ENH PHP 8.1 compatibility
2022-04-22 16:18:26 +12:00
Steve Boyd
0bceb0903c ENH PHP 8.1 compatibility 2022-04-13 17:39:46 +12:00
3 changed files with 10 additions and 10 deletions

View File

@ -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.

View File

@ -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;
}
/**

View File

@ -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\"";
}