Skip to content

Commit 8f84619

Browse files
committed
style: apply fixes from mago
1 parent 181e55e commit 8f84619

33 files changed

+464
-219
lines changed

packages/i18n/bin/plural-rules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ private function parseRule(string $rule): string
203203
// Extract the rule condition (before @integer/@decimal examples)
204204
$rulePart = trim(explode('@', $rule)[0]);
205205

206-
if (empty($rulePart)) {
206+
if (! $rulePart) {
207207
return '';
208208
}
209209

@@ -299,7 +299,7 @@ private function parseValueCondition(string $varExpression, string $operator, st
299299
}
300300
}
301301

302-
if (empty($conditions)) {
302+
if (! $conditions) {
303303
return 'false';
304304
}
305305

packages/i18n/src/Translator/GenericTranslator.php renamed to packages/i18n/src/GenericTranslator.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<?php
22

3-
namespace Tempest\Internationalization\Translator;
3+
namespace Tempest\Internationalization;
44

5-
use Tempest\Core\ExceptionReporter;
65
use Tempest\EventBus\EventBus;
76
use Tempest\Internationalization\Catalog\Catalog;
87
use Tempest\Internationalization\InternationalizationConfig;
98
use Tempest\Internationalization\MessageFormat\Formatter\MessageFormatter;
109
use Tempest\Support\Language\Locale;
1110

12-
final class GenericTranslator implements Translator
11+
final readonly class GenericTranslator implements Translator
1312
{
1413
public function __construct(
15-
private readonly InternationalizationConfig $config,
16-
private readonly Catalog $catalog,
17-
private readonly MessageFormatter $formatter,
18-
private readonly ?EventBus $eventBus = null,
14+
private InternationalizationConfig $config,
15+
private Catalog $catalog,
16+
private MessageFormatter $formatter,
17+
private ?EventBus $eventBus = null,
1918
) {}
2019

2120
public function translateForLocale(Locale $locale, string $key, mixed ...$arguments): string

packages/i18n/src/MessageFormat/Formatter/FormattedValue.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Tempest\Internationalization\MessageFormat\Formatter;
44

5-
final class FormattedValue
5+
final readonly class FormattedValue
66
{
77
public function __construct(
8-
public readonly mixed $value,
9-
public readonly string $formatted,
8+
public mixed $value,
9+
public string $formatted,
1010
) {}
1111
}

packages/i18n/src/MessageFormat/Formatter/MessageFormatter.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Tempest\Internationalization\MessageFormat\Formatter;
44

55
use Exception;
6-
use Tempest\Internationalization\InternationalizationConfig;
76
use Tempest\Internationalization\MessageFormat\Parser\Node\ComplexBody\ComplexBody;
87
use Tempest\Internationalization\MessageFormat\Parser\Node\ComplexBody\Matcher;
98
use Tempest\Internationalization\MessageFormat\Parser\Node\ComplexBody\SimplePatternBody;
@@ -242,7 +241,7 @@ private function evaluateExpression(Expression $expression): FormattedValue
242241
$variableName = $expression->variable->name->name;
243242

244243
if (! array_key_exists($variableName, $this->variables)) {
245-
throw new FormattingException("Variable `$variableName` not found");
244+
throw new FormattingException("Variable `{$variableName}` not found");
246245
}
247246

248247
$value = $this->variables[$variableName];
@@ -304,9 +303,9 @@ private function formatMarkup(Markup $markup): string
304303
$tag = (string) $markup->identifier;
305304

306305
return match ($markup->type) {
307-
MarkupType::OPEN => "<$tag>",
308-
MarkupType::CLOSE => "</$tag>",
309-
MarkupType::STANDALONE => "<$tag/>",
306+
MarkupType::OPEN => "<{$tag}>",
307+
MarkupType::CLOSE => "</{$tag}>",
308+
MarkupType::STANDALONE => "<{$tag}/>",
310309
default => '',
311310
};
312311
}

packages/i18n/src/MessageFormat/Parser/Node/ComplexBody/Matcher.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
use Tempest\Internationalization\MessageFormat\Parser\Node\Pattern\Pattern;
66

7-
final class Matcher implements ComplexBody
7+
final readonly class Matcher implements ComplexBody
88
{
99
/**
1010
* @param Variable[] $selectors
1111
* @param Variant[] $variants
1212
*/
1313
public function __construct(
14-
public readonly array $selectors,
15-
public readonly array $variants,
14+
public array $selectors,
15+
public array $variants,
1616
) {}
1717

1818
public function getPattern(): Pattern

packages/i18n/src/MessageFormat/Parser/Node/ComplexBody/SimplePatternBody.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
use Tempest\Internationalization\MessageFormat\Parser\Node\Pattern\Pattern;
66

7-
final class SimplePatternBody implements ComplexBody
7+
final readonly class SimplePatternBody implements ComplexBody
88
{
99
public function __construct(
10-
public readonly Pattern $pattern,
10+
public Pattern $pattern,
1111
) {}
1212

1313
public function getPattern(): Pattern

packages/i18n/src/MessageFormat/Parser/Node/ComplexBody/Variant.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
use Tempest\Internationalization\MessageFormat\Parser\Node\Node;
66
use Tempest\Internationalization\MessageFormat\Parser\Node\Pattern\QuotedPattern;
77

8-
final class Variant implements Node
8+
final readonly class Variant implements Node
99
{
1010
/**
1111
* @param Key[] $keys
1212
*/
1313
public function __construct(
14-
public readonly array $keys,
15-
public readonly QuotedPattern $pattern,
14+
public array $keys,
15+
public QuotedPattern $pattern,
1616
) {}
1717
}

packages/i18n/src/MessageFormat/Parser/Node/Declaration/InputDeclaration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use Tempest\Internationalization\MessageFormat\Parser\Node\Expression\VariableExpression;
66

7-
final class InputDeclaration implements Declaration
7+
final readonly class InputDeclaration implements Declaration
88
{
99
public function __construct(
10-
public readonly VariableExpression $expression,
10+
public VariableExpression $expression,
1111
) {}
1212
}

packages/i18n/src/MessageFormat/Parser/Node/Declaration/LocalDeclaration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use Tempest\Internationalization\MessageFormat\Parser\Node\Expression\Expression;
66
use Tempest\Internationalization\MessageFormat\Parser\Node\Variable;
77

8-
final class LocalDeclaration implements Declaration
8+
final readonly class LocalDeclaration implements Declaration
99
{
1010
public function __construct(
11-
public readonly Variable $variable,
12-
public readonly Expression $expression,
11+
public Variable $variable,
12+
public Expression $expression,
1313
) {}
1414
}

packages/i18n/src/MessageFormat/Parser/Node/Expression/Attribute.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
use Tempest\Internationalization\MessageFormat\Parser\Node\Literal\Literal;
77
use Tempest\Internationalization\MessageFormat\Parser\Node\Node;
88

9-
final class Attribute implements Node
9+
final readonly class Attribute implements Node
1010
{
1111
public function __construct(
12-
public readonly Identifier $identifier,
13-
public readonly ?Literal $value,
12+
public Identifier $identifier,
13+
public ?Literal $value,
1414
) {}
1515
}

0 commit comments

Comments
 (0)