From 7b12eda8a53350a304ce75feea87418de7f1fd5d Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 4 Nov 2023 21:34:46 +0100 Subject: [PATCH] code review (phpstan) --- src/FrontendBehaviors.php | 16 ++++++++++++++-- src/Utils.php | 15 +++++++++++++++ src/Widgets.php | 10 +++++----- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/FrontendBehaviors.php b/src/FrontendBehaviors.php index cfeb7a4..572d0e0 100644 --- a/src/FrontendBehaviors.php +++ b/src/FrontendBehaviors.php @@ -20,6 +20,9 @@ use Dotclear\Core\Frontend\Ctx; */ class FrontendBehaviors { + /** + * @param ArrayObject $alias + */ public static function templateCustomSortByAlias(ArrayObject $alias): void { $alias['post'] = [ @@ -81,6 +84,11 @@ class FrontendBehaviors App::frontend()->context()->__set('saba_options', $options); } + /** + * @param ArrayObject $params + * + * @return array + */ public static function getPostsParams(ArrayObject $params): array { if (!isset($params['sql'])) { @@ -91,7 +99,7 @@ class FrontendBehaviors # retreive _GET $qs = $_SERVER['QUERY_STRING']; - $qs = preg_replace('#(^|/)page/([0-9]+)#', '', $qs); + $qs = (string) preg_replace('#(^|/)page/([0-9]+)#', '', $qs); parse_str($qs, $get); # search string @@ -189,7 +197,11 @@ class FrontendBehaviors return $options; } - # Ajouter la condition "ou" à la recherche + /** + * Ajouter la condition "ou" à la recherche. + * + * @param ArrayObject $p + */ public static function coreBlogBeforeGetPosts(ArrayObject $p): void { if (empty($p['search'])) { diff --git a/src/Utils.php b/src/Utils.php index 071d584..05db42a 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -15,6 +15,9 @@ use Dotclear\App; */ class Utils { + /** + * @return array + */ public static function getSabaDefaultPostsOptions(): array { return [ @@ -29,6 +32,9 @@ class Utils ]; } + /** + * @return array + */ public static function getSabaFormOptions(): array { return [ @@ -38,6 +44,9 @@ class Utils ]; } + /** + * @return array + */ public static function getSabaFormOrders(): array { return [ @@ -51,6 +60,9 @@ class Utils ]; } + /** + * @return array + */ public static function getSabaFormAges(): array { return [ @@ -62,6 +74,9 @@ class Utils ]; } + /** + * @return array + */ public static function getSabaFormTypes(): array { $know = [ diff --git a/src/Widgets.php b/src/Widgets.php index 84f9262..0f02638 100644 --- a/src/Widgets.php +++ b/src/Widgets.php @@ -110,7 +110,7 @@ class Widgets $ct .= '
  • '; + '/> ' . Html::escapeHTML((string) $k) . ''; } if (!empty($ct)) { $ct .= '
  • '; + '/> ' . Html::escapeHTML((string) $k) . ''; } if (!empty($ct)) { $res .= $w->renderTitle(__('Filter options')) . sprintf('
      %s
    ', $ct); @@ -147,7 +147,7 @@ class Widgets $ct .= '
  • '; + '/> ' . Html::escapeHTML((string) $k) . ''; } if (!empty($ct)) { $res .= $w->renderTitle(__('Filter by age')) . sprintf('
      %s
    ', $ct); @@ -166,7 +166,7 @@ class Widgets $ct .= '
  • '; + '/> ' . Html::escapeHTML((string) $k) . ''; } if (!empty($ct)) { $res .= $w->renderTitle(__('Filter by type')) . sprintf('
      %s
    ', $ct); @@ -186,7 +186,7 @@ class Widgets $ct .= '
  • '; + '/> ' . Html::escapeHTML((string) $rs->f('cat_title')) . ''; } if (!empty($ct)) { $res .= $w->renderTitle(__('Filter by category')) . sprintf('
      %s
    ', $ct);