From 350edf398c55b472e19a3017de9b4d2d3420b9e4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 10 Apr 2024 15:33:43 +0200 Subject: PHP 8.3 #[\Override] (#6273) * PHP 8.3 #[\Override] https://php.watch/versions/8.3/override-attr With PHPStan `checkMissingOverrideMethodAttribute` https://phpstan.org/config-reference#checkmissingoverridemethodattribute And modified the call to phpstan-next on the model of https://github.com/FreshRSS/Extensions/pull/228 (more robust than the find method, which gave some strange errors) * Update extension example accordingly --- cli/i18n/I18nCompletionValidator.php | 3 +++ cli/i18n/I18nUsageValidator.php | 3 +++ cli/i18n/I18nValue.php | 1 + 3 files changed, 7 insertions(+) (limited to 'cli') diff --git a/cli/i18n/I18nCompletionValidator.php b/cli/i18n/I18nCompletionValidator.php index 4a8e54759..2a42dc13f 100644 --- a/cli/i18n/I18nCompletionValidator.php +++ b/cli/i18n/I18nCompletionValidator.php @@ -22,6 +22,7 @@ class I18nCompletionValidator implements I18nValidatorInterface { $this->language = $language; } + #[\Override] public function displayReport(): string { if ($this->passEntries > $this->totalEntries) { throw new \RuntimeException('The number of translated strings cannot be higher than the number of strings'); @@ -32,10 +33,12 @@ class I18nCompletionValidator implements I18nValidatorInterface { return sprintf('Translation is %5.1f%% complete.', $this->passEntries / $this->totalEntries * 100) . PHP_EOL; } + #[\Override] public function displayResult(): string { return $this->result; } + #[\Override] public function validate(): bool { foreach ($this->reference as $file => $data) { foreach ($data as $refKey => $refValue) { diff --git a/cli/i18n/I18nUsageValidator.php b/cli/i18n/I18nUsageValidator.php index 1267cd66d..dd514236b 100644 --- a/cli/i18n/I18nUsageValidator.php +++ b/cli/i18n/I18nUsageValidator.php @@ -22,6 +22,7 @@ class I18nUsageValidator implements I18nValidatorInterface { $this->reference = $reference; } + #[\Override] public function displayReport(): string { if ($this->failedEntries > $this->totalEntries) { throw new \RuntimeException('The number of unused strings cannot be higher than the number of strings'); @@ -32,10 +33,12 @@ class I18nUsageValidator implements I18nValidatorInterface { return sprintf('%5.1f%% of translation keys are unused.', $this->failedEntries / $this->totalEntries * 100) . PHP_EOL; } + #[\Override] public function displayResult(): string { return $this->result; } + #[\Override] public function validate(): bool { foreach ($this->reference as $file => $data) { foreach ($data as $key => $value) { diff --git a/cli/i18n/I18nValue.php b/cli/i18n/I18nValue.php index 88d0ea494..03e7676ae 100644 --- a/cli/i18n/I18nValue.php +++ b/cli/i18n/I18nValue.php @@ -66,6 +66,7 @@ class I18nValue { } } + #[\Override] public function __toString(): string { if ($this->state === null) { return $this->value; -- cgit v1.2.3