Skip to content

Commit 5b68bd7

Browse files
committed
ImpossibleInstanceofRule - test a tricky situation
1 parent 9bb2ed5 commit 5b68bd7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Diff for: tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,10 @@ public function testNewIsAlwaysFinalClass(): void
532532
'Instanceof between ImpossibleInstanceofNewIsAlwaysFinal\Bar and ImpossibleInstanceofNewIsAlwaysFinal\Foo will always evaluate to false.',
533533
63,
534534
],
535+
[
536+
'Instanceof between ImpossibleInstanceofNewIsAlwaysFinal\Bar|null and ImpossibleInstanceofNewIsAlwaysFinal\Foo will always evaluate to false.',
537+
73,
538+
],
535539
]);
536540
}
537541

Diff for: tests/PHPStan/Rules/Classes/data/impossible-instanceof-new-is-always-final.php

+10
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ function (Bar $bar): void {
6464

6565
}
6666
};
67+
68+
function (): void {
69+
$bar = null;
70+
if (rand(0,1)===1) {
71+
$bar = new Bar();
72+
}
73+
if ($bar instanceof Foo) {
74+
75+
}
76+
};

0 commit comments

Comments
 (0)