aboutsummaryrefslogtreecommitdiff
path: root/cli/i18n
diff options
context:
space:
mode:
Diffstat (limited to 'cli/i18n')
-rw-r--r--cli/i18n/I18nCompletionValidator.php11
-rw-r--r--cli/i18n/I18nData.php11
-rw-r--r--cli/i18n/I18nUsageValidator.php11
-rw-r--r--cli/i18n/I18nValue.php4
4 files changed, 13 insertions, 24 deletions
diff --git a/cli/i18n/I18nCompletionValidator.php b/cli/i18n/I18nCompletionValidator.php
index 2a42dc13f..28f8abed8 100644
--- a/cli/i18n/I18nCompletionValidator.php
+++ b/cli/i18n/I18nCompletionValidator.php
@@ -5,10 +5,6 @@ require_once __DIR__ . '/I18nValidatorInterface.php';
class I18nCompletionValidator implements I18nValidatorInterface {
- /** @var array<string,array<string,I18nValue>> */
- private array $reference;
- /** @var array<string,array<string,I18nValue>> */
- private array $language;
private int $totalEntries = 0;
private int $passEntries = 0;
private string $result = '';
@@ -17,9 +13,10 @@ class I18nCompletionValidator implements I18nValidatorInterface {
* @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 __construct(
+ private readonly array $reference,
+ private array $language,
+ ) {
}
#[\Override]
diff --git a/cli/i18n/I18nData.php b/cli/i18n/I18nData.php
index 6d5730a08..6f841e947 100644
--- a/cli/i18n/I18nData.php
+++ b/cli/i18n/I18nData.php
@@ -5,13 +5,8 @@ class I18nData {
public const REFERENCE_LANGUAGE = 'en';
- /** @var array<string,array<string,array<string,I18nValue>>> */
- private array $data;
-
/** @param array<string,array<string,array<string,I18nValue>>> $data */
- public function __construct(array $data) {
- $this->data = $data;
-
+ public function __construct(private array $data) {
$this->addMissingKeysFromReference();
$this->removeExtraKeysFromOtherLanguages();
$this->processValueStates();
@@ -144,7 +139,7 @@ class I18nData {
$keys = array_keys($this->data[static::REFERENCE_LANGUAGE][$this->getFilenamePrefix($key)]);
$parent = $this->getParentKey($key);
- return array_values(array_filter($keys, static fn(string $element) => false !== strpos($element, $parent)));
+ return array_values(array_filter($keys, static fn(string $element) => str_contains($element, $parent)));
}
/**
@@ -185,7 +180,7 @@ class I18nData {
if ($element === $key) {
return false;
}
- return false !== strpos($element, $key);
+ return str_contains($element, $key);
}));
return count($children) !== 0;
diff --git a/cli/i18n/I18nUsageValidator.php b/cli/i18n/I18nUsageValidator.php
index dd514236b..89c88d222 100644
--- a/cli/i18n/I18nUsageValidator.php
+++ b/cli/i18n/I18nUsageValidator.php
@@ -5,10 +5,6 @@ require_once __DIR__ . '/I18nValidatorInterface.php';
class I18nUsageValidator implements I18nValidatorInterface {
- /** @var array<string> */
- private array $code;
- /** @var array<string,array<string,I18nValue>> */
- private array $reference;
private int $totalEntries = 0;
private int $failedEntries = 0;
private string $result = '';
@@ -17,9 +13,10 @@ class I18nUsageValidator implements I18nValidatorInterface {
* @param array<string,array<string,I18nValue>> $reference
* @param array<string> $code
*/
- public function __construct(array $reference, array $code) {
- $this->code = $code;
- $this->reference = $reference;
+ public function __construct(
+ private readonly array $reference,
+ private readonly array $code,
+ ) {
}
#[\Override]
diff --git a/cli/i18n/I18nValue.php b/cli/i18n/I18nValue.php
index aa2a670e1..ba6465062 100644
--- a/cli/i18n/I18nValue.php
+++ b/cli/i18n/I18nValue.php
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);
-class I18nValue {
+class I18nValue implements \Stringable {
private const STATE_DIRTY = 'dirty';
public const STATE_IGNORE = 'ignore';
private const STATE_TODO = 'todo';
@@ -11,7 +11,7 @@ class I18nValue {
self::STATE_TODO,
];
- private string $value;
+ private readonly string $value;
private ?string $state = null;
/** @param I18nValue|string $data */