Skip to content

Commit 113fed0

Browse files
committed
Fix build
1 parent dcbadfa commit 113fed0

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

tests/PHPStan/Rules/Api/RuntimeReflectionInstantiationRuleTest.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PHPStan\Rules\Rule;
66
use PHPStan\Testing\RuleTestCase;
7+
use const PHP_VERSION_ID;
78

89
/**
910
* @extends RuleTestCase<RuntimeReflectionInstantiationRule>
@@ -18,7 +19,7 @@ protected function getRule(): Rule
1819

1920
public function testRule(): void
2021
{
21-
$this->analyse([__DIR__ . '/data/runtime-reflection-instantiation.php'], [
22+
$errors = [
2223
[
2324
'Creating new ReflectionMethod is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
2425
43,
@@ -31,14 +32,6 @@ public function testRule(): void
3132
'Creating new ReflectionClassConstant is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
3233
45,
3334
],
34-
[
35-
'Creating new ReflectionEnum is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
36-
46,
37-
],
38-
[
39-
'Creating new ReflectionEnumBackedCase is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
40-
47,
41-
],
4235
[
4336
'Creating new ReflectionZendExtension is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
4437
48,
@@ -67,11 +60,22 @@ public function testRule(): void
6760
'Creating new ReflectionGenerator is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
6861
54,
6962
],
70-
[
63+
];
64+
if (PHP_VERSION_ID >= 80100) {
65+
$errors[] = [
7166
'Creating new ReflectionFiber is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
7267
55,
73-
],
74-
]);
68+
];
69+
$errors[] = [
70+
'Creating new ReflectionEnum is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
71+
56,
72+
];
73+
$errors[] = [
74+
'Creating new ReflectionEnumBackedCase is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine. Use objects retrieved from ReflectionProvider instead.',
75+
57,
76+
];
77+
}
78+
$this->analyse([__DIR__ . '/data/runtime-reflection-instantiation.php'], $errors);
7579
}
7680

7781
}

tests/PHPStan/Rules/Api/data/runtime-reflection-instantiation.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public function doFoo(object $o, \Fiber $f, \Generator $g): void
4343
new \ReflectionMethod($o, 'foo');
4444
new \ReflectionClass(\stdClass::class);
4545
new \ReflectionClassConstant(\stdClass::class, 'foo');
46-
new \ReflectionEnum(\stdClass::class);
47-
new \ReflectionEnumBackedCase(\stdClass::class, 'foo');
46+
47+
4848
new \ReflectionZendExtension('foo');
4949
new \ReflectionExtension('foo');
5050
new \ReflectionFunction('foo');
@@ -53,6 +53,8 @@ public function doFoo(object $o, \Fiber $f, \Generator $g): void
5353
new \ReflectionProperty(\stdClass::class, 'foo');
5454
new \ReflectionGenerator($g);
5555
new \ReflectionFiber($f);
56+
new \ReflectionEnum(\stdClass::class);
57+
new \ReflectionEnumBackedCase(\stdClass::class, 'foo');
5658
}
5759

5860
}

0 commit comments

Comments
 (0)