From d9101e83bd3ce66d8ee18583f055ee0ad85978b0 Mon Sep 17 00:00:00 2001 From: Visman Date: Sun, 19 Dec 2021 15:31:27 +0700 Subject: [PATCH] Strict type checking --- app/Controllers/Routing.php | 2 +- app/Core/Config.php | 4 ++-- app/Core/Parser.php | 4 ++-- app/Models/Pages/Post.php | 2 +- app/Models/Pages/PostValidatorTrait.php | 4 ++-- app/Models/Pages/Profile/Edit.php | 2 +- app/Models/Subscription/Subscription.php | 4 ++-- app/Models/User/ChangeGroup.php | 2 +- app/Models/Validators/NoURL.php | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/Controllers/Routing.php b/app/Controllers/Routing.php index 4005e0de..fe7d546c 100644 --- a/app/Controllers/Routing.php +++ b/app/Controllers/Routing.php @@ -740,7 +740,7 @@ class Routing case $r::NOT_FOUND: // ... 404 Not Found if ( - '1' != $user->g_read_board + 1 !== $user->g_read_board && $user->isGuest ) { $page = $this->c->Redirect->page('Login'); diff --git a/app/Core/Config.php b/app/Core/Config.php index df096b7f..1ae655c0 100644 --- a/app/Core/Config.php +++ b/app/Core/Config.php @@ -186,7 +186,7 @@ class Config } else { $result[] = $value; } - } elseif (null != $key) { + } elseif (null !== $key) { throw new ForkException('Config array cannot be parsed'); } @@ -267,7 +267,7 @@ class Config $value = null; $key = null; - } elseif (null != $key) { + } elseif (null !== $key) { throw new ForkException('Config array cannot be parsed'); } diff --git a/app/Core/Parser.php b/app/Core/Parser.php index 4d03316b..880d85e2 100644 --- a/app/Core/Parser.php +++ b/app/Core/Parser.php @@ -59,8 +59,8 @@ class Parser extends Parserus } $this->setAttr('baseUrl', $this->c->BASE_URL); - $this->setAttr('showImg', '0' != $this->c->user->show_img); - $this->setAttr('showImgSign', '0' != $this->c->user->show_img_sig); + $this->setAttr('showImg', 1 === $this->c->user->show_img); + $this->setAttr('showImgSign', 1 === $this->c->user->show_img_sig); } /** diff --git a/app/Models/Pages/Post.php b/app/Models/Pages/Post.php index 1be4f7bf..0d578302 100644 --- a/app/Models/Pages/Post.php +++ b/app/Models/Pages/Post.php @@ -291,7 +291,7 @@ class Post extends Page $this->user->num_posts = $this->user->num_posts + 1; if ( - 0 != $this->user->g_promote_next_group + $this->user->g_promote_next_group > 0 && $this->user->num_posts >= $this->user->g_promote_min_posts ) { $this->user->group_id = $this->user->g_promote_next_group; diff --git a/app/Models/Pages/PostValidatorTrait.php b/app/Models/Pages/PostValidatorTrait.php index 271aa046..70d57141 100644 --- a/app/Models/Pages/PostValidatorTrait.php +++ b/app/Models/Pages/PostValidatorTrait.php @@ -27,7 +27,7 @@ trait PostValidatorTrait // заголовок темы только заглавными буквами } elseif ( ! $executive - && 1 != $this->c->config->b_subject_all_caps + && 1 !== $this->c->config->b_subject_all_caps && \preg_match('%\p{Lu}%u', $subject) && ! \preg_match('%\p{Ll}%u', $subject) ) { @@ -62,7 +62,7 @@ trait PostValidatorTrait if ( true === $prepare && ! $executive - && 1 != $this->c->config->b_message_all_caps + && 1 !== $this->c->config->b_message_all_caps ) { $text = $this->c->Parser->getText(); diff --git a/app/Models/Pages/Profile/Edit.php b/app/Models/Pages/Profile/Edit.php index 5c8ac0c9..e228c003 100644 --- a/app/Models/Pages/Profile/Edit.php +++ b/app/Models/Pages/Profile/Edit.php @@ -194,7 +194,7 @@ class Edit extends Profile if ( true === $prepare && ! $this->user->isAdmin - && 1 != $this->c->config->b_sig_all_caps + && 1 !== $this->c->config->b_sig_all_caps ) { $text = $this->c->Parser->getText(); diff --git a/app/Models/Subscription/Subscription.php b/app/Models/Subscription/Subscription.php index 14b63296..014f6a93 100644 --- a/app/Models/Subscription/Subscription.php +++ b/app/Models/Subscription/Subscription.php @@ -217,7 +217,7 @@ class Subscription extends Model if (self::FORUMS_DATA & $type) { if ( - 1 != $this->c->config->b_forum_subscriptions + 1 !== $this->c->config->b_forum_subscriptions || $model->isGuest ) { $result[self::FORUMS_DATA] = null; @@ -232,7 +232,7 @@ class Subscription extends Model if (self::TOPICS_DATA & $type) { if ( - 1 != $this->c->config->b_topic_subscriptions + 1 !== $this->c->config->b_topic_subscriptions || $model->isGuest ) { $result[self::TOPICS_DATA] = null; diff --git a/app/Models/User/ChangeGroup.php b/app/Models/User/ChangeGroup.php index 78ea5602..a9a95e17 100644 --- a/app/Models/User/ChangeGroup.php +++ b/app/Models/User/ChangeGroup.php @@ -41,7 +41,7 @@ class ChangeGroup extends Action } if ( - 1 != $newGroup->g_moderator + 1 !== $newGroup->g_moderator && $user->isAdmMod ) { $moderators[$user->id] = $user; diff --git a/app/Models/Validators/NoURL.php b/app/Models/Validators/NoURL.php index 02f97254..16e82aa2 100644 --- a/app/Models/Validators/NoURL.php +++ b/app/Models/Validators/NoURL.php @@ -29,7 +29,7 @@ class NoURL extends RulesValidator if ( ( ! empty($flag) - || '1' != $this->c->user->g_post_links + || 1 !== $this->c->user->g_post_links ) && \preg_match('%https?://|www\.%i', $value) ) {