Skip to content

Commit 276e275

Browse files
committed
Added regression test
1 parent 8c812ba commit 276e275

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
@@ -1032,10 +1032,26 @@ public function testBug13291(): void
10321032
$this->analyse([__DIR__ . '/data/bug-13291.php'], []);
10331033
}
10341034

1035+
#[RequiresPhp('>= 8.0')]
10351036
public function testBug13268(): void
10361037
{
10371038
$this->treatPhpDocTypesAsCertain = true;
10381039
$this->analyse([__DIR__ . '/data/bug-13268.php'], []);
10391040
}
10401041

1042+
#[RequiresPhp('>= 8.0')]
1043+
public function testBug12087(): void
1044+
{
1045+
$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%</>.';
1046+
1047+
$this->treatPhpDocTypesAsCertain = true;
1048+
$this->analyse([__DIR__ . '/data/bug-12087.php'], [
1049+
[
1050+
'Call to function is_null() with null will always evaluate to true.',
1051+
14,
1052+
$tipText,
1053+
],
1054+
]);
1055+
}
1056+
10411057
}
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)