Skip to content

Commit 48ddcfd

Browse files
committed
Stop using deprecated Broker in favor of ReflectionProvider
1 parent 35f28c5 commit 48ddcfd

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

tests/unit/EnumMethodReflectionTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
class EnumMethodReflectionTest extends PHPStanTestCase
1414
{
1515
/**
16-
* @var \PHPStan\Broker\Broker
16+
* @var \PHPStan\Reflection\ReflectionProvider
1717
*/
18-
protected $broker;
18+
protected $reflectionProvider;
1919

2020
/**
2121
* @var EnumMethodsClassReflectionExtension
@@ -24,61 +24,61 @@ class EnumMethodReflectionTest extends PHPStanTestCase
2424

2525
public function setUp(): void
2626
{
27-
$this->broker = $this->createBroker();
27+
$this->reflectionProvider = $this->createReflectionProvider();
2828
$this->reflectionExtension = new EnumMethodsClassReflectionExtension();
2929
}
3030

3131
public function testGetName(): void
3232
{
33-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
33+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
3434
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
3535

3636
$this->assertSame('STR', $methodReflection->getName());
3737
}
3838

3939
public function testGetDeclaringClass(): void
4040
{
41-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
41+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
4242
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
4343

4444
$this->assertSame($classReflection, $methodReflection->getDeclaringClass());
4545
}
4646

4747
public function testShouldBeStatic(): void
4848
{
49-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
49+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
5050
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
5151

5252
$this->assertTrue($methodReflection->isStatic());
5353
}
5454

5555
public function testShouldNotBePrivate(): void
5656
{
57-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
57+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
5858
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
5959

6060
$this->assertFalse($methodReflection->isPrivate());
6161
}
6262

6363
public function testShouldBePublic(): void
6464
{
65-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
65+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
6666
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
6767

6868
$this->assertTrue($methodReflection->isPublic());
6969
}
7070

7171
public function testGetPrototype(): void
7272
{
73-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
73+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
7474
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
7575

7676
$this->assertSame($methodReflection, $methodReflection->getPrototype());
7777
}
7878

7979
public function testGetVariants(): void
8080
{
81-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
81+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
8282
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
8383
$parametersAcceptor = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants());
8484

@@ -87,7 +87,7 @@ public function testGetVariants(): void
8787

8888
public function testGetDocComment(): void
8989
{
90-
$classReflection = $this->broker->getClass(DocCommentEnum::class);
90+
$classReflection = $this->reflectionProvider->getClass(DocCommentEnum::class);
9191
$docMethodRefl = $this->reflectionExtension->getMethod($classReflection, 'WITH_DOC_BLOCK');
9292
$noDocMethodRefl = $this->reflectionExtension->getMethod($classReflection, 'WITHOUT_DOC_BLOCK');
9393

@@ -103,7 +103,7 @@ public function testGetDocComment(): void
103103

104104
public function testIsDeprecated(): void
105105
{
106-
$classReflection = $this->broker->getClass(DeprecatedEnum::class);
106+
$classReflection = $this->reflectionProvider->getClass(DeprecatedEnum::class);
107107
$deprecatedRefl = $this->reflectionExtension->getMethod($classReflection, 'DEPRECATED');
108108
$notDeprecatedRefl = $this->reflectionExtension->getMethod($classReflection, 'NOT_DEPRECATED');
109109

@@ -113,7 +113,7 @@ public function testIsDeprecated(): void
113113

114114
public function testGetDeprecatedDescription(): void
115115
{
116-
$classReflection = $this->broker->getClass(DeprecatedEnum::class);
116+
$classReflection = $this->reflectionProvider->getClass(DeprecatedEnum::class);
117117
$deprecatedRefl = $this->reflectionExtension->getMethod($classReflection, 'DEPRECATED');
118118
$notDeprecatedRefl = $this->reflectionExtension->getMethod($classReflection, 'NOT_DEPRECATED');
119119

@@ -123,31 +123,31 @@ public function testGetDeprecatedDescription(): void
123123

124124
public function testIsFinal(): void
125125
{
126-
$classReflection = $this->broker->getClass(DeprecatedEnum::class);
126+
$classReflection = $this->reflectionProvider->getClass(DeprecatedEnum::class);
127127
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
128128

129129
$this->assertTrue($methodReflection->isFinal()->no());
130130
}
131131

132132
public function testIsInternal(): void
133133
{
134-
$classReflection = $this->broker->getClass(DeprecatedEnum::class);
134+
$classReflection = $this->reflectionProvider->getClass(DeprecatedEnum::class);
135135
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
136136

137137
$this->assertTrue($methodReflection->isInternal()->no());
138138
}
139139

140140
public function testGetThrowType(): void
141141
{
142-
$classReflection = $this->broker->getClass(DeprecatedEnum::class);
142+
$classReflection = $this->reflectionProvider->getClass(DeprecatedEnum::class);
143143
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
144144

145145
$this->assertNull($methodReflection->getThrowType());
146146
}
147147

148148
public function testHasSideEffects(): void
149149
{
150-
$classReflection = $this->broker->getClass(DeprecatedEnum::class);
150+
$classReflection = $this->reflectionProvider->getClass(DeprecatedEnum::class);
151151
$methodReflection = $this->reflectionExtension->getMethod($classReflection, 'STR');
152152

153153
$this->assertTrue($methodReflection->hasSideEffects()->no());

tests/unit/EnumMethodsClassReflectionExtensionTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
class EnumMethodsClassReflectionExtensionTest extends PHPStanTestCase
1212
{
1313
/**
14-
* @var \PHPStan\Broker\Broker
14+
* @var \PHPStan\Reflection\ReflectionProvider
1515
*/
16-
protected $broker;
16+
protected $reflectionProvider;
1717

1818
/**
1919
* @var EnumMethodsClassReflectionExtension
@@ -22,13 +22,13 @@ class EnumMethodsClassReflectionExtensionTest extends PHPStanTestCase
2222

2323
public function setUp(): void
2424
{
25-
$this->broker = $this->createBroker();
25+
$this->reflectionProvider = $this->createReflectionProvider();
2626
$this->extension = new EnumMethodsClassReflectionExtension();
2727
}
2828

2929
public function testHasMethodSuccess(): void
3030
{
31-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
31+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
3232

3333
foreach (array_keys(VisibilityEnum::getConstants()) as $name) {
3434
$this->assertTrue($this->extension->hasMethod($classReflection, $name));
@@ -37,19 +37,19 @@ public function testHasMethodSuccess(): void
3737

3838
public function testHasMethodUnknownNotFound(): void
3939
{
40-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
40+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
4141
$this->assertFalse($this->extension->hasMethod($classReflection, 'UNKNOWN'));
4242
}
4343

4444
public function testHasMethodNotSubclassOfEnumNotFound(): void
4545
{
46-
$classReflection = $this->broker->getClass(NotAnEnum::class);
46+
$classReflection = $this->reflectionProvider->getClass(NotAnEnum::class);
4747
$this->assertFalse($this->extension->hasMethod($classReflection, 'STR'));
4848
}
4949

5050
public function testGetMethodSuccess(): void
5151
{
52-
$classReflection = $this->broker->getClass(VisibilityEnum::class);
52+
$classReflection = $this->reflectionProvider->getClass(VisibilityEnum::class);
5353

5454
foreach (array_keys(VisibilityEnum::getConstants()) as $name) {
5555
$methodReflection = $this->extension->getMethod($classReflection, $name);

0 commit comments

Comments
 (0)