fix phpstan level 9 warnings

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

View File

@ -104,8 +104,8 @@ class Manage extends dcNsProcess
(new Hidden(['p'], My::id()))->render()
);
$current->list->display(
(int) $current->filter->__get('page'),
(int) $current->filter->__get('nb'),
is_numeric($current->filter->__get('page')) ? (int) $current->filter->__get('page') : 1,
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 Text('', '%s')),
(new Div())->class('two-cols')->items([

View File

@ -37,7 +37,7 @@ class ManageVars
/** @var null|BackendList $list The records list form instance */
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;
/** @var bool $selected_logs The post form action */
@ -65,7 +65,8 @@ class ManageVars
try {
$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);
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());

View File

@ -48,7 +48,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 : 'Undefined');
}
/**