Skip to content

Commit 28a1696

Browse files
committed
fix version dependent errors
1 parent 3f82a55 commit 28a1696

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

tests/PHPStan/Rules/Variables/UnsetRuleTest.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PHPStan\Rules\Properties\PropertyReflectionFinder;
77
use PHPStan\Rules\Rule;
88
use PHPStan\Testing\RuleTestCase;
9+
use function array_merge;
910
use const PHP_VERSION_ID;
1011

1112
/**
@@ -60,12 +61,16 @@ public function testBug2752(): void
6061

6162
public function testBug4289(): void
6263
{
63-
$this->analyse([__DIR__ . '/data/bug-4289.php'], [
64-
[
65-
'Cannot unset Bug4289\BaseClass::$fields property which might get hooked in subclass.',
66-
25,
67-
],
68-
]);
64+
if (PHP_VERSION_ID < 80400) {
65+
$this->analyse([__DIR__ . '/data/bug-4289.php'], []);
66+
} else {
67+
$this->analyse([__DIR__ . '/data/bug-4289.php'], [
68+
[
69+
'Cannot unset Bug4289\BaseClass::$fields property which might get hooked in subclass.',
70+
25,
71+
],
72+
]);
73+
}
6974
}
7075

7176
public function testBug5223(): void
@@ -104,11 +109,15 @@ public function testBug4565(): void
104109

105110
public function testBug12421(): void
106111
{
107-
$this->analyse([__DIR__ . '/data/bug-12421.php'], [
108-
[
112+
$errors = [];
113+
if (PHP_VERSION_ID >= 80400) {
114+
$errors[] = [
109115
'Cannot unset Bug12421\RegularProperty::$y property which might get hooked in subclass.',
110116
7,
111-
],
117+
];
118+
}
119+
120+
$errors = array_merge($errors, [
112121
[
113122
'Cannot unset readonly Bug12421\NativeReadonlyClass::$y property.',
114123
11,
@@ -134,6 +143,8 @@ public function testBug12421(): void
134143
34,
135144
],
136145
]);
146+
147+
$this->analyse([__DIR__ . '/data/bug-12421.php'], $errors);
137148
}
138149

139150
public function testUnsetHookedProperty(): void

0 commit comments

Comments
 (0)