From 5a4c8d96d4eaf6de4fa791e1bd9f3fe85c56ad37 Mon Sep 17 00:00:00 2001 From: Mateusz Zalewski Date: Fri, 29 Apr 2022 15:52:32 +0200 Subject: [PATCH 1/2] Support Twig 3 --- composer.json | 2 +- .../AddressingBundle/spec/Twig/CountryNameExtensionSpec.php | 3 ++- .../Bundle/UiBundle/spec/Twig/PercentageExtensionSpec.php | 3 ++- src/Sylius/Bundle/UiBundle/spec/Twig/SortByExtensionSpec.php | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 635c90c5570..bd24fb4e71e 100644 --- a/composer.json +++ b/composer.json @@ -126,7 +126,7 @@ "symfony/validator": "^5.4", "symfony/yaml": "^5.4", "twig/intl-extra": "^2.12", - "twig/twig": "^2.12", + "twig/twig": "^2.12 || ^3.3", "webmozart/assert": "^1.9", "willdurand/hateoas": "^3.0", "willdurand/hateoas-bundle": "^2.0", diff --git a/src/Sylius/Bundle/AddressingBundle/spec/Twig/CountryNameExtensionSpec.php b/src/Sylius/Bundle/AddressingBundle/spec/Twig/CountryNameExtensionSpec.php index 560a499f5e6..8b43f5dbcce 100644 --- a/src/Sylius/Bundle/AddressingBundle/spec/Twig/CountryNameExtensionSpec.php +++ b/src/Sylius/Bundle/AddressingBundle/spec/Twig/CountryNameExtensionSpec.php @@ -15,12 +15,13 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Addressing\Model\CountryInterface; +use Twig\Extension\ExtensionInterface; final class CountryNameExtensionSpec extends ObjectBehavior { function it_is_a_twig_extension(): void { - $this->shouldHaveType(\Twig_Extension::class); + $this->shouldImplement(ExtensionInterface::class); } function it_translates_country_iso_code_into_name(): void diff --git a/src/Sylius/Bundle/UiBundle/spec/Twig/PercentageExtensionSpec.php b/src/Sylius/Bundle/UiBundle/spec/Twig/PercentageExtensionSpec.php index 2bb65593711..19356c4eabd 100644 --- a/src/Sylius/Bundle/UiBundle/spec/Twig/PercentageExtensionSpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/Twig/PercentageExtensionSpec.php @@ -14,12 +14,13 @@ namespace spec\Sylius\Bundle\UiBundle\Twig; use PhpSpec\ObjectBehavior; +use Twig\Extension\ExtensionInterface; final class PercentageExtensionSpec extends ObjectBehavior { function it_is_twig_extension(): void { - $this->shouldHaveType(\Twig_Extension::class); + $this->shouldImplement(ExtensionInterface::class); } function it_returns_float_number_as_percentage(): void diff --git a/src/Sylius/Bundle/UiBundle/spec/Twig/SortByExtensionSpec.php b/src/Sylius/Bundle/UiBundle/spec/Twig/SortByExtensionSpec.php index d0973c6fc2b..3e9cb647d5f 100644 --- a/src/Sylius/Bundle/UiBundle/spec/Twig/SortByExtensionSpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/Twig/SortByExtensionSpec.php @@ -17,12 +17,13 @@ use PhpSpec\ObjectBehavior; use Sylius\Bundle\UiBundle\spec\Fixtures\SampleInterface; use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException; +use Twig\Extension\ExtensionInterface; final class SortByExtensionSpec extends ObjectBehavior { function it_extends_twig_extensions(): void { - $this->shouldHaveType(\Twig_Extension::class); + $this->shouldImplement(ExtensionInterface::class); } function it_sorts_in_ascending_order_by_default( From 6792c7abda67a99d0e6abd964a81d8fc13656d12 Mon Sep 17 00:00:00 2001 From: Mateusz Zalewski Date: Sat, 30 Apr 2022 09:01:10 +0200 Subject: [PATCH 2/2] Additional build with Twig 2 --- .github/workflows/application.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/application.yml b/.github/workflows/application.yml index 21f25fcb84a..1434af468d9 100644 --- a/.github/workflows/application.yml +++ b/.github/workflows/application.yml @@ -108,7 +108,7 @@ jobs: name: Run PHPStan run: vendor/bin/phpstan analyse if: always() && steps.end-of-setup.outcome == 'success' - + - name: Run ComposerRequireChecker run: | @@ -394,7 +394,7 @@ jobs: test-application-without-frontend-mysql: runs-on: ubuntu-latest - name: "Test non-JS application (PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }})" + name: "Test non-JS application (PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}, Twig ${{ matrix.twig }})" timeout-minutes: 25 @@ -405,6 +405,14 @@ jobs: symfony: ["^5.4"] node: ["14.x", "16.x"] mysql: ["5.7", "8.0"] + twig: ["3.x"] + include: + - + php: "8.0" + symfony: "^5.4" + node: "14.x" + twig: "2.x" + mysql: "5.7" env: APP_ENV: test_cached @@ -456,6 +464,12 @@ jobs: restore-keys: | ${{ runner.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer- + - + name: Restrict Twig version + if: matrix.twig != '' + run: | + composer require "twig/twig:${{ matrix.twig }}" --no-update --no-scripts --no-interaction + - name: Install PHP dependencies run: composer update --no-interaction --no-scripts