From 0e70b0e0f018a127cb8543c8be5add3263fc8c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Ho=CC=88=C3=9Fl?= Date: Sun, 17 Nov 2024 10:18:30 +0100 Subject: [PATCH] Fix some issues reported by phpstan2 --- models/db/ConsultationUserGroup.php | 4 ++-- models/db/MotionSection.php | 3 +-- models/db/User.php | 1 - models/forms/AdminMotionFilterForm.php | 4 ++-- models/layoutHooks/StdHooks.php | 2 +- models/settings/JsonConfigTrait.php | 11 ++--------- plugins/ModuleBase.php | 1 - plugins/green_manager/Module.php | 3 --- 8 files changed, 8 insertions(+), 21 deletions(-) diff --git a/models/db/ConsultationUserGroup.php b/models/db/ConsultationUserGroup.php index e2dbc50435..e4c1152aed 100644 --- a/models/db/ConsultationUserGroup.php +++ b/models/db/ConsultationUserGroup.php @@ -138,8 +138,8 @@ public static function loadGroupsByIdForConsultation(Consultation $consultation, // Iterating over the userIds attached to a user group is faster than over the groupIds of a user, // as there are way more users, and we would need to perform more queries that way. // Note that this method should only be used for read-only operations, as the cache is not flushed yet. - /** @var null|int[][] */ - private static ?array $userIdCache = []; + /** @var int[][] */ + private static array $userIdCache = []; public function getUserIds(): array { diff --git a/models/db/MotionSection.php b/models/db/MotionSection.php index 86563fcf6f..dc3293da9f 100644 --- a/models/db/MotionSection.php +++ b/models/db/MotionSection.php @@ -144,9 +144,8 @@ public function getConsultation(): Consultation if ($motion) { return Consultation::findOne($motion->consultationId); } else { - /** @var Motion $motion */ - $section = ConsultationSettingsMotionSection::findOne($this->sectionId); /** @var ConsultationSettingsMotionSection $section */ + $section = ConsultationSettingsMotionSection::findOne($this->sectionId); return $section->motionType->getConsultation(); } } diff --git a/models/db/User.php b/models/db/User.php index 142abef515..b3bbe95506 100644 --- a/models/db/User.php +++ b/models/db/User.php @@ -313,7 +313,6 @@ public static function findIdentity($userId) * @return IdentityInterface the identity object that matches the given token. * Null should be returned if such an identity cannot be found * or the identity is not in an active state (disabled, deleted, etc.) - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public static function findIdentityByAccessToken($token, $type = null) { diff --git a/models/forms/AdminMotionFilterForm.php b/models/forms/AdminMotionFilterForm.php index 2db4116d56..18ab7833d6 100644 --- a/models/forms/AdminMotionFilterForm.php +++ b/models/forms/AdminMotionFilterForm.php @@ -617,7 +617,7 @@ public function getFilteredMotions(): array $matches = false; } - if ($this->status !== null && $this->status !== '' && $motion->status !== $this->status) { + if ($this->status !== null && $motion->status !== $this->status) { $matches = false; } @@ -756,7 +756,7 @@ public function getFilteredAmendments(array $filteredMotions): array $matches = false; } - if ($this->status !== null && $this->status !== "" && $amend->status !== $this->status) { + if ($this->status !== null && $amend->status !== $this->status) { $matches = false; } diff --git a/models/layoutHooks/StdHooks.php b/models/layoutHooks/StdHooks.php index 82abaef648..8058035001 100644 --- a/models/layoutHooks/StdHooks.php +++ b/models/layoutHooks/StdHooks.php @@ -85,7 +85,7 @@ public function breadcrumbs(string $before): string { $out = ''; $showBreadcrumbs = (!$this->consultation || !$this->consultation->site || $this->consultation->site->getSettings()->showBreadcrumbs); - if (is_array($this->layout->breadcrumbs) && $showBreadcrumbs) { + if (count($this->layout->breadcrumbs) > 0 && $showBreadcrumbs) { $out .= '