diff --git a/CHANGELOG.md b/CHANGELOG.md index ad2577a..33831cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +postExpired 2023.11.04 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Fix typo +* Code review (phpstan) + postExpired 2023.10.19 =========================================================== * Require Dotclear 2.28 diff --git a/_define.php b/_define.php index d102ca7..39cc647 100644 --- a/_define.php +++ b/_define.php @@ -18,7 +18,7 @@ $this->registerModule( 'Expired entries', 'Change entries options at a given date', 'Jean-Christian Denis and Contributors', - '2023.10.19', + '2023.11.04', [ 'requires' => [['core', '2.28']], 'permissions' => 'My', diff --git a/dcstore.xml b/dcstore.xml index e2ba0fc..5a124e8 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,10 +2,10 @@ Expired entries - 2023.10.19 + 2023.11.04 Jean-Christian Denis and Contributors Change entries options at a given date - https://git.dotclear.watch/JcDenis/postExpired/releases/download/v2023.10.19/plugin-postExpired.zip + https://git.dotclear.watch/JcDenis/postExpired/releases/download/v2023.11.04/plugin-postExpired.zip 2.28 https://git.dotclear.watch/JcDenis/postExpired/src/branch/master/README.md https://git.dotclear.watch/JcDenis/postExpired/issues diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index ed1b116..963e593 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -81,9 +81,9 @@ class BackendBehaviors /** * Add form to post sidebar. * - * @param ArrayObject $main_items Main items - * @param ArrayObject $sidebar_items Sidebar items - * @param ?MetaRecord $post Post record or null + * @param ArrayObject $main_items Main items + * @param ArrayObject $sidebar_items Sidebar items + * @param ?MetaRecord $post Post record or null */ public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void { @@ -138,8 +138,8 @@ class BackendBehaviors /** * Posts actions callback to add expired date. * - * @param ActionsPosts $pa ActionsPosts instance - * @param ArrayObject $post _POST actions + * @param ActionsPosts $pa ActionsPosts instance + * @param ArrayObject $post _POST actions */ public static function callbackAdd(ActionsPosts $pa, ArrayObject $post): void { @@ -161,8 +161,8 @@ class BackendBehaviors ) ) { foreach ($posts_ids as $post_id) { - self::delPostExpired($post_id); - self::setPostExpired($post_id, $post); + self::delPostExpired((int) $post_id); + self::setPostExpired((int) $post_id, $post); } Notices::addSuccessNotice(__('Expired date added.')); @@ -202,8 +202,8 @@ class BackendBehaviors /** * Posts actions callback to add expired date. * - * @param ActionsPosts $pa ActionsPosts instance - * @param ArrayObject $post _POST actions + * @param ActionsPosts $pa ActionsPosts instance + * @param ArrayObject $post _POST actions */ public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void { @@ -215,7 +215,7 @@ class BackendBehaviors // Delete expired date foreach ($posts_ids as $post_id) { - self::delPostExpired($post_id); + self::delPostExpired((int) $post_id); } Notices::addSuccessNotice(__('Expired date deleted.')); @@ -235,8 +235,8 @@ class BackendBehaviors /** * Save expired date. * - * @param int $post_id Post id - * @param ArrayObject $post _POST fields + * @param int $post_id Post id + * @param ArrayObject $post _POST fields */ private static function setPostExpired(int $post_id, ArrayObject $post): void { @@ -286,7 +286,8 @@ class BackendBehaviors * @param string $post_type Posts type * @param null|int $post_id Post ID * @param bool $render Render fileds to HTML - * @return array Array of object form fields + * + * @return array Array of object form fields */ private static function fieldsPostExpired(string $post_type, ?int $post_id = null, bool $render = true): array { @@ -346,13 +347,15 @@ class BackendBehaviors (new Checkbox('post_expired_password', !empty($post_expired['password'])))->value(1), (new Label(__('Change password'), Label::OUTSIDE_LABEL_AFTER))->for('post_expired_password')->class('classic'), (new Label(__('New password:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_newpassword'), - (new Input('post_expired_newpassword'))->size(65)->maxlenght(255)->class('maximal')->value(empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']), + (new Input('post_expired_newpassword'))->size(65)->maxlength(255)->class('maximal')->value(empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']), (new Note())->text(__('Leave empty to remove it'))->class('form-note'), ]); if ($render) { foreach ($fields as $k => $v) { - $fields[$k] = $v->render(); + if (!is_string($v)) { + $fields[$k] = $v->render(); + } } } @@ -364,7 +367,7 @@ class BackendBehaviors * * @param MetaRecord $categories Categories recordset * - * @return array Categorires combo + * @return array Categorires combo */ private static function categoriesCombo(MetaRecord $categories): array { @@ -394,7 +397,7 @@ class BackendBehaviors /** * Custom status combo. * - * @return array Status combo + * @return array Status combo */ private static function statusCombo(): array { @@ -409,7 +412,7 @@ class BackendBehaviors /** * Custom selection combo. * - * @return array Selection combo + * @return array Selection combo */ private static function selectedCombo(): array { @@ -423,7 +426,7 @@ class BackendBehaviors /** * Custom comment status combo. * - * @return array Comment status combo + * @return array Comment status combo */ private static function commentCombo(): array { @@ -437,7 +440,7 @@ class BackendBehaviors /** * Custom trackback status combo. * - * @return array Trackback status combo + * @return array Trackback status combo */ private static function trackbackCombo(): array { diff --git a/src/FrontendTemplate.php b/src/FrontendTemplate.php index ef52139..631454c 100644 --- a/src/FrontendTemplate.php +++ b/src/FrontendTemplate.php @@ -20,8 +20,8 @@ class FrontendTemplate /** * Template condition to check if there is an expired date. * - * @param ArrayObject $attr Block attributes - * @param string $content Block content + * @param ArrayObject $attr Block attributes + * @param string $content Block content * * @return string */ @@ -47,7 +47,7 @@ class FrontendTemplate /** * Template for expired date. * - * @param ArrayObject $attr Value attributes + * @param ArrayObject $attr Value attributes * * @return string */ @@ -73,7 +73,7 @@ class FrontendTemplate /** * Template for expired time. * - * @param ArrayObject $attr Value attributes + * @param ArrayObject $attr Value attributes * * @return string */ diff --git a/src/My.php b/src/My.php index 9329dc6..81a9072 100644 --- a/src/My.php +++ b/src/My.php @@ -24,7 +24,7 @@ class My extends MyPlugin * This is saved into post_meta as meta_id value, * so this must be less than 255 caracters. * - * @param array $in Array of options + * @param array $in Array of options * * @return string "Serialized" options */ @@ -43,14 +43,14 @@ class My extends MyPlugin * * @param string $in "Serialized" options * - * @return array Array of options + * @return array Array of options */ public static function decode(string $in): array { $out = []; foreach (explode(';', $in) as $v) { - $v = explode('|', $v); - $out[$v[0]] = $v[1]; + $v = explode('|', $v); + $out[(string) $v[0]] = (string) $v[1]; } return $out; diff --git a/src/RsExtPostExpired.php b/src/RsExtPostExpired.php index abbd586..2bfb430 100644 --- a/src/RsExtPostExpired.php +++ b/src/RsExtPostExpired.php @@ -17,7 +17,11 @@ use Dotclear\Schema\Extension\Post; */ class rsExtPostExpired extends Post { - /** @var array $memory Memory to prevent redondant call */ + /** + * Memory to prevent redondant call. + * + * @var array $memory + */ protected static array $memory = []; /** @@ -40,8 +44,8 @@ class rsExtPostExpired extends Post return ''; } - $v = My::decode($rs_date->f('meta_id')); - static::$memory[$rs->f('post_id')] = $v['date']; + $v = My::decode($rs_date->f('meta_id')); + static::$memory[(string) $rs->f('post_id')] = (string) $v['date']; } return static::$memory[$rs->f('post_id')];