From 0a9dc26e13a4e7e2611cf5ef837b3ebe0220219e Mon Sep 17 00:00:00 2001 From: franck Date: Fri, 27 Oct 2023 08:44:42 +0200 Subject: [PATCH] New release 5.1 --- _define.php | 2 +- src/BackendBehaviors.php | 8 ++++---- src/FrontendHelper.php | 4 +--- src/FrontendTemplate.php | 2 -- src/FrontendWidgets.php | 10 +++++----- src/Install.php | 6 +----- src/Manage.php | 6 +++--- src/Prepend.php | 19 +++++++++---------- 8 files changed, 24 insertions(+), 33 deletions(-) diff --git a/_define.php b/_define.php index 45b5881..2302dc3 100644 --- a/_define.php +++ b/_define.php @@ -14,7 +14,7 @@ 'a11yConfig', 'Implements Access42 accessibility configuration tool', 'Franck Paul, Biou and contributors', - '5.0', + '5.1', [ 'requires' => [['core', '2.28']], 'permissions' => 'My', diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index e76bcdc..901e6b7 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -88,8 +88,8 @@ public static function adminBeforeUserOptionsUpdate(): string $preferences->put('contrast', !empty($_POST['a11yc_contrast']), App::userWorkspace()::WS_BOOL); $preferences->put('image', !empty($_POST['a11yc_image']), App::userWorkspace()::WS_BOOL); } - } catch (Exception $e) { - App::error()->add($e->getMessage()); + } catch (Exception $exception) { + App::error()->add($exception->getMessage()); } return ''; @@ -134,7 +134,7 @@ public static function adminPreferencesForm(): string $icons[] = (new Radio(['a11yc_icon', 'a11yc_icon_' . $i], $a11yc_icon == $k)) ->value($k) ->label((new Label($v, Label::INSIDE_TEXT_AFTER))); - $i++; + ++$i; } $positions = []; @@ -143,7 +143,7 @@ public static function adminPreferencesForm(): string $positions[] = (new Radio(['a11yc_position', 'a11yc_position_' . $i], $a11yc_position == $k)) ->value($k) ->label((new Label($v, Label::INSIDE_TEXT_AFTER))); - $i++; + ++$i; } echo diff --git a/src/FrontendHelper.php b/src/FrontendHelper.php index f9678b9..837f6cc 100644 --- a/src/FrontendHelper.php +++ b/src/FrontendHelper.php @@ -25,8 +25,6 @@ class FrontendHelper * @param int $icon The icon * @param array $params The parameters * @param string $class The class - * - * @return string */ public static function render(?string $label, int $icon, array $params, string $class = ''): string { @@ -39,7 +37,7 @@ public static function render(?string $label, int $icon, array $params, string $ 'Contrast' => true, 'ImageReplacement' => true, ]; - $options = array_merge($options, $params); + $options = [...$options, ...$params]; $class .= match ($icon) { Prepend::ICON_WHEELCHAIR => ($class !== '' ? ' ' : '') . 'a11yc-wc', diff --git a/src/FrontendTemplate.php b/src/FrontendTemplate.php index 3ebd1dc..6b4a589 100644 --- a/src/FrontendTemplate.php +++ b/src/FrontendTemplate.php @@ -20,8 +20,6 @@ class FrontendTemplate { /** * @param array|\ArrayObject $attr The attribute - * - * @return string */ public static function tplAccessConfig(array|ArrayObject $attr): string { diff --git a/src/FrontendWidgets.php b/src/FrontendWidgets.php index 2984db3..5aaa263 100644 --- a/src/FrontendWidgets.php +++ b/src/FrontendWidgets.php @@ -30,11 +30,11 @@ public static function renderWidget(WidgetsElement $w): string } $params = [ - 'Font' => ($w->get('font') ? true : false), - 'LineSpacing' => ($w->get('linespacing') ? true : false), - 'Justification' => ($w->get('justification') ? true : false), - 'Contrast' => ($w->get('contrast') ? true : false), - 'ImageReplacement' => ($w->get('image') ? true : false), + 'Font' => ((bool) $w->get('font')), + 'LineSpacing' => ((bool) $w->get('linespacing')), + 'Justification' => ((bool) $w->get('justification')), + 'Contrast' => ((bool) $w->get('contrast')), + 'ImageReplacement' => ((bool) $w->get('image')), ]; return FrontendHelper::render($w->get('buttonname'), (int) $w->get('icon'), $params, 'widget'); diff --git a/src/Install.php b/src/Install.php index 56dddf0..eae582a 100644 --- a/src/Install.php +++ b/src/Install.php @@ -25,10 +25,6 @@ public static function init(): bool public static function process(): bool { - if (!self::status()) { - return false; - } - - return true; + return (bool) self::status(); } } diff --git a/src/Manage.php b/src/Manage.php index b872dbd..9cdbd63 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -48,7 +48,7 @@ public static function process(): bool return false; } - if (!empty($_POST)) { + if ($_POST !== []) { try { $settings = My::settings(); @@ -119,7 +119,7 @@ public static function render(): void $icons[] = (new Radio(['a11yc_icon', 'a11yc_icon_' . $i], $a11yc_icon == $k)) ->value($k) ->label((new Label($v, Label::INSIDE_TEXT_AFTER))); - $i++; + ++$i; } $positions = []; @@ -128,7 +128,7 @@ public static function render(): void $positions[] = (new Radio(['a11yc_position', 'a11yc_position_' . $i], $a11yc_position == $k)) ->value($k) ->label((new Label($v, Label::INSIDE_TEXT_AFTER))); - $i++; + ++$i; } $head = My::jsLoad('settings.js'); diff --git a/src/Prepend.php b/src/Prepend.php index 85bf752..5bb5348 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -19,13 +19,16 @@ class Prepend extends Process { // Constants for position (public/admin) - public const IN_TOP = 0; - public const IN_BOTTOM = 1; + final public const IN_TOP = 0; + + final public const IN_BOTTOM = 1; // Constants for icon (public/admin) - public const ICON_NONE = 0; - public const ICON_WHEELCHAIR = 1; - public const ICON_VISUALDEFICIENCY = 2; + final public const ICON_NONE = 0; + + final public const ICON_WHEELCHAIR = 1; + + final public const ICON_VISUALDEFICIENCY = 2; public static function init(): bool { @@ -34,10 +37,6 @@ public static function init(): bool public static function process(): bool { - if (!self::status()) { - return false; - } - - return true; + return (bool) self::status(); } }