diff options
| author | 2023-03-31 08:23:39 +0200 | |
|---|---|---|
| committer | 2023-03-31 08:23:39 +0200 | |
| commit | 288ed04ccc30b58373576dc3be811aee43e67034 (patch) | |
| tree | 27f4c571e04d64c97737416dfa2b8d65f481dfd8 /cli/i18n | |
| parent | c9d5fe2da12cbc3a071ebf9a518afe2789bb3d61 (diff) | |
PHPStan level 6 for all PDO and Exception classes (#5239)
* PHPStan level 6 for all PDO and Exception classes
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112
* Fix type
* Now also our remaining own librairies
* Motivation for a few more files
* A few more DAO classes
* Last interface
Diffstat (limited to 'cli/i18n')
| -rw-r--r-- | cli/i18n/I18nCompletionValidator.php | 17 | ||||
| -rw-r--r-- | cli/i18n/I18nUsageValidator.php | 17 | ||||
| -rw-r--r-- | cli/i18n/I18nValidatorInterface.php | 13 |
3 files changed, 29 insertions, 18 deletions
diff --git a/cli/i18n/I18nCompletionValidator.php b/cli/i18n/I18nCompletionValidator.php index 000629f8d..3903e18cd 100644 --- a/cli/i18n/I18nCompletionValidator.php +++ b/cli/i18n/I18nCompletionValidator.php @@ -4,18 +4,27 @@ require_once __DIR__ . '/I18nValidatorInterface.php'; class I18nCompletionValidator implements I18nValidatorInterface { + /** @var array<string,array<string,I18nValue>> */ private $reference; + /** @var array<string,array<string,I18nValue>> */ private $language; + /** @var int */ private $totalEntries = 0; + /** @var int */ private $passEntries = 0; + /** @var string */ private $result = ''; - public function __construct($reference, $language) { + /** + * @param array<string,array<string,I18nValue>> $reference + * @param array<string,array<string,I18nValue>> $language + */ + public function __construct(array $reference, array $language) { $this->reference = $reference; $this->language = $language; } - public function displayReport() { + 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'); } @@ -25,11 +34,11 @@ class I18nCompletionValidator implements I18nValidatorInterface { return sprintf('Translation is %5.1f%% complete.', $this->passEntries / $this->totalEntries * 100) . PHP_EOL; } - public function displayResult() { + public function displayResult(): string { return $this->result; } - public function validate() { + public function validate(): bool { foreach ($this->reference as $file => $data) { foreach ($data as $refKey => $refValue) { $this->totalEntries++; diff --git a/cli/i18n/I18nUsageValidator.php b/cli/i18n/I18nUsageValidator.php index 681e17326..f507fbac3 100644 --- a/cli/i18n/I18nUsageValidator.php +++ b/cli/i18n/I18nUsageValidator.php @@ -4,18 +4,27 @@ require_once __DIR__ . '/I18nValidatorInterface.php'; class I18nUsageValidator implements I18nValidatorInterface { + /** @var array<string> */ private $code; + /** @var array<string,array<string,string>> */ private $reference; + /** @var int */ private $totalEntries = 0; + /** @var int */ private $failedEntries = 0; + /** @var string */ private $result = ''; - public function __construct($reference, $code) { + /** + * @param array<string,array<string,string>> $reference + * @param array<string> $code + */ + public function __construct(array $reference, array $code) { $this->code = $code; $this->reference = $reference; } - public function displayReport() { + 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'); } @@ -25,11 +34,11 @@ class I18nUsageValidator implements I18nValidatorInterface { return sprintf('%5.1f%% of translation keys are unused.', $this->failedEntries / $this->totalEntries * 100) . PHP_EOL; } - public function displayResult() { + public function displayResult(): string { return $this->result; } - public function validate() { + public function validate(): bool { foreach ($this->reference as $file => $data) { foreach ($data as $key => $value) { $this->totalEntries++; diff --git a/cli/i18n/I18nValidatorInterface.php b/cli/i18n/I18nValidatorInterface.php index d5681912b..e6f5f7cdd 100644 --- a/cli/i18n/I18nValidatorInterface.php +++ b/cli/i18n/I18nValidatorInterface.php @@ -5,21 +5,14 @@ interface I18nValidatorInterface { /** * Display the validation result. * Empty if there are no errors. - * - * @return array */ - public function displayResult(); + public function displayResult(): string; - /** - * @return bool - */ - public function validate(); + public function validate(): bool; /** * Display the validation report. - * - * @return string */ - public function displayReport(); + public function displayReport(): string; } |
