aboutsummaryrefslogtreecommitdiff
path: root/cli/i18n/I18nUsageValidator.php
diff options
context:
space:
mode:
Diffstat (limited to 'cli/i18n/I18nUsageValidator.php')
-rw-r--r--cli/i18n/I18nUsageValidator.php17
1 files changed, 13 insertions, 4 deletions
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++;