From b294c16651f833b84b11503e8cc71d8ba460935c Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Thu, 16 May 2024 10:39:09 +0200 Subject: [PATCH] Fix current CI issues --- .gitignore | 2 ++ composer.json | 2 +- phpstan.neon => phpstan.dist.neon | 0 rector.php | 17 +++++++++++------ .../FlushMiddleware/DoctrineFlushMiddleware.php | 2 +- .../UnpackExceptionMiddlewareTest.php | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-) rename phpstan.neon => phpstan.dist.neon (100%) 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 1149282..a6d0dc9 100644 --- a/composer.json +++ b/composer.json @@ -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([]);