From 11796eb948d43caa1c683688191d8e36411a18b4 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Wed, 21 Dec 2022 15:51:43 +0100 Subject: [PATCH] code review --- _admin.php | 2 +- _config.php | 2 +- _install.php | 2 +- _prepend.php | 2 +- _uninstall.php | 2 +- inc/Install.php | 1 + inc/Manage.php | 10 +++++----- inc/Prepend.php | 2 +- inc/core/Core.php | 16 ++++++++-------- inc/module/po2php.php | 17 +++++++---------- index.php | 2 +- 11 files changed, 28 insertions(+), 30 deletions(-) diff --git a/_admin.php b/_admin.php index 11af807..ab7f47e 100644 --- a/_admin.php +++ b/_admin.php @@ -5,7 +5,7 @@ * @package Dotclear * @subpackage Plugin * - * @author Jean-Christian Denis + * @author Jean-Christian Denis and contributors * * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html diff --git a/_config.php b/_config.php index d8858ba..fdad8b7 100644 --- a/_config.php +++ b/_config.php @@ -5,7 +5,7 @@ * @package Dotclear * @subpackage Plugin * - * @author Jean-Christian Denis + * @author Jean-Christian Denis and contributors * * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html diff --git a/_install.php b/_install.php index 2b34453..395c677 100644 --- a/_install.php +++ b/_install.php @@ -5,7 +5,7 @@ * @package Dotclear * @subpackage Plugin * - * @author Jean-Christian Denis + * @author Jean-Christian Denis and contributors * * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html diff --git a/_prepend.php b/_prepend.php index 6137750..f5fd5d9 100644 --- a/_prepend.php +++ b/_prepend.php @@ -5,7 +5,7 @@ * @package Dotclear * @subpackage Plugin * - * @author Jean-Christian Denis + * @author Jean-Christian Denis and contributors * * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html diff --git a/_uninstall.php b/_uninstall.php index 77ef664..5b5ccea 100644 --- a/_uninstall.php +++ b/_uninstall.php @@ -5,7 +5,7 @@ * @package Dotclear * @subpackage Plugin * - * @author Jean-Christian Denis + * @author Jean-Christian Denis and contributors * * @copyright Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html diff --git a/inc/Install.php b/inc/Install.php index 31f5793..278593c 100644 --- a/inc/Install.php +++ b/inc/Install.php @@ -55,6 +55,7 @@ class Install try { self::update_0_8_0(); self::putSettings(); + return true; } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); diff --git a/inc/Manage.php b/inc/Manage.php index c6b7645..6d6d67c 100644 --- a/inc/Manage.php +++ b/inc/Manage.php @@ -36,16 +36,16 @@ use Exception; */ class Manage { - /** @var improve $improve improve core instance */ + /** @var Core $improve improve core instance */ private static $improve = null; /** @var string $type Current module(s) type */ private static $type = 'plugin'; /** @var string $module Current module id */ private static $module = '-'; - /** @var action|null $action Current action module */ + /** @var Action|null $action Current action module */ private static $action = null; - private static $init = false; + private static $init = false; public static function init(): bool { @@ -56,7 +56,7 @@ class Manage self::$type = self::getType(); self::$module = self::getModule(); self::$action = self::getAction(); - self::$init = true; + self::$init = true; } return self::$init; @@ -77,7 +77,7 @@ class Manage return $module; } - private static function getAction(): ?action + private static function getAction(): ?Action { return empty($_REQUEST['config']) ? null : self::$improve->module($_REQUEST['config']); } diff --git a/inc/Prepend.php b/inc/Prepend.php index 801afb5..8eb637a 100644 --- a/inc/Prepend.php +++ b/inc/Prepend.php @@ -21,7 +21,7 @@ use Clearbricks; * * Manage autoload and some action module helpers. */ -class prepend +class Prepend { private static $init = false; diff --git a/inc/core/Core.php b/inc/core/Core.php index 46d3ec7..63d8193 100644 --- a/inc/core/Core.php +++ b/inc/core/Core.php @@ -36,7 +36,7 @@ class Core 'php', 'xml', 'js', 'css', 'csv', 'html', 'htm', 'txt', 'md', 'po', ]; - /** @var array $actions Loaded actions modules */ + /** @var array $actions Loaded actions modules */ private $actions = []; /** @var array $disabled Disabled actions modules */ @@ -60,7 +60,7 @@ class Core dcCore::app()->callBehavior('improveAddAction', $list); foreach ($list as $action) { - if ($action instanceof action && !isset($this->actions[$action->id()])) { + if ($action instanceof Action && !isset($this->actions[$action->id()])) { if (in_array($action->id(), $disabled)) { $this->disabled[$action->id()] = $action->name(); } else { @@ -154,9 +154,9 @@ class Core * * @param string $id Module id * - * @return action action instance + * @return Action action instance */ - public function module(string $id): ?action + public function module(string $id): ?Action { if (empty($id)) { return null; @@ -168,7 +168,7 @@ class Core /** * Get all loaded action modules * - * @return action[] action instance + * @return Action[] action instance */ public function modules(): array { @@ -338,12 +338,12 @@ class Core /** * Sort modules by priority then name * - * @param action $a ImproveAction instance - * @param action $b ImproveAction instance + * @param Action $a ImproveAction instance + * @param Action $b ImproveAction instance * * @return integer Is higher */ - private function sortModules(action $a, action $b): int + private function sortModules(Action $a, Action $b): int { if ($a->priority() == $b->priority()) { return strcasecmp($a->name(), $b->name()); diff --git a/inc/module/po2php.php b/inc/module/po2php.php index bae84fc..27c3b4d 100644 --- a/inc/module/po2php.php +++ b/inc/module/po2php.php @@ -29,16 +29,13 @@ class po2php extends Action { /** @var string License bloc */ private $license = <<