fix phpstan level 9 warnings

This commit is contained in:
Jean-Christian Denis 2023-04-29 21:51:41 +02:00
parent 9d05c543ac
commit dbc8541d59
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
4 changed files with 21 additions and 12 deletions

View file

@ -18,6 +18,7 @@ use ArrayObject;
use dcAdmin; use dcAdmin;
use dcCore; use dcCore;
use dcFavorites; use dcFavorites;
use dcMenu;
use dcNsProcess; use dcNsProcess;
use dcPage; use dcPage;
@ -40,13 +41,18 @@ class Backend extends dcNsProcess
} }
// backend sidebar menu icon // backend sidebar menu icon
dcCore::app()->menu[dcAdmin::MENU_SYSTEM]->addItem( if (!is_null(dcCore::app()->auth)
My::name(), && !is_null(dcCore::app()->adminurl)
dcCore::app()->adminurl?->get('admin.plugin.' . My::id()), && (dcCore::app()->menu[dcAdmin::MENU_SYSTEM] instanceof dcMenu)
dcPage::getPF(My::id() . '/icon.svg'), ) {
preg_match('/' . preg_quote((string) dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']), dcCore::app()->menu[dcAdmin::MENU_SYSTEM]->addItem(
dcCore::app()->auth?->isSuperAdmin() 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()
);
}
dcCore::app()->addBehaviors([ dcCore::app()->addBehaviors([
// backend user preference for logs list columns // backend user preference for logs list columns

View file

@ -104,8 +104,8 @@ class Manage extends dcNsProcess
(new Hidden(['p'], My::id()))->render() (new Hidden(['p'], My::id()))->render()
); );
$current->list->display( $current->list->display(
(int) $current->filter->__get('page'), is_numeric($current->filter->__get('page')) ? (int) $current->filter->__get('page') : 1,
(int) $current->filter->__get('nb'), is_numeric($current->filter->__get('nb')) ? (int) $current->filter->__get('nb') : 10,
(new Form('form-entries'))->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->method('post')->fields([ (new Form('form-entries'))->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->method('post')->fields([
(new Text('', '%s')), (new Text('', '%s')),
(new Div())->class('two-cols')->items([ (new Div())->class('two-cols')->items([

View file

@ -37,7 +37,7 @@ class ManageVars
/** @var null|BackendList $list The records list form instance */ /** @var null|BackendList $list The records list form instance */
public readonly ?BackendList $list; public readonly ?BackendList $list;
/** @var array $entries The post form selected entries */ /** @var array<int,string> $entries The post form selected entries */
public readonly array $entries; public readonly array $entries;
/** @var bool $selected_logs The post form action */ /** @var bool $selected_logs The post form action */
@ -65,7 +65,8 @@ class ManageVars
try { try {
$this->logs = dcCore::app()->log->getLogs($params); $this->logs = dcCore::app()->log->getLogs($params);
$count = (int) dcCore::app()->log->getLogs($params, true)->f(0); $count = dcCore::app()->log->getLogs($params, true)->f(0);
$count = is_numeric($count) ? (int) $count : 0;
$this->list = new BackendList($this->logs, $count); $this->list = new BackendList($this->logs, $count);
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());

View file

@ -48,7 +48,9 @@ class My
*/ */
public static function name(): string 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 : 'Undefined');
} }
/** /**