From e727201a1a76dbbab4433179db9a38ac27740b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Tue, 11 Jun 2024 09:17:21 +0200 Subject: [PATCH] Add support for Symfony 7 --- .github/workflows/ci.yaml | 2 +- composer.json | 36 +++++++++---------- monorepo-builder.php | 2 +- src/TwigHooks/composer.json | 32 ++++++++--------- .../Debug/HookableDebugCommentRenderer.php | 13 ++++++- 5 files changed, 48 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3aff5db5..816b60b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: php: [ "8.1", "8.2", "8.3" ] - symfony: [ "^6.4" ] + symfony: [ "^6.4", "^7.4" ] name: "PHP ${{ matrix.php }} / Symfony ${{ matrix.symfony }}" env: APP_ENV: test diff --git a/composer.json b/composer.json index 195798d6..ef5b14d9 100644 --- a/composer.json +++ b/composer.json @@ -16,32 +16,32 @@ "require": { "php": "^8.1", "laminas/laminas-stdlib": "^3.18", - "symfony/config": "^6.4", - "symfony/dependency-injection": "^6.4", - "symfony/expression-language": "^6.4", - "symfony/http-kernel": "^6.4", - "symfony/stopwatch": "^6.4", - "symfony/twig-bundle": "^6.4", + "symfony/config": "^6.4 || ^7.0", + "symfony/dependency-injection": "^6.4 || ^7.0", + "symfony/expression-language": "^6.4 || ^7.0", + "symfony/http-kernel": "^6.4 || ^7.0", + "symfony/stopwatch": "^6.4 || ^7.0", + "symfony/twig-bundle": "^6.4 || ^7.0", "symfony/ux-live-component": "^2.17", "symfony/ux-twig-component": "^2.17", "twig/twig": "^2.15 || ^3.0" }, "require-dev": { - "matthiasnoback/symfony-config-test": "^4.3", - "matthiasnoback/symfony-dependency-injection-test": "^4.3.1", + "matthiasnoback/symfony-config-test": "^5.1", + "matthiasnoback/symfony-dependency-injection-test": "^5.1", "phpstan/phpstan": "^1.10", "phpstan/phpstan-symfony": "^1.3", "phpunit/phpunit": "^9.6", - "symfony/console": "^6.4", - "symfony/debug-bundle": "^6.4", - "symfony/dom-crawler": "^6.4", - "symfony/dotenv": "^6.4", + "symfony/console": "^6.4 || ^7.0", + "symfony/debug-bundle": "^6.4 || ^7.0", + "symfony/dom-crawler": "^6.4 || ^7.0", + "symfony/dotenv": "^6.4 || ^7.0", "symfony/flex": "^2.4", - "symfony/framework-bundle": "^6.4", - "symfony/runtime": "^6.4", - "symfony/translation": "^6.4", - "symfony/web-profiler-bundle": "^6.4", - "symfony/yaml": "^6.4 ", + "symfony/framework-bundle": "^6.4 || ^7.0", + "symfony/runtime": "^6.4 || ^7.0", + "symfony/translation": "^6.4 || ^7.0", + "symfony/web-profiler-bundle": "^6.4 || ^7.0", + "symfony/yaml": "^6.4 || ^7.0", "symplify/monorepo-builder": "11.2.*" }, "autoload": { @@ -69,7 +69,7 @@ }, "extra": { "symfony": { - "require": "6.4.*" + "require": "7.0.*" } } } diff --git a/monorepo-builder.php b/monorepo-builder.php index 808c09e3..0f7c4ca1 100644 --- a/monorepo-builder.php +++ b/monorepo-builder.php @@ -13,7 +13,7 @@ ], ComposerJsonSection::REQUIRE_DEV => [ 'phpstan/phpstan' => '^1.10', - 'symfony/debug-bundle' => '^6.4', + 'symfony/debug-bundle' => '^6.4 || ^7.0', 'symfony/flex' => '^2.4', 'symplify/monorepo-builder' => '11.2.*', 'phpstan/phpstan-symfony' => '^1.3' diff --git a/src/TwigHooks/composer.json b/src/TwigHooks/composer.json index 21965460..3f4c2248 100644 --- a/src/TwigHooks/composer.json +++ b/src/TwigHooks/composer.json @@ -16,28 +16,28 @@ "require": { "php": "^8.1", "laminas/laminas-stdlib": "^3.18", - "symfony/config": "^6.4", - "symfony/dependency-injection": "^6.4", - "symfony/expression-language": "^6.4", - "symfony/http-kernel": "^6.4", - "symfony/stopwatch": "^6.4", + "symfony/config": "^6.4 || ^7.0", + "symfony/dependency-injection": "^6.4 || ^7.0", + "symfony/expression-language": "^6.4 || ^7.0", + "symfony/http-kernel": "^6.4 || ^7.0", + "symfony/stopwatch": "^6.4 || ^7.0", "symfony/ux-live-component": "^2.17", "symfony/ux-twig-component": "^2.17", - "symfony/twig-bundle": "^6.4", + "symfony/twig-bundle": "^6.4 || ^7.0", "twig/twig": "^2.15 || ^3.0" }, "require-dev": { - "symfony/console": "^6.4", - "symfony/dom-crawler": "^6.4", - "symfony/dotenv": "^6.4", - "symfony/framework-bundle": "^6.4", - "symfony/runtime": "^6.4", - "symfony/translation": "^6.4", - "symfony/twig-bundle": "^6.4", - "symfony/web-profiler-bundle": "^6.4", + "symfony/console": "^6.4 || ^7.0", + "symfony/dom-crawler": "^6.4 || ^7.0", + "symfony/dotenv": "^6.4 || ^7.0", + "symfony/framework-bundle": "^6.4 || ^7.0", + "symfony/runtime": "^6.4 || ^7.0", + "symfony/translation": "^6.4 || ^7.0", + "symfony/twig-bundle": "^6.4 || ^7.0", + "symfony/web-profiler-bundle": "^6.4 || ^7.0", "symfony/yaml": "^6.4 ", - "matthiasnoback/symfony-config-test": "^4.3", - "matthiasnoback/symfony-dependency-injection-test": "^4.3.1", + "matthiasnoback/symfony-config-test": "^5.1", + "matthiasnoback/symfony-dependency-injection-test": "^5.1", "phpunit/phpunit": "^9.6" }, "suggest": { diff --git a/src/TwigHooks/src/Hookable/Renderer/Debug/HookableDebugCommentRenderer.php b/src/TwigHooks/src/Hookable/Renderer/Debug/HookableDebugCommentRenderer.php index 38c69955..2bff8ca9 100644 --- a/src/TwigHooks/src/Hookable/Renderer/Debug/HookableDebugCommentRenderer.php +++ b/src/TwigHooks/src/Hookable/Renderer/Debug/HookableDebugCommentRenderer.php @@ -7,10 +7,12 @@ use Sylius\TwigHooks\Hookable\AbstractHookable; use Sylius\TwigHooks\Hookable\HookableComponent; use Sylius\TwigHooks\Hookable\HookableTemplate; +use Sylius\TwigHooks\Hookable\Merger\HookableMergerInterface; use Sylius\TwigHooks\Hookable\Metadata\HookableMetadata; +use Sylius\TwigHooks\Hookable\Renderer\Exception\HookRenderException; use Sylius\TwigHooks\Hookable\Renderer\HookableRendererInterface; -final class HookableDebugCommentRenderer implements HookableRendererInterface +final class HookableDebugCommentRenderer implements HookableRendererInterface, HookableMergerInterface { public function __construct(private readonly HookableRendererInterface $innerRenderer) { @@ -61,4 +63,13 @@ private function getClosingDebugComment(AbstractHookable $hookable): string $hookable->priority(), ); } + + public function merge(AbstractHookable ...$hookables): AbstractHookable + { + if (!$this->innerRenderer instanceof HookableMergerInterface) { + throw new HookRenderException(sprintf('"%s" should implement "%s" to merge hookables\' data.', $this->innerRenderer::class, HookableMergerInterface::class)); + } + + return $this->innerRenderer->merge(...$hookables); + } }