From 2cf4d73813a4f0eca2ef7942bf86793db21a97a9 Mon Sep 17 00:00:00 2001
From: Fabian <fs@webfactory.de>
Date: Mon, 19 Jun 2023 09:54:50 +0200
Subject: [PATCH] Allow symfony 6 packages (#29)

---
 .github/workflows/tests.yml                    |  2 +-
 composer.json                                  | 18 +++++++++---------
 src/Handler/EmbeddedShortcodeHandler.php       |  2 +-
 src/Resources/config/guide-routing.xml         |  4 ++--
 .../EmbeddedShortcodeHandlerTest.php           |  4 ++--
 tests/Functional/EndToEndTest.php              |  2 +-
 .../ShortcodeDefinitionTestHelperTest.php      |  2 +-
 tests/Functional/ShortcodeExtensionTest.php    |  2 +-
 tests/Functional/ShortcodeTest.php             |  2 +-
 9 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 700d51b..bc76b23 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -18,7 +18,7 @@ jobs:
             matrix:
                 include:
                     - { php-version: 7.2, symfony-locked-version: none, dependency-version: prefer-lowest }
-                    - { php-version: 7.4, symfony-locked-version: 4.4.*, dependency-version: prefer-stable }
+                    - { php-version: 7.4, symfony-locked-version: 5.3.*, dependency-version: prefer-stable }
                     - { php-version: 8.1, symfony-locked-version: none, dependency-version: prefer-stable }
         name: PHPUnit (PHP ${{matrix.php-version}}, Symfony Version Lock ${{ matrix.symfony-locked-version }}, ${{ matrix.dependency-version }})
         steps:
diff --git a/composer.json b/composer.json
index a249d2a..72dda00 100644
--- a/composer.json
+++ b/composer.json
@@ -8,11 +8,11 @@
         "ext-json": "*",
         "ext-mbstring": "*",
         "psr/log": "^1.0.2",
-        "symfony/config": "^4.4|^5.0",
-        "symfony/dependency-injection": "^4.4|^5.0",
+        "symfony/config": "^4.4|^5.0|^6.0",
+        "symfony/dependency-injection": "^4.4|^5.0|^6.0",
         "symfony/deprecation-contracts": "^2.5|^3.0",
-        "symfony/http-foundation": "^4.4|^5.0",
-        "symfony/http-kernel": "^4.4|^5.0",
+        "symfony/http-foundation": "^5.3|^6.0",
+        "symfony/http-kernel": "^4.4|^5.0|^6.0",
         "thunderer/shortcode": "^0.6.5|^0.7",
         "twig/twig": "^1.34|^2.0|^3.0"
     },
@@ -20,12 +20,12 @@
     "require-dev": {
         "phpunit/phpunit": "^8.5|^9.5",
         "symfony/browser-kit": "^4.4|^5.4",
-        "symfony/expression-language": "^4.4|^5.0",
-        "symfony/framework-bundle": "^4.4|^5.0",
+        "symfony/expression-language": "^4.4|^5.0|^6.0",
+        "symfony/framework-bundle": "^5.3|^6.0",
         "symfony/phpunit-bridge": ">= 6.0",
-        "symfony/routing": "^4.4|^5.0",
-        "symfony/twig-bundle": "^4.4|^5.0",
-        "symfony/yaml": "^4.4|^5.0"
+        "symfony/routing": "^4.4|^5.0|^6.0",
+        "symfony/twig-bundle": "^4.4|^5.0|^6.0",
+        "symfony/yaml": "^4.4|^5.0|^6.0"
     },
 
     "autoload": {
diff --git a/src/Handler/EmbeddedShortcodeHandler.php b/src/Handler/EmbeddedShortcodeHandler.php
index c9094d8..36fc1ee 100644
--- a/src/Handler/EmbeddedShortcodeHandler.php
+++ b/src/Handler/EmbeddedShortcodeHandler.php
@@ -64,7 +64,7 @@ public function __invoke(ShortcodeInterface $shortcode)
                 'parameters' => json_encode($shortcode->getParameters()),
                 'renderer' => $this->renderer,
                 'shortcode' => $shortcode->getName(),
-                'url' => $this->requestStack->getMasterRequest() ? $this->requestStack->getMasterRequest()->getRequestUri() : '-',
+                'url' => $this->requestStack->getMainRequest() ? $this->requestStack->getMainRequest()->getRequestUri() : '-',
             ]
         );
 
