From c6a68dc7c971bb92f664075a958fcf0d89ec5259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81re=CC=81my=20DECOOL?= Date: Mon, 15 Nov 2021 12:55:33 +0100 Subject: [PATCH 1/2] Add PHPStan 1.0 compatibility --- composer.json | 2 +- tests/Reflection/EnumMethodsClassReflectionExtensionTest.php | 4 ++-- tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 18e748f..0072630 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "require": { "php": "~7.1|^8.0", "myclabs/php-enum": "^1.2", - "phpstan/phpstan": "^0.12.84" + "phpstan/phpstan": "^1.0" }, "require-dev": { "phpunit/phpunit": "^7.0|^9.0" diff --git a/tests/Reflection/EnumMethodsClassReflectionExtensionTest.php b/tests/Reflection/EnumMethodsClassReflectionExtensionTest.php index b3afb1d..434c085 100644 --- a/tests/Reflection/EnumMethodsClassReflectionExtensionTest.php +++ b/tests/Reflection/EnumMethodsClassReflectionExtensionTest.php @@ -5,7 +5,7 @@ namespace Timeweb\Tests\PHPStan\Reflection; use PHPStan\Reflection\ParametersAcceptorSelector; -use PHPStan\Testing\TestCase; +use PHPStan\Testing\PHPStanTestCase; use PHPStan\Type\VerbosityLevel; use Timeweb\PHPStan\Reflection\EnumMethodReflection; use Timeweb\PHPStan\Reflection\EnumMethodsClassReflectionExtension; @@ -14,7 +14,7 @@ /** * @coversDefaultClass \Timeweb\PHPStan\Reflection\EnumMethodsClassReflectionExtension */ -class EnumMethodsClassReflectionExtensionTest extends TestCase +class EnumMethodsClassReflectionExtensionTest extends PHPStanTestCase { /** * @var \PHPStan\Broker\Broker diff --git a/tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php b/tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php index 0fcfcb9..0883a43 100644 --- a/tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php +++ b/tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php @@ -4,14 +4,14 @@ namespace Timeweb\Tests\PHPStan\Rule; -use PHPStan\Testing\TestCase; +use PHPStan\Testing\PHPStanTestCase; use Timeweb\PHPStan\Rule\EnumAlwaysUsedConstantsExtension; use Timeweb\Tests\PHPStan\Fixture\EnumFixture; /** * @coversDefaultClass \Timeweb\PHPStan\Rule\EnumAlwaysUsedConstantsExtension */ -class EnumAlwaysUsedConstantsExtensionTest extends TestCase +class EnumAlwaysUsedConstantsExtensionTest extends PHPStanTestCase { /** * @var \PHPStan\Broker\Broker From e19393f9fdbf86507a77a5a42c5715a2e59e5ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81re=CC=81my=20DECOOL?= Date: Mon, 15 Nov 2021 12:59:06 +0100 Subject: [PATCH 2/2] Replace usage of deprecated Broken with ReflectionProvider --- .../EnumMethodsClassReflectionExtensionTest.php | 14 +++++++------- .../Rule/EnumAlwaysUsedConstantsExtensionTest.php | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Reflection/EnumMethodsClassReflectionExtensionTest.php b/tests/Reflection/EnumMethodsClassReflectionExtensionTest.php index 434c085..70cb63e 100644 --- a/tests/Reflection/EnumMethodsClassReflectionExtensionTest.php +++ b/tests/Reflection/EnumMethodsClassReflectionExtensionTest.php @@ -17,9 +17,9 @@ class EnumMethodsClassReflectionExtensionTest extends PHPStanTestCase { /** - * @var \PHPStan\Broker\Broker + * @var \PHPStan\Reflection\ReflectionProvider */ - protected $broker; + protected $reflectionProvider; /** * @var EnumMethodsClassReflectionExtension @@ -28,7 +28,7 @@ class EnumMethodsClassReflectionExtensionTest extends PHPStanTestCase public function setUp(): void { - $this->broker = $this->createBroker(); + $this->reflectionProvider = $this->createReflectionProvider(); $this->reflectionExtension = new EnumMethodsClassReflectionExtension(); } @@ -38,7 +38,7 @@ public function setUp(): void */ public function testEnumMethodsCanBeFoundInEnumSubclasses(bool $expected, string $methodName): void { - $classReflection = $this->broker->getClass(EnumFixture::class); + $classReflection = $this->reflectionProvider->getClass(EnumFixture::class); $hasMethod = $this->reflectionExtension->hasMethod($classReflection, $methodName); $this->assertEquals($expected, $hasMethod); @@ -60,7 +60,7 @@ public function methodNameDataProvider(): array */ public function testEnumMethodsCannotBeFoundInNonEnumSubclasses(): void { - $classReflection = $this->broker->getClass(EnumFixture::class); + $classReflection = $this->reflectionProvider->getClass(EnumFixture::class); $hasMethod = $this->reflectionExtension->hasMethod($classReflection, 'SOME_NAME'); $this->assertFalse($hasMethod); @@ -72,7 +72,7 @@ public function testEnumMethodsCannotBeFoundInNonEnumSubclasses(): void */ public function testEnumMethodReflectionCanBeObtained(): void { - $classReflection = $this->broker->getClass(EnumFixture::class); + $classReflection = $this->reflectionProvider->getClass(EnumFixture::class); $methodReflection = $this->reflectionExtension->getMethod($classReflection, 'SOME_NAME'); $this->assertInstanceOf(EnumMethodReflection::class, $methodReflection); @@ -91,7 +91,7 @@ public function testEnumMethodReflectionCanBeObtained(): void */ public function testEnumMethodProperties(string $propertyName): void { - $classReflection = $this->broker->getClass(EnumFixture::class); + $classReflection = $this->reflectionProvider->getClass(EnumFixture::class); $methodReflection = $this->reflectionExtension->getMethod($classReflection, $propertyName); $parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants()); diff --git a/tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php b/tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php index 0883a43..ea046ee 100644 --- a/tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php +++ b/tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php @@ -14,9 +14,9 @@ class EnumAlwaysUsedConstantsExtensionTest extends PHPStanTestCase { /** - * @var \PHPStan\Broker\Broker + * @var \PHPStan\Reflection\ReflectionProvider */ - protected $broker; + protected $reflectionProvider; /** * @var EnumAlwaysUsedConstantsExtension @@ -25,7 +25,7 @@ class EnumAlwaysUsedConstantsExtensionTest extends PHPStanTestCase public function setUp(): void { - $this->broker = $this->createBroker(); + $this->reflectionProvider = $this->createReflectionProvider(); $this->constantsExtension = new EnumAlwaysUsedConstantsExtension(); } @@ -35,7 +35,7 @@ public function setUp(): void */ public function testEnumConstantsAreConsideredAsAlwaysUsed(string $constantName): void { - $classReflection = $this->broker->getClass(EnumFixture::class); + $classReflection = $this->reflectionProvider->getClass(EnumFixture::class); $constantReflection = $classReflection->getConstant($constantName); $this->assertTrue($this->constantsExtension->isAlwaysUsed($constantReflection));