Skip to content

Commit f2b10a5

Browse files
authored
Add PHPStan 1.0 compatibility (#25)
* Add PHPStan 1.0 compatibility * Replace usage of deprecated Broken with ReflectionProvider
1 parent 2c7a3d5 commit f2b10a5

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"require": {
88
"php": "~7.1|^8.0",
99
"myclabs/php-enum": "^1.2",
10-
"phpstan/phpstan": "^0.12.84"
10+
"phpstan/phpstan": "^1.0"
1111
},
1212
"require-dev": {
1313
"phpunit/phpunit": "^7.0|^9.0"

tests/Reflection/EnumMethodsClassReflectionExtensionTest.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Timeweb\Tests\PHPStan\Reflection;
66

77
use PHPStan\Reflection\ParametersAcceptorSelector;
8-
use PHPStan\Testing\TestCase;
8+
use PHPStan\Testing\PHPStanTestCase;
99
use PHPStan\Type\VerbosityLevel;
1010
use Timeweb\PHPStan\Reflection\EnumMethodReflection;
1111
use Timeweb\PHPStan\Reflection\EnumMethodsClassReflectionExtension;
@@ -14,12 +14,12 @@
1414
/**
1515
* @coversDefaultClass \Timeweb\PHPStan\Reflection\EnumMethodsClassReflectionExtension
1616
*/
17-
class EnumMethodsClassReflectionExtensionTest extends TestCase
17+
class EnumMethodsClassReflectionExtensionTest extends PHPStanTestCase
1818
{
1919
/**
20-
* @var \PHPStan\Broker\Broker
20+
* @var \PHPStan\Reflection\ReflectionProvider
2121
*/
22-
protected $broker;
22+
protected $reflectionProvider;
2323

2424
/**
2525
* @var EnumMethodsClassReflectionExtension
@@ -28,7 +28,7 @@ class EnumMethodsClassReflectionExtensionTest extends TestCase
2828

2929
public function setUp(): void
3030
{
31-
$this->broker = $this->createBroker();
31+
$this->reflectionProvider = $this->createReflectionProvider();
3232
$this->reflectionExtension = new EnumMethodsClassReflectionExtension();
3333
}
3434

@@ -38,7 +38,7 @@ public function setUp(): void
3838
*/
3939
public function testEnumMethodsCanBeFoundInEnumSubclasses(bool $expected, string $methodName): void
4040
{
41-
$classReflection = $this->broker->getClass(EnumFixture::class);
41+
$classReflection = $this->reflectionProvider->getClass(EnumFixture::class);
4242
$hasMethod = $this->reflectionExtension->hasMethod($classReflection, $methodName);
4343

4444
$this->assertEquals($expected, $hasMethod);
@@ -60,7 +60,7 @@ public function methodNameDataProvider(): array
6060
*/
6161
public function testEnumMethodsCannotBeFoundInNonEnumSubclasses(): void
6262
{
63-
$classReflection = $this->broker->getClass(EnumFixture::class);
63+
$classReflection = $this->reflectionProvider->getClass(EnumFixture::class);
6464
$hasMethod = $this->reflectionExtension->hasMethod($classReflection, 'SOME_NAME');
6565

6666
$this->assertFalse($hasMethod);
@@ -72,7 +72,7 @@ public function testEnumMethodsCannotBeFoundInNonEnumSubclasses(): void
7272
*/
7373
public function testEnumMethodReflectionCanBeObtained(): void
7474
{
75-
$classReflection = $this->broker->getClass(EnumFixture::class);
75+
$classReflection = $this->reflectionProvider->getClass(EnumFixture::class);
7676
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'SOME_NAME');
7777

7878
$this->assertInstanceOf(EnumMethodReflection::class, $methodReflection);
@@ -91,7 +91,7 @@ public function testEnumMethodReflectionCanBeObtained(): void
9191
*/
9292
public function testEnumMethodProperties(string $propertyName): void
9393
{
94-
$classReflection = $this->broker->getClass(EnumFixture::class);
94+
$classReflection = $this->reflectionProvider->getClass(EnumFixture::class);
9595
$methodReflection = $this->reflectionExtension->getMethod($classReflection, $propertyName);
9696
$parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants());
9797

tests/Rule/EnumAlwaysUsedConstantsExtensionTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
namespace Timeweb\Tests\PHPStan\Rule;
66

7-
use PHPStan\Testing\TestCase;
7+
use PHPStan\Testing\PHPStanTestCase;
88
use Timeweb\PHPStan\Rule\EnumAlwaysUsedConstantsExtension;
99
use Timeweb\Tests\PHPStan\Fixture\EnumFixture;
1010

1111
/**
1212
* @coversDefaultClass \Timeweb\PHPStan\Rule\EnumAlwaysUsedConstantsExtension
1313
*/
14-
class EnumAlwaysUsedConstantsExtensionTest extends TestCase
14+
class EnumAlwaysUsedConstantsExtensionTest extends PHPStanTestCase
1515
{
1616
/**
17-
* @var \PHPStan\Broker\Broker
17+
* @var \PHPStan\Reflection\ReflectionProvider
1818
*/
19-
protected $broker;
19+
protected $reflectionProvider;
2020

2121
/**
2222
* @var EnumAlwaysUsedConstantsExtension
@@ -25,7 +25,7 @@ class EnumAlwaysUsedConstantsExtensionTest extends TestCase
2525

2626
public function setUp(): void
2727
{
28-
$this->broker = $this->createBroker();
28+
$this->reflectionProvider = $this->createReflectionProvider();
2929
$this->constantsExtension = new EnumAlwaysUsedConstantsExtension();
3030
}
3131

@@ -35,7 +35,7 @@ public function setUp(): void
3535
*/
3636
public function testEnumConstantsAreConsideredAsAlwaysUsed(string $constantName): void
3737
{
38-
$classReflection = $this->broker->getClass(EnumFixture::class);
38+
$classReflection = $this->reflectionProvider->getClass(EnumFixture::class);
3939
$constantReflection = $classReflection->getConstant($constantName);
4040

4141
$this->assertTrue($this->constantsExtension->isAlwaysUsed($constantReflection));

0 commit comments

Comments
 (0)