diff --git a/src/Resources/config/guide-routing.xml b/src/Resources/config/guide-routing.xml
index e4c0b32..5916fa1 100644
--- a/src/Resources/config/guide-routing.xml
+++ b/src/Resources/config/guide-routing.xml
@@ -5,11 +5,11 @@
         http://symfony.com/schema/routing/routing-1.0.xsd">
 
     <route id="webfactory.shortcode.guide-list" path="/">
-        <default key="_controller">Webfactory\ShortcodeBundle\Controller\GuideController:listAction</default>
+        <default key="_controller">Webfactory\ShortcodeBundle\Controller\GuideController::listAction</default>
     </route>
 
     <route id="webfactory.shortcode.guide-detail" path="/{shortcode}/">
-        <default key="_controller">Webfactory\ShortcodeBundle\Controller\GuideController:detailAction</default>
+        <default key="_controller">Webfactory\ShortcodeBundle\Controller\GuideController::detailAction</default>
     </route>
 
 </routes>
diff --git a/tests/Functional/EmbeddedShortcodeHandlerTest.php b/tests/Functional/EmbeddedShortcodeHandlerTest.php
index da9fb2b..721b610 100644
--- a/tests/Functional/EmbeddedShortcodeHandlerTest.php
+++ b/tests/Functional/EmbeddedShortcodeHandlerTest.php
@@ -69,9 +69,9 @@ private function processShortcodes(string $content, Request $request = null): st
         self::bootKernel();
 
         if ($request) {
-            static::$container->get(RequestStack::class)->push($request);
+            static::getContainer()->get(RequestStack::class)->push($request);
         }
 
-        return EndToEndTestHelper::createFromContainer(static::$container)->processShortcode($content);
+        return EndToEndTestHelper::createFromContainer(static::getContainer())->processShortcode($content);
     }
 }
diff --git a/tests/Functional/EndToEndTest.php b/tests/Functional/EndToEndTest.php
index 94af8e4..60a8cbf 100644
--- a/tests/Functional/EndToEndTest.php
+++ b/tests/Functional/EndToEndTest.php
@@ -75,7 +75,7 @@ public function provideEsiShortcodes(): Generator
     private function renderTwig(string $templateCode, array $context = [], Request $request = null): string
     {
         self::bootKernel();
-        $container = static::$container;
+        $container = static::getContainer();
 
         $requestStack = $container->get(RequestStack::class);
         $requestStack->push($request ?? new Request());
diff --git a/tests/Functional/ShortcodeDefinitionTestHelperTest.php b/tests/Functional/ShortcodeDefinitionTestHelperTest.php
index afa9583..5b9fd63 100644
--- a/tests/Functional/ShortcodeDefinitionTestHelperTest.php
+++ b/tests/Functional/ShortcodeDefinitionTestHelperTest.php
@@ -19,7 +19,7 @@ class ShortcodeDefinitionTestHelperTest extends KernelTestCase
     protected function setUp(): void
     {
         self::bootKernel();
-        $this->helper = static::$container->get(ShortcodeDefinitionTestHelper::class);
+        $this->helper = static::getContainer()->get(ShortcodeDefinitionTestHelper::class);
     }
 
     /**
diff --git a/tests/Functional/ShortcodeExtensionTest.php b/tests/Functional/ShortcodeExtensionTest.php
index 3008284..6a75120 100644
--- a/tests/Functional/ShortcodeExtensionTest.php
+++ b/tests/Functional/ShortcodeExtensionTest.php
@@ -28,7 +28,7 @@ public function filter_returns_safe_html(): void
     private function renderTemplate(string $template): string
     {
         self::bootKernel();
-        $container = static::$container;
+        $container = static::getContainer();
 
         $twig = $container->get('twig');
 
diff --git a/tests/Functional/ShortcodeTest.php b/tests/Functional/ShortcodeTest.php
index 54fdf28..898972a 100644
--- a/tests/Functional/ShortcodeTest.php
+++ b/tests/Functional/ShortcodeTest.php
@@ -90,7 +90,7 @@ private function getUrlWithRenderedExample(/* array */ $customParameters = null)
             $urlParameters['customParameters'] = $customParametersAsString;
         }
 
-        return static::$container->get('router')->generate('webfactory.shortcode.guide-detail', $urlParameters);
+        return static::getContainer()->get('router')->generate('webfactory.shortcode.guide-detail', $urlParameters);
     }
 
     private function getCustomParametersAsString($customParametersAsMixed): ?string