From 3bfb69d24b67984af9592158bb7085c78692b3f3 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Wed, 26 Mar 2025 13:50:28 +0100 Subject: [PATCH 1/8] github: fix static workflows update dependencies --- .github/workflows/static.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index ea6822a..2020a5f 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -6,14 +6,14 @@ on: [pull_request] jobs: phpstan: name: PHPStan - runs-on: Ubuntu-20.04 + runs-on: Ubuntu-22.04 steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Cache PHPStan - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: .github/.cache/phpstan/ key: phpstan-${{ github.sha }} @@ -26,7 +26,7 @@ jobs: coverage: none - name: Download dependencies - uses: ramsey/composer-install@v2 + uses: ramsey/composer-install@v3 with: composer-options: --no-interaction --prefer-dist --optimize-autoloader @@ -40,7 +40,7 @@ jobs: name: PHP-CS-Fixer runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: PHP-CS-Fixer uses: docker://oskarstark/php-cs-fixer-ga with: @@ -48,13 +48,13 @@ jobs: psalm: name: Psalm - runs-on: Ubuntu-20.04 + runs-on: Ubuntu-22.04 steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Cache Psalm - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: .github/.cache/psalm/ key: psalm-${{ github.sha }} @@ -67,7 +67,7 @@ jobs: coverage: none - name: Download dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v3 with: composer-options: --no-interaction --prefer-dist --optimize-autoloader From 4077f727b07fe2936555794f964d8df5b1880414 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Wed, 26 Mar 2025 14:50:11 +0100 Subject: [PATCH 2/8] refac: use ConditionalTernary when possible --- Twig/Visitor/DefaultApplyingNodeVisitor.php | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Twig/Visitor/DefaultApplyingNodeVisitor.php b/Twig/Visitor/DefaultApplyingNodeVisitor.php index 9c112a7..9bf7a50 100644 --- a/Twig/Visitor/DefaultApplyingNodeVisitor.php +++ b/Twig/Visitor/DefaultApplyingNodeVisitor.php @@ -18,6 +18,7 @@ use Twig\Node\Expression\ConditionalExpression; use Twig\Node\Expression\ConstantExpression; use Twig\Node\Expression\FilterExpression; +use Twig\Node\Expression\Ternary\ConditionalTernary; use Twig\Node\Node; use Twig\NodeVisitor\AbstractNodeVisitor; @@ -103,12 +104,21 @@ public function doEnterNode(Node $node, Environment $env): Node ); } - $condition = new ConditionalExpression( - new EqualBinary($testNode, $transNode->getNode('node'), $wrappingNode->getTemplateLine()), - $defaultNode, - clone $wrappingNode, - $wrappingNode->getTemplateLine() - ); + if (Environment::VERSION_ID >= 31700) { + $condition = new ConditionalTernary( + new EqualBinary($testNode, $transNode->getNode('node'), $wrappingNode->getTemplateLine()), + $defaultNode, + clone $wrappingNode, + $wrappingNode->getTemplateLine() + ); + } else { + $condition = new ConditionalExpression( + new EqualBinary($testNode, $transNode->getNode('node'), $wrappingNode->getTemplateLine()), + $defaultNode, + clone $wrappingNode, + $wrappingNode->getTemplateLine() + ); + } $node->setNode('node', $condition); return $node; From f80e59f2b257e7d63350eea73bf0887ae79e64b6 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Wed, 26 Mar 2025 16:38:05 +0100 Subject: [PATCH 3/8] refac: use Nodes instate of Node --- Twig/Visitor/DefaultApplyingNodeVisitor.php | 29 +++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Twig/Visitor/DefaultApplyingNodeVisitor.php b/Twig/Visitor/DefaultApplyingNodeVisitor.php index 9bf7a50..cb8ddd5 100644 --- a/Twig/Visitor/DefaultApplyingNodeVisitor.php +++ b/Twig/Visitor/DefaultApplyingNodeVisitor.php @@ -20,7 +20,9 @@ use Twig\Node\Expression\FilterExpression; use Twig\Node\Expression\Ternary\ConditionalTernary; use Twig\Node\Node; +use Twig\Node\Nodes; use Twig\NodeVisitor\AbstractNodeVisitor; +use Twig\TwigFilter; /** * Applies the value of the "desc" filter if the "trans" filter has no @@ -94,14 +96,25 @@ public function doEnterNode(Node $node, Environment $env): Node $testNode->getNode('arguments')->setNode(0, new ArrayExpression([], $lineno)); // wrap the default node in a |replace filter - $defaultNode = new FilterExpression( - clone $node->getNode('arguments')->getNode(0), - new ConstantExpression('replace', $lineno), - new Node([ - clone $wrappingNode->getNode('arguments')->getNode(0), - ]), - $lineno - ); + if (Environment::VERSION_ID >= 31500) { + $defaultNode = new FilterExpression( + clone $node->getNode('arguments')->getNode(0), + new TwigFilter('replace'), + new Nodes([ + clone $wrappingNode->getNode('arguments')->getNode(0), + ]), + $lineno + ); + } else { + $defaultNode = new FilterExpression( + clone $node->getNode('arguments')->getNode(0), + new ConstantExpression('replace', $lineno), + new Node([ + clone $wrappingNode->getNode('arguments')->getNode(0), + ]), + $lineno + ); + } } if (Environment::VERSION_ID >= 31700) { From 890edccacf09e8222c8805a5fe0a8030b45b26f9 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Thu, 27 Mar 2025 09:00:29 +0100 Subject: [PATCH 4/8] refac: set operator attribute on EqualBinary expression --- Twig/Visitor/DefaultApplyingNodeVisitor.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Twig/Visitor/DefaultApplyingNodeVisitor.php b/Twig/Visitor/DefaultApplyingNodeVisitor.php index cb8ddd5..5be6d88 100644 --- a/Twig/Visitor/DefaultApplyingNodeVisitor.php +++ b/Twig/Visitor/DefaultApplyingNodeVisitor.php @@ -117,21 +117,25 @@ public function doEnterNode(Node $node, Environment $env): Node } } + $expr = new EqualBinary($testNode, $transNode->getNode('node'), $wrappingNode->getTemplateLine()); if (Environment::VERSION_ID >= 31700) { + $expr->setAttribute('operator', 'binary_=='); + $condition = new ConditionalTernary( - new EqualBinary($testNode, $transNode->getNode('node'), $wrappingNode->getTemplateLine()), + $expr, $defaultNode, clone $wrappingNode, $wrappingNode->getTemplateLine() ); } else { $condition = new ConditionalExpression( - new EqualBinary($testNode, $transNode->getNode('node'), $wrappingNode->getTemplateLine()), + $expr, $defaultNode, clone $wrappingNode, $wrappingNode->getTemplateLine() ); } + $node->setNode('node', $condition); return $node; From ce0407e216ea51a085f51028a707291d21566b60 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Thu, 27 Mar 2025 09:29:46 +0100 Subject: [PATCH 5/8] refac: migrate phpunit.dist.xml and fix max deprecation setting --- phpunit.xml.dist | 59 +++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0a4e149..a886fab 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,38 +1,25 @@ - - - - - - - - - - - - - - - ./Tests - - - - - - ./ - - vendor - Tests - - - + + + + ./ + + + vendor + Tests + + + + + + + + + + + + + ./Tests + + From 1acdc0be906d2d9f6437634789c2839141cdde64 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Thu, 27 Mar 2025 09:34:54 +0100 Subject: [PATCH 6/8] feat: remove twig 2.x support no more maintained --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e28adc8..3dd11d3 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php-translation/symfony-storage": "^2.1", "php-translation/extractor": "^2.0", "nyholm/nsa": "^1.1", - "twig/twig": "^2.14.4 || ^3.3", + "twig/twig": "^3.3", "symfony/asset": "^5.3 || ^6.0 || ^7.0" }, "require-dev": { From c036d64ea9851b5540b5e5dc87b271e80638f0c2 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Thu, 27 Mar 2025 09:43:44 +0100 Subject: [PATCH 7/8] refac: fix Symfony\Component\HttpKernel\DependencyInjection\Extension deprecation --- DependencyInjection/TranslationExtension.php | 2 +- phpunit.xml.dist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/TranslationExtension.php b/DependencyInjection/TranslationExtension.php index 1ba8fed..ede6351 100644 --- a/DependencyInjection/TranslationExtension.php +++ b/DependencyInjection/TranslationExtension.php @@ -16,9 +16,9 @@ use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; +use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\Kernel; use Translation\Bundle\EventListener\AutoAddMissingTranslations; use Translation\Bundle\EventListener\EditInPlaceResponseListener; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a886fab..c8f76bf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,7 +11,7 @@ - + From 776af278451ee9e2eac2eb4a925206bf0c4b0f9b Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Thu, 27 Mar 2025 10:17:53 +0100 Subject: [PATCH 8/8] refac: fix self deprecation mb_convert_encoding --- Tests/Functional/Controller/EditInPlaceTest.php | 4 ++-- phpunit.xml.dist | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/Functional/Controller/EditInPlaceTest.php b/Tests/Functional/Controller/EditInPlaceTest.php index 932af74..733a1e2 100644 --- a/Tests/Functional/Controller/EditInPlaceTest.php +++ b/Tests/Functional/Controller/EditInPlaceTest.php @@ -40,7 +40,7 @@ public function testActivatedTest(): void self::assertStringContainsString('', $response->getContent()); $dom = new \DOMDocument('1.0', 'utf-8'); - @$dom->loadHTML(mb_convert_encoding($response->getContent(), 'HTML-ENTITIES', 'UTF-8')); + @$dom->loadHTML(mb_encode_numericentity($response->getContent(), [0x80, 0x10FFFF, 0, ~0], 'UTF-8')); $xpath = new \DOMXPath($dom); // Check number of x-trans tags @@ -79,7 +79,7 @@ public function testIfUntranslatableLabelGetsDisabled(): void self::assertStringContainsString('', $response->getContent()); $dom = new \DOMDocument('1.0', 'utf-8'); - @$dom->loadHTML(mb_convert_encoding($response->getContent(), 'HTML-ENTITIES', 'UTF-8')); + @$dom->loadHTML(mb_encode_numericentity($response->getContent(), [0x80, 0x10FFFF, 0, ~0], 'UTF-8')); $xpath = new \DOMXPath($dom); // Check number of x-trans tags diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c8f76bf..5e2a761 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,7 +11,7 @@ - +