fix nullsafe warnings and type hint

This commit is contained in:
Jean-Christian Paul Denis 2023-05-13 11:38:18 +02:00
parent e9242f40c3
commit 7a3117e1ac
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
5 changed files with 27 additions and 20 deletions

View File

@ -17,6 +17,7 @@ namespace Dotclear\Plugin\httpPassword;
use dcAdmin; use dcAdmin;
use dcCore; use dcCore;
use dcPage; use dcPage;
use dcMenu;
use dcNsProcess; use dcNsProcess;
class Backend extends dcNsProcess class Backend extends dcNsProcess
@ -35,6 +36,7 @@ class Backend extends dcNsProcess
} }
// add backend sidebar menu icon // add backend sidebar menu icon
if ((dcCore::app()->menu[dcAdmin::MENU_PLUGINS] instanceof dcMenu)) {
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
My::name(), My::name(),
dcCore::app()->adminurl->get('admin.plugin.' . My::id()), dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
@ -44,6 +46,7 @@ class Backend extends dcNsProcess
My::PERMISSION, My::PERMISSION,
]), dcCore::app()->blog->id) ]), dcCore::app()->blog->id)
); );
}
return true; return true;
} }

View File

@ -79,7 +79,7 @@ class Frontend extends dcNsProcess
if (!$logs->isEmpty()) { if (!$logs->isEmpty()) {
$ids = []; $ids = [];
while ($logs->fetch()) { while ($logs->fetch()) {
$ids[] = (int) $logs->f('log_id'); $ids[] = is_numeric($logs->f('log_id')) ? (int) $logs->f('log_id') : 0;
} }
$logs = dcCore::app()->log->delLogs($ids); $logs = dcCore::app()->log->delLogs($ids);
} }

View File

@ -22,8 +22,10 @@ class Install extends dcNsProcess
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN') if (defined('DC_CONTEXT_ADMIN')) {
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version')); $version = dcCore::app()->plugins->moduleInfo(My::id(), 'version');
static::$init = is_string($version) ? dcCore::app()->newVersion(My::id(), $version) : true;
}
return static::$init; return static::$init;
} }

View File

@ -216,7 +216,7 @@ class Manage extends dcNsProcess
(new Submit(['save']))->value(__('Save')), (new Submit(['save']))->value(__('Save')),
(new Hidden(['action'], 'savesettings')), (new Hidden(['action'], 'savesettings')),
(new Hidden(['part'], $part)), (new Hidden(['part'], $part)),
(new Text('', dcCore::app()->formNonce())), dcCore::app()->formNonce(false),
]), ]),
])->render(); ])->render();
} }
@ -234,7 +234,7 @@ class Manage extends dcNsProcess
(new Submit(['save']))->value(__('Clear logs')), (new Submit(['save']))->value(__('Clear logs')),
(new Hidden(['action'], 'savelogins')), (new Hidden(['action'], 'savelogins')),
(new Hidden(['part'], $part)), (new Hidden(['part'], $part)),
(new Text('', dcCore::app()->formNonce())), dcCore::app()->formNonce(false),
]), ]),
])->render() . ])->render() .
@ -246,10 +246,12 @@ class Manage extends dcNsProcess
'</tr></thead<tbody>'; '</tr></thead<tbody>';
while ($logs->fetch()) { while ($logs->fetch()) {
$msg = is_string($logs->f('log_msg')) ? $logs->f('log_msg') : '';
$dt = is_string($logs->f('log_dt')) ? $logs->f('log_dt') : '';
echo echo
'<tr class="line">' . '<tr class="line">' .
'<td class="nowrap maximal">' . Html::escapeHTML($logs->f('log_msg')) . '</td>' . '<td class="nowrap maximal">' . Html::escapeHTML($msg) . '</td>' .
'<td class="nowrap count">' . Html::escapeHTML(Date::dt2str(__('%Y-%m-%d %H:%M'), $logs->f('log_dt'))) . '</td>' . '<td class="nowrap count">' . Html::escapeHTML(Date::dt2str(__('%Y-%m-%d %H:%M'), $dt)) . '</td>' .
'</tr>'; '</tr>';
} }
@ -299,7 +301,7 @@ class Manage extends dcNsProcess
(new Para())->items([ (new Para())->items([
(new Hidden(['action'], 'savepasswords')), (new Hidden(['action'], 'savepasswords')),
(new Hidden(['part'], $part)), (new Hidden(['part'], $part)),
(new Text('', dcCore::app()->formNonce())), dcCore::app()->formNonce(false),
]), ]),
])->render(); ])->render();
} }
@ -322,7 +324,7 @@ class Manage extends dcNsProcess
(new Submit(['add']))->value(__('Save')), (new Submit(['add']))->value(__('Save')),
(new Hidden(['action'], 'savepasswords')), (new Hidden(['action'], 'savepasswords')),
(new Hidden(['part'], $part)), (new Hidden(['part'], $part)),
(new Text('', dcCore::app()->formNonce())), dcCore::app()->formNonce(false),
]), ]),
])->render(); ])->render();
} }

View File

@ -98,7 +98,7 @@ class Utils
*/ */
public static function cryptMethod(): string public static function cryptMethod(): string
{ {
return is_null(dcCore::app()->blog) ? '' : (string) dcCore::app()->blog->settings->get(My::id())->get('crypt'); return !is_null(dcCore::app()->blog) && is_string(dcCore::app()->blog->settings->get(My::id())->get('crypt')) ? dcCore::app()->blog->settings->get(My::id())->get('crypt') : '';
} }
/** /**
@ -108,7 +108,7 @@ class Utils
*/ */
public static function httpMessage(): string public static function httpMessage(): string
{ {
return is_null(dcCore::app()->blog) ? '' : (string) dcCore::app()->blog->settings->get(My::id())->get('message'); return !is_null(dcCore::app()->blog) && is_string(dcCore::app()->blog->settings->get(My::id())->get('message')) ? dcCore::app()->blog->settings->get(My::id())->get('message') : '';
} }
/** /**