From a0b5e61cefb43de071eece60ffdbe30df4988c28 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Mon, 1 May 2023 19:34:54 +0200 Subject: [PATCH] fix nullsafe warnings --- src/Backend.php | 26 ++++++++++++++++---------- src/ManageVars.php | 15 ++++++++++++--- src/My.php | 4 +++- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/Backend.php b/src/Backend.php index f2edac3..2841d64 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -18,6 +18,7 @@ use dcAdmin; use dcCore; use dcFavorites; use dcNsProcess; +use dcMenu; use dcPage; class Backend extends dcNsProcess @@ -36,16 +37,21 @@ class Backend extends dcNsProcess return false; } - dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( - My::name(), - dcCore::app()->adminurl?->get('admin.plugin.' . My::id()), - dcPage::getPF(My::id() . '/icon.svg'), - preg_match( - '/' . preg_quote((string) dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) . '(&.*)?$/', - $_SERVER['REQUEST_URI'] - ), - dcCore::app()->auth?->isSuperAdmin() - ); + if (!is_null(dcCore::app()->auth) + && !is_null(dcCore::app()->adminurl) + && (dcCore::app()->menu[dcAdmin::MENU_PLUGINS] instanceof dcMenu) + ) { + dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( + My::name(), + dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + dcPage::getPF(My::id() . '/icon.svg'), + preg_match( + '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', + $_SERVER['REQUEST_URI'] + ), + dcCore::app()->auth->isSuperAdmin() + ); + } dcCore::app()->addBehaviors([ 'adminDashboardFavoritesV2' => function (dcFavorites $favs): void { diff --git a/src/ManageVars.php b/src/ManageVars.php index 8a844ea..90b737f 100644 --- a/src/ManageVars.php +++ b/src/ManageVars.php @@ -23,16 +23,25 @@ use Exception; class ManageVars { - /** - * @var ManageVars self instance - */ + /** @var ManageVars self instance */ private static $container; + /** @var CleanersStack The cleaners stack */ public readonly CleanersStack $cleaners; + + /** @var null|CleanerParent The post form cleaner */ public readonly ?CleanerParent $cleaner; + + /** @var string $related The post form related action id */ public readonly string $related; + + /** @var array The post form selected ns */ public readonly array $entries; + + /** @var string The post form action id */ public readonly string $action; + + /** @var array The form actions combo */ public readonly array $combo; protected function __construct() diff --git a/src/My.php b/src/My.php index 3461769..0f1fb77 100644 --- a/src/My.php +++ b/src/My.php @@ -37,7 +37,9 @@ class My */ public static function name(): string { - return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name')); + $name = dcCore::app()->plugins->moduleInfo(self::id(), 'name'); + + return __(is_string($name) ? $name : self::id()); } /**