From 1b0075a02459bbb61b2c9dd6d7a89824ff46a833 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Thu, 16 May 2024 10:47:15 +0200 Subject: [PATCH] Add PHP 8.3 support (#7) --- .github/workflows/test-application.yaml | 6 ++++++ .gitignore | 2 ++ composer.json | 4 ++-- phpstan.neon => phpstan.dist.neon | 0 rector.php | 17 +++++++++++------ .../FlushMiddleware/DoctrineFlushMiddleware.php | 2 +- .../UnpackExceptionMiddlewareTest.php | 2 +- 7 files changed, 23 insertions(+), 10 deletions(-) rename phpstan.neon => phpstan.dist.neon (100%) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 2e23e78..b25d300 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -37,6 +37,12 @@ jobs: env: SYMFONY_DEPRECATIONS_HELPER: weak + - php-version: '8.3' + coverage: true + dependency-versions: 'highest' + env: + SYMFONY_DEPRECATIONS_HELPER: weak + services: mysql: image: mysql:5.7 diff --git a/.gitignore b/.gitignore index 20bcd78..5c3d8a3 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ composer.lock /tests/Application/var /tests/Application/secrets + +phpstan.neon diff --git a/composer.json b/composer.json index 4f848e4..a6d0dc9 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "proprietary", "type": "sulu-bundle", "require": { - "php": "8.0.* || 8.1.* || 8.2.*", + "php": "8.0.* || 8.1.* || 8.2.* || 8.3.*", "doctrine/dbal": "^3.3", "doctrine/doctrine-bundle": "^2.5", "doctrine/orm": "^2.11", @@ -32,7 +32,7 @@ "phpstan/phpstan-webmozart-assert": "^1.0", "phpunit/phpunit": "^9.5", "qossmic/deptrac-shim": "^0.24.0 || ^1.0", - "rector/rector": "^0.15.0", + "rector/rector": "^1.0", "schranz/test-generator": "^0.4", "symfony/browser-kit": "^5.4 || ^6.0 || ^7.0", "symfony/css-selector": "^5.4 || ^6.0 || ^7.0", diff --git a/phpstan.neon b/phpstan.dist.neon similarity index 100% rename from phpstan.neon rename to phpstan.dist.neon diff --git a/rector.php b/rector.php index ffcbde9..c024817 100644 --- a/rector.php +++ b/rector.php @@ -17,20 +17,25 @@ __DIR__ . '/tests', ]); + $rectorConfig->phpstanConfigs([ + __DIR__ . '/phpstan.dist.neon', + // rector does not load phpstan extension automatically so require them manually here: + __DIR__ . '/vendor/phpstan/phpstan-doctrine/extension.neon', + __DIR__ . '/vendor/phpstan/phpstan-symfony/extension.neon', + ]); + $rectorConfig->skip([ __DIR__ . '/tests/Application/var', __DIR__ . '/tests/Application/config', ]); - $rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon'); - // basic rules $rectorConfig->importNames(); $rectorConfig->importShortClasses(false); $rectorConfig->sets([ SetList::CODE_QUALITY, - LevelSetList::UP_TO_PHP_80, + // LevelSetList::UP_TO_PHP_80, ]); // symfony rules @@ -39,7 +44,7 @@ $rectorConfig->sets([ SymfonySetList::SYMFONY_CODE_QUALITY, SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION, - SymfonyLevelSetList::UP_TO_SYMFONY_54, + // SymfonyLevelSetList::UP_TO_SYMFONY_54, ]); // doctrine rules @@ -49,7 +54,7 @@ // phpunit rules $rectorConfig->sets([ - PHPUnitLevelSetList::UP_TO_PHPUNIT_90, - PHPUnitSetList::PHPUNIT_91, + // PHPUnitLevelSetList::UP_TO_PHPUNIT_90, + // PHPUnitSetList::PHPUNIT_91, ]); }; diff --git a/src/Infrastructure/Symfony/Messenger/FlushMiddleware/DoctrineFlushMiddleware.php b/src/Infrastructure/Symfony/Messenger/FlushMiddleware/DoctrineFlushMiddleware.php index b2d19a1..7a5a259 100644 --- a/src/Infrastructure/Symfony/Messenger/FlushMiddleware/DoctrineFlushMiddleware.php +++ b/src/Infrastructure/Symfony/Messenger/FlushMiddleware/DoctrineFlushMiddleware.php @@ -22,7 +22,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope $envelope = $stack->next()->handle($envelope, $stack); // flush unit-of-work to the database after the root message was handled successfully - if (!empty($envelope->all(EnableFlushStamp::class))) { + if ([] !== $envelope->all(EnableFlushStamp::class)) { $this->container->get('doctrine.orm.entity_manager')->flush(); } diff --git a/tests/Unit/Infrastructure/Symfony/Messenger/UnpackExceptionMiddleware/UnpackExceptionMiddlewareTest.php b/tests/Unit/Infrastructure/Symfony/Messenger/UnpackExceptionMiddleware/UnpackExceptionMiddlewareTest.php index b4f2f22..ffabbf1 100644 --- a/tests/Unit/Infrastructure/Symfony/Messenger/UnpackExceptionMiddleware/UnpackExceptionMiddlewareTest.php +++ b/tests/Unit/Infrastructure/Symfony/Messenger/UnpackExceptionMiddleware/UnpackExceptionMiddlewareTest.php @@ -56,7 +56,7 @@ private function createEnvelope(): Envelope return new Envelope(new \stdClass()); } - private function createStack(callable $handler = null): StackMiddleware + private function createStack(?callable $handler = null): StackMiddleware { if (!$handler) { return new StackMiddleware([]);