Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions tests/PHPStan/Rules/Variables/UnsetRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\Rules\Properties\PropertyReflectionFinder;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use function array_merge;
use const PHP_VERSION_ID;

/**
Expand Down Expand Up @@ -60,12 +61,16 @@ public function testBug2752(): void

public function testBug4289(): void
{
$this->analyse([__DIR__ . '/data/bug-4289.php'], [
[
'Cannot unset Bug4289\BaseClass::$fields property which might get hooked in subclass.',
25,
],
]);
if (PHP_VERSION_ID < 80400) {
$this->analyse([__DIR__ . '/data/bug-4289.php'], []);
} else {
$this->analyse([__DIR__ . '/data/bug-4289.php'], [
[
'Cannot unset Bug4289\BaseClass::$fields property which might get hooked in subclass.',
25,
],
]);
}
}

public function testBug5223(): void
Expand Down Expand Up @@ -104,11 +109,15 @@ public function testBug4565(): void

public function testBug12421(): void
{
$this->analyse([__DIR__ . '/data/bug-12421.php'], [
[
$errors = [];
if (PHP_VERSION_ID >= 80400) {
$errors[] = [
'Cannot unset Bug12421\RegularProperty::$y property which might get hooked in subclass.',
7,
],
];
}

$errors = array_merge($errors, [
[
'Cannot unset readonly Bug12421\NativeReadonlyClass::$y property.',
11,
Expand All @@ -134,6 +143,8 @@ public function testBug12421(): void
34,
],
]);

$this->analyse([__DIR__ . '/data/bug-12421.php'], $errors);
}

public function testUnsetHookedProperty(): void
Expand Down
Loading