Skip to content

Commit 0cfddca

Browse files
committed
Added regression test
1 parent c5079f3 commit 0cfddca

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,10 +1038,26 @@ public function testBug6788(): void
10381038
$this->analyse([__DIR__ . '/data/bug-6788.php'], []);
10391039
}
10401040

1041+
#[RequiresPhp('>= 8.0')]
10411042
public function testBug13268(): void
10421043
{
10431044
$this->treatPhpDocTypesAsCertain = true;
10441045
$this->analyse([__DIR__ . '/data/bug-13268.php'], []);
10451046
}
10461047

1048+
#[RequiresPhp('>= 8.0')]
1049+
public function testBug12087(): void
1050+
{
1051+
$tipText = 'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.';
1052+
1053+
$this->treatPhpDocTypesAsCertain = true;
1054+
$this->analyse([__DIR__ . '/data/bug-12087.php'], [
1055+
[
1056+
'Call to function is_null() with null will always evaluate to true.',
1057+
14,
1058+
$tipText,
1059+
],
1060+
]);
1061+
}
1062+
10471063
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Bug12087;
4+
5+
enum Button: int
6+
{
7+
case On = 1;
8+
9+
case Off = 0;
10+
}
11+
12+
$value = 10;
13+
14+
is_null($value = Button::tryFrom($value));
15+

0 commit comments

Comments
 (0)