From da0c515d72b796bab07acf3b5b5b15f72fbf0592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Ho=CC=88=C3=9Fl?= Date: Sun, 17 Nov 2024 10:09:26 +0100 Subject: [PATCH 1/3] Use Phpstan 2 --- composer.json | 2 +- composer.lock | 156 +++++++++++++++++++++++++------------------------- 2 files changed, 79 insertions(+), 79 deletions(-) diff --git a/composer.json b/composer.json index dbf19443e..f5837febf 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,7 @@ "codeception/module-yii2": "^1.1.8", "codeception/lib-web": "dev-main#bc7c96a52e61cf636130caec77bd4668a2bc5969 as 1.0.6", "phpmd/phpmd": "^2.13.0", - "phpstan/phpstan": "^1.10.15", + "phpstan/phpstan": "^2.0", "squizlabs/php_codesniffer": "^3.7.2", "yiisoft/yii2-debug": "^2.1.23" }, diff --git a/composer.lock b/composer.lock index d64478902..805566222 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4766a046699135157aeeaf06f9e42ebf", + "content-hash": "58dbdc6898e3454c29be7cbf3a4b6387", "packages": [ { "name": "async-aws/core", @@ -1869,16 +1869,16 @@ }, { "name": "phpoffice/phpspreadsheet", - "version": "3.3.0", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", - "reference": "87ddd21eb0b6b7ad20a11d314348ef307475f547" + "reference": "eec07c20b51cc785295a6feef81ada7feda755e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/87ddd21eb0b6b7ad20a11d314348ef307475f547", - "reference": "87ddd21eb0b6b7ad20a11d314348ef307475f547", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/eec07c20b51cc785295a6feef81ada7feda755e7", + "reference": "eec07c20b51cc785295a6feef81ada7feda755e7", "shasum": "" }, "require": { @@ -1967,9 +1967,9 @@ ], "support": { "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", - "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/3.3.0" + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/3.4.0" }, - "time": "2024-09-29T07:04:07+00:00" + "time": "2024-11-10T10:10:41+00:00" }, { "name": "predis/predis", @@ -3275,16 +3275,16 @@ }, { "name": "symfony/http-client", - "version": "v5.4.45", + "version": "v5.4.47", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "54118c6340dc6831a00f10b296ea6e80592ec89d" + "reference": "3b643b83f87e1765d2e9b1e946bb56ee0b4b7bde" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/54118c6340dc6831a00f10b296ea6e80592ec89d", - "reference": "54118c6340dc6831a00f10b296ea6e80592ec89d", + "url": "https://api.github.com/repos/symfony/http-client/zipball/3b643b83f87e1765d2e9b1e946bb56ee0b4b7bde", + "reference": "3b643b83f87e1765d2e9b1e946bb56ee0b4b7bde", "shasum": "" }, "require": { @@ -3346,7 +3346,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v5.4.45" + "source": "https://github.com/symfony/http-client/tree/v5.4.47" }, "funding": [ { @@ -3362,7 +3362,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:11:13+00:00" + "time": "2024-11-13T12:18:12+00:00" }, { "name": "symfony/http-client-contracts", @@ -4468,16 +4468,16 @@ }, { "name": "symfony/property-info", - "version": "v5.4.45", + "version": "v5.4.47", "source": { "type": "git", "url": "https://github.com/symfony/property-info.git", - "reference": "cec75362b20263758c9c7af4c2f9af82614195ae" + "reference": "4d77ab22c57ef56a943e3f5769b5fe66be546094" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/property-info/zipball/cec75362b20263758c9c7af4c2f9af82614195ae", - "reference": "cec75362b20263758c9c7af4c2f9af82614195ae", + "url": "https://api.github.com/repos/symfony/property-info/zipball/4d77ab22c57ef56a943e3f5769b5fe66be546094", + "reference": "4d77ab22c57ef56a943e3f5769b5fe66be546094", "shasum": "" }, "require": { @@ -4494,7 +4494,7 @@ "require-dev": { "doctrine/annotations": "^1.10.4|^2", "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", - "phpstan/phpdoc-parser": "^1.0", + "phpstan/phpdoc-parser": "^1.0|^2.0", "symfony/cache": "^4.4|^5.0|^6.0", "symfony/dependency-injection": "^4.4|^5.0|^6.0", "symfony/serializer": "^4.4|^5.0|^6.0" @@ -4539,7 +4539,7 @@ "validator" ], "support": { - "source": "https://github.com/symfony/property-info/tree/v5.4.45" + "source": "https://github.com/symfony/property-info/tree/v5.4.47" }, "funding": [ { @@ -4555,7 +4555,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:11:13+00:00" + "time": "2024-11-07T14:13:13+00:00" }, { "name": "symfony/serializer", @@ -4745,16 +4745,16 @@ }, { "name": "symfony/string", - "version": "v5.4.45", + "version": "v5.4.47", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "7f6807add88b1e2635f3c6de5e1ace631ed7cad2" + "reference": "136ca7d72f72b599f2631aca474a4f8e26719799" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/7f6807add88b1e2635f3c6de5e1ace631ed7cad2", - "reference": "7f6807add88b1e2635f3c6de5e1ace631ed7cad2", + "url": "https://api.github.com/repos/symfony/string/zipball/136ca7d72f72b599f2631aca474a4f8e26719799", + "reference": "136ca7d72f72b599f2631aca474a4f8e26719799", "shasum": "" }, "require": { @@ -4811,7 +4811,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.45" + "source": "https://github.com/symfony/string/tree/v5.4.47" }, "funding": [ { @@ -4827,7 +4827,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:11:13+00:00" + "time": "2024-11-10T20:33:58+00:00" }, { "name": "symfony/translation-contracts", @@ -5665,7 +5665,7 @@ "type": "open_collective" } ], - "time": "2024-09-13T11:35:42+00:00" + "time": "2024-11-10T18:29:44+00:00" }, { "name": "codeception/lib-asserts", @@ -5797,7 +5797,7 @@ "require": { "ext-mbstring": "*", "guzzlehttp/psr7": "^2.0", - "php": "^8.0", + "php": "^8.1", "phpunit/phpunit": "^9.5 | ^10.0 | ^11.0", "symfony/css-selector": ">=4.4.24 <8.0" }, @@ -5832,7 +5832,7 @@ "issues": "https://github.com/Codeception/lib-web/issues", "source": "https://github.com/Codeception/lib-web/tree/main" }, - "time": "2024-07-31T17:00:47+00:00" + "time": "2024-11-11T07:36:20+00:00" }, { "name": "codeception/module-asserts", @@ -6120,16 +6120,16 @@ }, { "name": "composer/pcre", - "version": "3.3.1", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4" + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/63aaeac21d7e775ff9bc9d45021e1745c97521c4", - "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", "shasum": "" }, "require": { @@ -6139,8 +6139,8 @@ "phpstan/phpstan": "<1.11.10" }, "require-dev": { - "phpstan/phpstan": "^1.11.10", - "phpstan/phpstan-strict-rules": "^1.1", + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", "phpunit/phpunit": "^8 || ^9" }, "type": "library", @@ -6179,7 +6179,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.3.1" + "source": "https://github.com/composer/pcre/tree/3.3.2" }, "funding": [ { @@ -6195,7 +6195,7 @@ "type": "tidelift" } ], - "time": "2024-08-27T18:44:43+00:00" + "time": "2024-11-12T16:29:46+00:00" }, { "name": "composer/xdebug-handler", @@ -6265,16 +6265,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.12.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", "shasum": "" }, "require": { @@ -6313,7 +6313,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" }, "funding": [ { @@ -6321,7 +6321,7 @@ "type": "tidelift" } ], - "time": "2024-06-12T14:39:25+00:00" + "time": "2024-11-08T17:47:46+00:00" }, { "name": "nikic/php-parser", @@ -6713,20 +6713,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.7", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0" + "reference": "ab4e9b4415a5fc9e4d27f7fe16c8bc9d067dcd6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", - "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ab4e9b4415a5fc9e4d27f7fe16c8bc9d067dcd6d", + "reference": "ab4e9b4415a5fc9e4d27f7fe16c8bc9d067dcd6d", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -6767,7 +6767,7 @@ "type": "github" } ], - "time": "2024-10-18T11:12:07+00:00" + "time": "2024-11-11T15:43:04+00:00" }, { "name": "phpunit/php-code-coverage", @@ -8188,16 +8188,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.10.3", + "version": "3.11.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", "shasum": "" }, "require": { @@ -8264,7 +8264,7 @@ "type": "open_collective" } ], - "time": "2024-09-18T10:38:58+00:00" + "time": "2024-11-16T12:02:36+00:00" }, { "name": "symfony/browser-kit", @@ -8340,16 +8340,16 @@ }, { "name": "symfony/config", - "version": "v5.4.45", + "version": "v5.4.46", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "b9d94b0753da249439694c4a3847f57465b40d1d" + "reference": "977c88a02d7d3f16904a81907531b19666a08e78" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/b9d94b0753da249439694c4a3847f57465b40d1d", - "reference": "b9d94b0753da249439694c4a3847f57465b40d1d", + "url": "https://api.github.com/repos/symfony/config/zipball/977c88a02d7d3f16904a81907531b19666a08e78", + "reference": "977c88a02d7d3f16904a81907531b19666a08e78", "shasum": "" }, "require": { @@ -8399,7 +8399,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v5.4.45" + "source": "https://github.com/symfony/config/tree/v5.4.46" }, "funding": [ { @@ -8415,20 +8415,20 @@ "type": "tidelift" } ], - "time": "2024-10-22T13:05:35+00:00" + "time": "2024-10-30T07:58:02+00:00" }, { "name": "symfony/console", - "version": "v5.4.45", + "version": "v5.4.47", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "108d436c2af470858bdaba3257baab3a74172017" + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/108d436c2af470858bdaba3257baab3a74172017", - "reference": "108d436c2af470858bdaba3257baab3a74172017", + "url": "https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", "shasum": "" }, "require": { @@ -8498,7 +8498,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.45" + "source": "https://github.com/symfony/console/tree/v5.4.47" }, "funding": [ { @@ -8514,7 +8514,7 @@ "type": "tidelift" } ], - "time": "2024-10-08T07:27:17+00:00" + "time": "2024-11-06T11:30:55+00:00" }, { "name": "symfony/dependency-injection", @@ -8821,16 +8821,16 @@ }, { "name": "symfony/process", - "version": "v5.4.45", + "version": "v5.4.47", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "95f3f19d0f8f06e4253c66a0828ddb69f8b8ede4" + "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/95f3f19d0f8f06e4253c66a0828ddb69f8b8ede4", - "reference": "95f3f19d0f8f06e4253c66a0828ddb69f8b8ede4", + "url": "https://api.github.com/repos/symfony/process/zipball/5d1662fb32ebc94f17ddb8d635454a776066733d", + "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d", "shasum": "" }, "require": { @@ -8863,7 +8863,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.45" + "source": "https://github.com/symfony/process/tree/v5.4.47" }, "funding": [ { @@ -8879,20 +8879,20 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:11:13+00:00" + "time": "2024-11-06T11:36:42+00:00" }, { "name": "symfony/var-dumper", - "version": "v6.4.13", + "version": "v6.4.15", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "2acb151474ed8cb43624e3f41a0bf7c4c8ce4f41" + "reference": "38254d5a5ac2e61f2b52f9caf54e7aa3c9d36b80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/2acb151474ed8cb43624e3f41a0bf7c4c8ce4f41", - "reference": "2acb151474ed8cb43624e3f41a0bf7c4c8ce4f41", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/38254d5a5ac2e61f2b52f9caf54e7aa3c9d36b80", + "reference": "38254d5a5ac2e61f2b52f9caf54e7aa3c9d36b80", "shasum": "" }, "require": { @@ -8948,7 +8948,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.4.13" + "source": "https://github.com/symfony/var-dumper/tree/v6.4.15" }, "funding": [ { @@ -8964,7 +8964,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:18:03+00:00" + "time": "2024-11-08T15:28:48+00:00" }, { "name": "symfony/yaml", 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 2/3] 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 e2dbc5043..e4c1152ae 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 86563fcf6..dc3293da9 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 142abef51..b3bbe9550 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 2db4116d5..18ab7833d 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 82abaef64..805803500 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 .= '