From 75e421aec2d38cf21b3e47edf6a5eef1812c4b16 Mon Sep 17 00:00:00 2001 From: Bibi Date: Tue, 3 Oct 2023 20:19:26 +0200 Subject: [PATCH] Updated psalm configuration. --- psalm.xml | 22 ++++------------------ src/Chart/AbstractHighchart.php | 2 -- src/Chart/MonthChart.php | 2 -- src/Chart/StateChart.php | 2 -- src/Faker/CustomCompany.php | 5 +++++ src/Model/TaskComputeQuery.php | 5 +---- src/Twig/HighlightExtension.php | 4 ++-- src/Utils/StringUtils.php | 2 +- src/Validator/Captcha.php | 4 ---- src/Validator/Password.php | 4 ---- src/Validator/Recaptcha.php | 4 ---- src/Validator/Strength.php | 4 ---- 12 files changed, 13 insertions(+), 47 deletions(-) diff --git a/psalm.xml b/psalm.xml index 089c5db39..1d87db939 100644 --- a/psalm.xml +++ b/psalm.xml @@ -37,12 +37,6 @@ - - - - - - @@ -57,14 +51,6 @@ - - - - - - - - @@ -100,12 +86,12 @@ - + - - + + - + diff --git a/src/Chart/AbstractHighchart.php b/src/Chart/AbstractHighchart.php index 9b7c0237f..ab3afe5fd 100644 --- a/src/Chart/AbstractHighchart.php +++ b/src/Chart/AbstractHighchart.php @@ -24,8 +24,6 @@ /** * Extends the Highchart with method shortcuts. - * - * @psalm-suppress PropertyNotSetInConstructor */ class AbstractHighchart extends Highchart implements ServiceSubscriberInterface { diff --git a/src/Chart/MonthChart.php b/src/Chart/MonthChart.php index 6c65e1b41..c5f9942f2 100644 --- a/src/Chart/MonthChart.php +++ b/src/Chart/MonthChart.php @@ -20,8 +20,6 @@ /** * Chart to display calculations by month. * - * @psalm-suppress PropertyNotSetInConstructor - * * @psalm-import-type CalculationByMonthType from CalculationRepository */ class MonthChart extends AbstractHighchart diff --git a/src/Chart/StateChart.php b/src/Chart/StateChart.php index ddd23d706..cd03da381 100644 --- a/src/Chart/StateChart.php +++ b/src/Chart/StateChart.php @@ -22,8 +22,6 @@ * Chart to display calculations by state. * * @psalm-import-type QueryCalculationType from CalculationStateRepository - * - * @psalm-suppress PropertyNotSetInConstructor */ class StateChart extends AbstractHighchart { diff --git a/src/Faker/CustomCompany.php b/src/Faker/CustomCompany.php index 1711e2978..9667b6ad2 100644 --- a/src/Faker/CustomCompany.php +++ b/src/Faker/CustomCompany.php @@ -19,6 +19,11 @@ */ class CustomCompany extends \Faker\Provider\fr_CH\Company { + /** + * @psalm-var mixed + * + * @phpstan-var string[] + */ protected static $formats = [ '{{lastName}} {{companySuffix}}', '{{lastName}} {{firstName}} {{companySuffix}}', diff --git a/src/Model/TaskComputeQuery.php b/src/Model/TaskComputeQuery.php index 6af113866..1f678dc02 100644 --- a/src/Model/TaskComputeQuery.php +++ b/src/Model/TaskComputeQuery.php @@ -74,11 +74,8 @@ public function setQuantity(float $quantity): self return $this; } - /** - * @psalm-suppress MixedArgumentTypeCoercion - */ private function updateItems(): void { - $this->items = $this->task->getItems()->map(static fn (TaskItem $item) => (int) $item->getId())->toArray(); + $this->items = $this->task->getItems()->map(static fn (TaskItem $item): int => (int) $item->getId())->toArray(); } } diff --git a/src/Twig/HighlightExtension.php b/src/Twig/HighlightExtension.php index 936417ab7..68946a024 100644 --- a/src/Twig/HighlightExtension.php +++ b/src/Twig/HighlightExtension.php @@ -26,7 +26,7 @@ class HighlightExtension extends AbstractExtension { /** - * @const array + * @const array */ private const PHP_PATTERNS = [ '/title="(.*?)"/i' => '', @@ -84,7 +84,7 @@ private function exportPhp(Environment $env, mixed $variable, string $id = ''): if (!\is_string($content)) { return null; } - $content = StringUtils::pregReplace(self::PHP_PATTERNS, $content); // @phpstan-ignore-line + $content = StringUtils::pregReplace(self::PHP_PATTERNS, $content); if ('' !== $id) { $content = (string) \preg_replace('/highlight-php-\d+/', $id, $content); } diff --git a/src/Utils/StringUtils.php b/src/Utils/StringUtils.php index e8a0e50eb..87c065a79 100644 --- a/src/Utils/StringUtils.php +++ b/src/Utils/StringUtils.php @@ -215,7 +215,7 @@ public static function isString(?string $str): bool * * @phpstan-return ($subject is string ? string : string[]) * - * @psalm-param array $values + * @psalm-param array $values */ public static function pregReplace(array $values, string|array $subject): string|array { diff --git a/src/Validator/Captcha.php b/src/Validator/Captcha.php index 5811b1ac2..bbbe6abfe 100644 --- a/src/Validator/Captcha.php +++ b/src/Validator/Captcha.php @@ -16,10 +16,6 @@ /** * Captcha contraint. - * - * @Annotation - * - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) */ #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Captcha extends Constraint diff --git a/src/Validator/Password.php b/src/Validator/Password.php index 6a56d49bc..e957af614 100644 --- a/src/Validator/Password.php +++ b/src/Validator/Password.php @@ -16,10 +16,6 @@ /** * Password constraint. - * - * @Annotation - * - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) */ #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Password extends Constraint diff --git a/src/Validator/Recaptcha.php b/src/Validator/Recaptcha.php index 066e6b9c4..71c0553cd 100644 --- a/src/Validator/Recaptcha.php +++ b/src/Validator/Recaptcha.php @@ -16,10 +16,6 @@ /** * Google reCaptcha contraint. - * - * @Annotation - * - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) */ #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Recaptcha extends Constraint diff --git a/src/Validator/Strength.php b/src/Validator/Strength.php index f8cf545e4..bbddbba3a 100644 --- a/src/Validator/Strength.php +++ b/src/Validator/Strength.php @@ -18,10 +18,6 @@ /** * Strength constraint. - * - * @Annotation - * - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) */ #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Strength extends Constraint