diff --git a/composer.json b/composer.json index 30756f9..a84f2ad 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ }, "require": { "php": "^8.2", - "twig/twig": "^3.17" + "twig/twig": "4.x-dev" }, "require-dev": { "phpmyadmin/coding-standard": "^4.0", @@ -30,7 +30,7 @@ "phpstan/phpstan": "^1.10", "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-strict-rules": "^1.5", - "phpunit/phpunit": "^10" + "phpunit/phpunit": "^11" }, "scripts": { "phpstan": "./vendor/bin/phpstan analyse", diff --git a/src/I18nExtension.php b/src/I18nExtension.php index c9ed637..ca49896 100644 --- a/src/I18nExtension.php +++ b/src/I18nExtension.php @@ -26,7 +26,7 @@ class I18nExtension extends AbstractExtension /** * {@inheritdoc} */ - public function getTokenParsers() + public function getTokenParsers(): array { return [new TransTokenParser()]; } @@ -34,19 +34,14 @@ public function getTokenParsers() /** * {@inheritdoc} */ - public function getFilters() + public function getFilters(): array { return [ new TwigFilter('trans', [$this, 'translate']), /* Note, the filter does not handle plurals */ ]; } - /** - * {@inheritdoc} - * - * @return string - */ - public function getName() + public function getName(): string { return 'i18n'; } diff --git a/src/Node/TransNode.php b/src/Node/TransNode.php index 3e10f39..ad23113 100644 --- a/src/Node/TransNode.php +++ b/src/Node/TransNode.php @@ -95,10 +95,7 @@ public function __construct( parent::__construct($nodes, [], $lineno); } - /** - * {@inheritdoc} - */ - public function compile(Compiler $compiler) + public function compile(Compiler $compiler): void { if (self::$enableAddDebugInfo) { $compiler->addDebugInfo($this); diff --git a/src/TokenParser/TransTokenParser.php b/src/TokenParser/TransTokenParser.php index cf8253d..1cd8b7e 100644 --- a/src/TokenParser/TransTokenParser.php +++ b/src/TokenParser/TransTokenParser.php @@ -27,10 +27,7 @@ class TransTokenParser extends AbstractTokenParser { - /** - * {@inheritdoc} - */ - public function parse(Token $token) + public function parse(Token $token): Node { [ $body, @@ -118,10 +115,7 @@ public function decideForEnd(Token $token): bool return $token->test('endtrans'); } - /** - * {@inheritdoc} - */ - public function getTag() + public function getTag(): string { return 'trans'; } diff --git a/test/Node/TransTest.php b/test/Node/TransTest.php index 030947b..6bf839a 100644 --- a/test/Node/TransTest.php +++ b/test/Node/TransTest.php @@ -17,13 +17,14 @@ use PhpMyAdmin\Twig\Extensions\Node\TransNode; use Twig\Environment; use Twig\Node\Expression\ConstantExpression; -use Twig\Node\Expression\FilterExpression; +use Twig\Node\Expression\Filter\RawFilter; use Twig\Node\Expression\Variable\ContextVariable; use Twig\Node\Node; use Twig\Node\Nodes; use Twig\Node\PrintNode; use Twig\Node\TextNode; use Twig\Test\NodeTestCase; +use Twig\TwigFilter; use function sprintf; @@ -203,7 +204,7 @@ public static function provideTests(): iterable $body = new Nodes([ new TextNode('J\'ai ', 0), new PrintNode( - new FilterExpression($contextFoo, new ConstantExpression('escape', 0), new Nodes(), 0), + new RawFilter($contextFoo, new TwigFilter('escape'), new Nodes(), 0), 0, ), new TextNode(' pommes', 0),