Skip to content

Commit d3be969

Browse files
committed
Regression test for #1860
1 parent 9aeda46 commit d3be969

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,4 +411,19 @@ public function testBug2835(): void
411411
$this->analyse([__DIR__ . '/data/bug-2835.php'], []);
412412
}
413413

414+
public function testBug1860(): void
415+
{
416+
$this->checkAlwaysTrueStrictComparison = true;
417+
$this->analyse([__DIR__ . '/data/bug-1860.php'], [
418+
[
419+
'Strict comparison using === between string and null will always evaluate to false.',
420+
15,
421+
],
422+
[
423+
'Strict comparison using !== between string and null will always evaluate to true.',
424+
19,
425+
],
426+
]);
427+
}
428+
414429
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Bug1860;
4+
5+
class Foo
6+
{
7+
8+
public function doFoo(): string
9+
{
10+
11+
}
12+
13+
public function doBar(): void
14+
{
15+
if ($this->doFoo() === null) {
16+
echo 'foo';
17+
}
18+
19+
if ($this->doFoo() !== null) {
20+
echo 'bar';
21+
}
22+
}
23+
24+
}

0 commit comments

Comments
 (0)