From 866bbbf26dd16b2d5f9d7de2702916841b74d180 Mon Sep 17 00:00:00 2001 From: David Maicher Date: Fri, 13 Dec 2024 11:22:45 +0100 Subject: [PATCH] upgrade to phpstan ^2 (#309) --- .php-cs-fixer.php | 1 + composer.json | 4 ++-- phpstan.neon | 1 - .../Doctrine/DBAL/StaticConnectionTrait.php | 2 ++ .../DoctrineTestBundle/PHPUnit/PHPUnitExtension.php | 12 ++++++------ .../Doctrine/DBAL/MockDriverTrait.php | 3 +++ tests/Functional/PhpunitTest.php | 2 +- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 89baf70..ed7aad9 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -18,5 +18,6 @@ ], 'phpdoc_var_annotation_correct_order' => true, 'void_return' => true, + 'trailing_comma_in_multiline' => false, ]) ; diff --git a/composer.json b/composer.json index 159923d..1b236ce 100644 --- a/composer.json +++ b/composer.json @@ -28,9 +28,9 @@ "require-dev": { "behat/behat": "^3.0", "friendsofphp/php-cs-fixer": "^3.27", - "phpstan/phpstan": "^1.2", + "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^8.0 || ^9.0 || ^10.0 || ^11.0", - "symfony/phpunit-bridge": "^6.3", + "symfony/phpunit-bridge": "^7.2", "symfony/process": "^5.4 || ^6.3 || ^7.0", "symfony/yaml": "^5.4 || ^6.3 || ^7.0" }, diff --git a/phpstan.neon b/phpstan.neon index 4bc85c4..1349e0f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,6 @@ parameters: treatPhpDocTypesAsCertain: false excludePaths: - %currentWorkingDirectory%/src/DAMA/DoctrineTestBundle/DependencyInjection/Configuration.php - - %currentWorkingDirectory%/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitListener.php - %currentWorkingDirectory%/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitExtension.php - %currentWorkingDirectory%/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriver.php - %currentWorkingDirectory%/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticConnection.php diff --git a/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticConnectionTrait.php b/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticConnectionTrait.php index a6fc1f2..199f258 100644 --- a/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticConnectionTrait.php +++ b/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticConnectionTrait.php @@ -7,6 +7,8 @@ /** * @internal + * + * @phpstan-ignore trait.unused */ trait StaticConnectionTrait { diff --git a/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitExtension.php b/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitExtension.php index d34ac52..e0d6c99 100644 --- a/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitExtension.php +++ b/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitExtension.php @@ -44,14 +44,14 @@ public static function rollBack(): void public function bootstrap(Configuration $configuration, Facade $facade, ParameterCollection $parameters): void { - $facade->registerSubscriber(new class() implements TestRunnerStartedSubscriber { + $facade->registerSubscriber(new class implements TestRunnerStartedSubscriber { public function notify(TestRunnerStartedEvent $event): void { StaticDriver::setKeepStaticConnections(true); } }); - $facade->registerSubscriber(new class() implements TestStartedSubscriber { + $facade->registerSubscriber(new class implements TestStartedSubscriber { public function notify(TestStartedEvent $event): void { StaticDriver::beginTransaction(); @@ -59,7 +59,7 @@ public function notify(TestStartedEvent $event): void } }); - $facade->registerSubscriber(new class() implements SkippedSubscriber { + $facade->registerSubscriber(new class implements SkippedSubscriber { public function notify(Skipped $event): void { // this is a workaround to allow skipping tests within the setUp() method @@ -68,14 +68,14 @@ public function notify(Skipped $event): void } }); - $facade->registerSubscriber(new class() implements TestFinishedSubscriber { + $facade->registerSubscriber(new class implements TestFinishedSubscriber { public function notify(TestFinishedEvent $event): void { PHPUnitExtension::rollBack(); } }); - $facade->registerSubscriber(new class() implements ErroredSubscriber { + $facade->registerSubscriber(new class implements ErroredSubscriber { public function notify(Errored $event): void { // needed as for errored tests the "Finished" event is not triggered @@ -83,7 +83,7 @@ public function notify(Errored $event): void } }); - $facade->registerSubscriber(new class() implements TestRunnerFinishedSubscriber { + $facade->registerSubscriber(new class implements TestRunnerFinishedSubscriber { public function notify(TestRunnerFinishedEvent $event): void { StaticDriver::setKeepStaticConnections(false); diff --git a/tests/DAMA/DoctrineTestBundle/Doctrine/DBAL/MockDriverTrait.php b/tests/DAMA/DoctrineTestBundle/Doctrine/DBAL/MockDriverTrait.php index c1c03a8..46f314a 100644 --- a/tests/DAMA/DoctrineTestBundle/Doctrine/DBAL/MockDriverTrait.php +++ b/tests/DAMA/DoctrineTestBundle/Doctrine/DBAL/MockDriverTrait.php @@ -8,6 +8,9 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\AbstractSchemaManager; +/** + * @phpstan-ignore trait.unused + */ trait MockDriverTrait { private $connection; diff --git a/tests/Functional/PhpunitTest.php b/tests/Functional/PhpunitTest.php index f27c3bc..15655bb 100644 --- a/tests/Functional/PhpunitTest.php +++ b/tests/Functional/PhpunitTest.php @@ -144,7 +144,7 @@ public function testSkippedTest(): void public function testSkippedTestDuringSetup(): void { - $this->assertTrue(true); + $this->expectNotToPerformAssertions(); } public function testMarkIncomplete(): void