From d67fb26ed5546dc91408e694d56e0e710aeb858d Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Wed, 20 Dec 2023 10:39:56 +0100 Subject: [PATCH] Update to Symfony 7 compatibility --- .github/workflows/php.yml | 36 +++++----- composer.json | 6 +- fixture-app/bin/console | 0 fixture-app/bin/phpunit | 10 ++- fixture-app/composer.json | 24 +++---- fixture-app/config/packages/framework.yaml | 2 - fixture-app/config/routes.yaml | 2 +- fixture-app/phpunit.xml.dist | 8 +-- .../src/Controller/TestRoutesController.php | 13 ++++ fixture-app/symfony.lock | 66 +++++++++---------- fixture-app/tests/bootstrap.php | 4 ++ phpunit-9.5.xml => phpunit-9.6.xml | 0 12 files changed, 91 insertions(+), 80 deletions(-) mode change 100644 => 100755 fixture-app/bin/console mode change 100644 => 100755 fixture-app/bin/phpunit rename phpunit-9.5.xml => phpunit-9.6.xml (100%) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index e487189..345c799 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -9,37 +9,35 @@ jobs: strategy: matrix: include: - - { php-version: "7.4", symfony-version: "5.4", phpunit-version: "9.5" } + - { php-version: "8.1", symfony-version: "6.0", phpunit-version: "9.6" } + - { php-version: "8.1", symfony-version: "6.1", phpunit-version: "9.6" } + - { php-version: "8.1", symfony-version: "6.2", phpunit-version: "9.6" } + - { php-version: "8.1", symfony-version: "6.3", phpunit-version: "9.6" } + - { php-version: "8.1", symfony-version: "6.4", phpunit-version: "9.6" } + + - { php-version: "8.2", symfony-version: "6.0", phpunit-version: "9.6" } + - { php-version: "8.2", symfony-version: "6.1", phpunit-version: "9.6" } + - { php-version: "8.2", symfony-version: "6.2", phpunit-version: "9.6" } + - { php-version: "8.2", symfony-version: "6.3", phpunit-version: "9.6" } + - { php-version: "8.2", symfony-version: "6.4", phpunit-version: "9.6" } + - { php-version: "8.2", symfony-version: "7.0", phpunit-version: "9.6" } - - { php-version: "8.0", symfony-version: "5.4", phpunit-version: "9.5" } - - - { php-version: "8.1", symfony-version: "5.4", phpunit-version: "9.5" } - - { php-version: "8.1", symfony-version: "6.0", phpunit-version: "9.5" } - - { php-version: "8.1", symfony-version: "6.1", phpunit-version: "9.5" } - - { php-version: "8.1", symfony-version: "6.2", phpunit-version: "9.5" } - - { php-version: "8.1", symfony-version: "6.3", phpunit-version: "9.5" } - - - { php-version: "8.2", symfony-version: "5.4", phpunit-version: "9.5" } - - { php-version: "8.2", symfony-version: "6.0", phpunit-version: "9.5" } - - { php-version: "8.2", symfony-version: "6.1", phpunit-version: "9.5" } - - { php-version: "8.2", symfony-version: "6.2", phpunit-version: "9.5" } - - { php-version: "8.2", symfony-version: "6.3", phpunit-version: "9.5" } - - - { php-version: "8.1", symfony-version: "5.4", phpunit-version: "10" } - { php-version: "8.1", symfony-version: "6.0", phpunit-version: "10" } - { php-version: "8.1", symfony-version: "6.1", phpunit-version: "10" } - { php-version: "8.1", symfony-version: "6.2", phpunit-version: "10" } - { php-version: "8.1", symfony-version: "6.3", phpunit-version: "10" } + - { php-version: "8.1", symfony-version: "6.4", phpunit-version: "10" } - - { php-version: "8.2", symfony-version: "5.4", phpunit-version: "10" } - { php-version: "8.2", symfony-version: "6.0", phpunit-version: "10" } - { php-version: "8.2", symfony-version: "6.1", phpunit-version: "10" } - { php-version: "8.2", symfony-version: "6.2", phpunit-version: "10" } - { php-version: "8.2", symfony-version: "6.3", phpunit-version: "10" } + - { php-version: "8.2", symfony-version: "6.4", phpunit-version: "10" } + - { php-version: "8.2", symfony-version: "7.0", phpunit-version: "10" } name: PHP ${{ matrix.php-version }}, Symfony ${{ matrix.symfony-version }}, PHPUnit ${{ matrix.phpunit-version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: @@ -51,7 +49,7 @@ jobs: - id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - uses: actions/cache@v1 + - uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/composer.json b/composer.json index 270d630..8732a6c 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,11 @@ } ], "require": { - "php": "^7.4|^8.0", - "symfony/framework-bundle": "^5.4|^6.1" + "php": "^8.1", + "symfony/framework-bundle": "^6.1|^7.0" }, "require-dev": { - "phpunit/phpunit": "^9.5|^10.0", + "phpunit/phpunit": "^9.6|^10.0", "symfony/maker-bundle": "^1.43" } } diff --git a/fixture-app/bin/console b/fixture-app/bin/console old mode 100644 new mode 100755 diff --git a/fixture-app/bin/phpunit b/fixture-app/bin/phpunit old mode 100644 new mode 100755 index f26f2c7..692bacc --- a/fixture-app/bin/phpunit +++ b/fixture-app/bin/phpunit @@ -6,9 +6,13 @@ if (!ini_get('date.timezone')) { } if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) { - define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php'); - require PHPUNIT_COMPOSER_INSTALL; - PHPUnit\TextUI\Command::main(); + if (PHP_VERSION_ID >= 80000) { + require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit'; + } else { + define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php'); + require PHPUNIT_COMPOSER_INSTALL; + PHPUnit\TextUI\Command::main(); + } } else { if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) { echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n"; diff --git a/fixture-app/composer.json b/fixture-app/composer.json index dc3a26d..f2baafd 100644 --- a/fixture-app/composer.json +++ b/fixture-app/composer.json @@ -4,23 +4,23 @@ "minimum-stability": "stable", "prefer-stable": true, "require": { - "php": "^7.4|^8.0", + "php": ">=8.1", "ext-ctype": "*", "ext-iconv": "*", - "doctrine/annotations": "^1.14", - "symfony/console": "^5.4|^6.1", - "symfony/dotenv": "^5.4|^6.1", - "symfony/flex": "^1.19|^2", - "symfony/framework-bundle": "^5.4|^6.1", - "symfony/runtime": "^5.4|^6.1", - "symfony/yaml": "^5.4|^6.1" + "doctrine/annotations": "^2.0", + "symfony/console": "^6.1|^7.0", + "symfony/dotenv": "^6.1|^7.0", + "symfony/flex": "^2.4", + "symfony/framework-bundle": "^6.1|^7.0", + "symfony/runtime": "^6.1|^7.0", + "symfony/yaml": "^6.1|^7.0" }, "require-dev": { "phpunit/phpunit": "^9.5|^10.0", - "symfony/browser-kit": "^5.4|^6.1", - "symfony/css-selector": "^5.4|^6.1", + "symfony/browser-kit": "^6.1|^7.0", + "symfony/css-selector": "^6.1|^7.0", "symfony/maker-bundle": "^1.43", - "symfony/phpunit-bridge": "^5.4|^6.1" + "symfony/phpunit-bridge": "^6.1|^7.0" }, "config": { "allow-plugins": { @@ -70,7 +70,7 @@ "extra": { "symfony": { "allow-contrib": false, - "require": "7.4.*" + "require": "6.1.*" } } } diff --git a/fixture-app/config/packages/framework.yaml b/fixture-app/config/packages/framework.yaml index 7853e9e..182b406 100644 --- a/fixture-app/config/packages/framework.yaml +++ b/fixture-app/config/packages/framework.yaml @@ -2,7 +2,6 @@ framework: secret: '%env(APP_SECRET)%' #csrf_protection: true - http_method_override: false # Enables session support. Note that the session will ONLY be started if you read or write from it. # Remove or comment this section to explicitly disable session support. @@ -10,7 +9,6 @@ framework: handler_id: null cookie_secure: auto cookie_samesite: lax - storage_factory_id: session.storage.factory.native #esi: true #fragments: true diff --git a/fixture-app/config/routes.yaml b/fixture-app/config/routes.yaml index b662dc9..9286e81 100644 --- a/fixture-app/config/routes.yaml +++ b/fixture-app/config/routes.yaml @@ -1,3 +1,3 @@ controllers: resource: ../src/Controller/ - type: annotation + type: attribute diff --git a/fixture-app/phpunit.xml.dist b/fixture-app/phpunit.xml.dist index af3f147..b7d629c 100644 --- a/fixture-app/phpunit.xml.dist +++ b/fixture-app/phpunit.xml.dist @@ -14,7 +14,7 @@ - + @@ -23,7 +23,7 @@ - + src @@ -33,10 +33,6 @@ - - diff --git a/fixture-app/src/Controller/TestRoutesController.php b/fixture-app/src/Controller/TestRoutesController.php index daf7a72..21a151b 100644 --- a/fixture-app/src/Controller/TestRoutesController.php +++ b/fixture-app/src/Controller/TestRoutesController.php @@ -12,42 +12,49 @@ class TestRoutesController extends AbstractController { /** @Route("/param/{id}", name="get_param_without_default") */ + #[Route("/param/{id}", name: "get_param_without_default")] public function getParameterWithoutDefault(string $id): Response { return new Response("Content: $id"); } /** @Route("/other_param/{id}", name="get_param_with_default", defaults={"id": "default_value"}) */ + #[Route("/other_param/{id}", name: "get_param_with_default", defaults: ["id" => "default_value"])] public function getParameterWithDefault(string $id): Response { return new Response("Content: $id"); } /** @Route("/200", name="get_200") */ + #[Route("/200", name: "get_200")] public function getOk(): Response { return new Response('200'); } /** @Route("/302", name="get_302") */ + #[Route("/302", name: "get_302")] public function getRedirect(): RedirectResponse { return new RedirectResponse('/200'); } /** @Route("/400", name="get_400") */ + #[Route("/400", name: "get_400")] public function get400(): Response { return new Response('400', 400); } /** @Route("/500", name="get_500") */ + #[Route("/500", name: "get_500")] public function get500(): Response { return new Response('500', 500); } /** @Route("/payload", name="get_with_payload") */ + #[Route("/payload", name: "get_with_payload")] public function getWithPayload(Request $request): Response { $payload = $request->getContent(); @@ -56,6 +63,7 @@ public function getWithPayload(Request $request): Response } /** @Route("/json/valid", name="json_valid") */ + #[Route("/json/valid", name: "json_valid")] public function getValidJson(): Response { return new JsonResponse([ @@ -65,6 +73,7 @@ public function getValidJson(): Response } /** @Route("/json/valid-header", name="json_valid_header") */ + #[Route("/json/valid-header", name: "json_valid_header")] public function getValidJsonHeader(): Response { return new JsonResponse([ @@ -74,6 +83,7 @@ public function getValidJsonHeader(): Response } /** @Route("/json/missing_header", name="json_missing_header") */ + #[Route("/json/missing_header", name: "json_missing_header")] public function getJsonInvalidHeader(): Response { return new Response(json_encode([ @@ -83,6 +93,7 @@ public function getJsonInvalidHeader(): Response } /** @Route("/json/invalid", name="json_invalid") */ + #[Route("/json/invalid", name: "json_invalid")] public function getJsonInvalid(): Response { return new Response('{"message":', 200, [ @@ -91,12 +102,14 @@ public function getJsonInvalid(): Response } /** @Route("/cookie/value", name="cookie_value") */ + #[Route("/cookie/value", name: "cookie_value")] public function getCookieValue(Request $request): Response { return new Response(\sprintf('Value: "%s"', $request->cookies->get('test_cookie'))); } /** @Route("/content-type", name="content_type") */ + #[Route("/content-type", name: "content_type")] public function getContentType(Request $request): Response { $contentType = method_exists($request, 'getContentTypeFormat') diff --git a/fixture-app/symfony.lock b/fixture-app/symfony.lock index 1b150c6..a16d218 100644 --- a/fixture-app/symfony.lock +++ b/fixture-app/symfony.lock @@ -4,25 +4,23 @@ "recipe": { "repo": "github.com/symfony/recipes", "branch": "main", - "version": "1.0", - "ref": "a2759dd6123694c8d901d0ec80006e044c2e6457" + "version": "1.10", + "ref": "64d8583af5ea57b7afa4aba4b159907f3a148b05" }, - "files": [ - "./config/routes/annotations.yaml" - ] + "files": [] }, "phpunit/phpunit": { - "version": "9.5", + "version": "10.5", "recipe": { "repo": "github.com/symfony/recipes", "branch": "main", - "version": "9.3", - "ref": "a6249a6c4392e9169b87abf93225f7f9f59025e6" + "version": "9.6", + "ref": "7364a21d87e658eb363c5020c072ecfdc12e2326" }, "files": [ - "./.env.test", - "./phpunit.xml.dist", - "./tests/bootstrap.php" + ".env.test", + "phpunit.xml.dist", + "tests/bootstrap.php" ] }, "symfony/console": { @@ -50,22 +48,22 @@ ] }, "symfony/framework-bundle": { - "version": "6.1", + "version": "7.0", "recipe": { "repo": "github.com/symfony/recipes", "branch": "main", - "version": "5.4", - "ref": "3cd216a4d007b78d8554d44a5b1c0a446dab24fb" + "version": "7.0", + "ref": "de6e1b3e2bbbe69e36262d72c3f3db858b1ab391" }, "files": [ - "./config/packages/cache.yaml", - "./config/packages/framework.yaml", - "./config/preload.php", - "./config/routes/framework.yaml", - "./config/services.yaml", - "./public/index.php", - "./src/Controller/.gitignore", - "./src/Kernel.php" + "config/packages/cache.yaml", + "config/packages/framework.yaml", + "config/preload.php", + "config/routes/framework.yaml", + "config/services.yaml", + "public/index.php", + "src/Controller/.gitignore", + "src/Kernel.php" ] }, "symfony/maker-bundle": { @@ -78,31 +76,31 @@ } }, "symfony/phpunit-bridge": { - "version": "6.1", + "version": "6.4", "recipe": { "repo": "github.com/symfony/recipes", "branch": "main", - "version": "5.3", - "ref": "97cb3dc7b0f39c7cfc4b7553504c9d7b7795de96" + "version": "6.3", + "ref": "1f5830c331065b6e4c9d5fa2105e322d29fcd573" }, "files": [ - "./.env.test", - "./bin/phpunit", - "./phpunit.xml.dist", - "./tests/bootstrap.php" + ".env.test", + "bin/phpunit", + "phpunit.xml.dist", + "tests/bootstrap.php" ] }, "symfony/routing": { - "version": "6.1", + "version": "7.0", "recipe": { "repo": "github.com/symfony/recipes", "branch": "main", - "version": "6.1", - "ref": "a44010c0d06989bd4f154aa07d2542d47caf5b83" + "version": "6.2", + "ref": "e0a11b4ccb8c9e70b574ff5ad3dfdcd41dec5aa6" }, "files": [ - "./config/packages/routing.yaml", - "./config/routes.yaml" + "config/packages/routing.yaml", + "config/routes.yaml" ] } } diff --git a/fixture-app/tests/bootstrap.php b/fixture-app/tests/bootstrap.php index 469dcce..3181151 100644 --- a/fixture-app/tests/bootstrap.php +++ b/fixture-app/tests/bootstrap.php @@ -9,3 +9,7 @@ } elseif (method_exists(Dotenv::class, 'bootEnv')) { (new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); } + +if ($_SERVER['APP_DEBUG']) { + umask(0000); +} diff --git a/phpunit-9.5.xml b/phpunit-9.6.xml similarity index 100% rename from phpunit-9.5.xml rename to phpunit-9.6.xml