Skip to content

Commit 1df7d40

Browse files
committed
Added regression test
1 parent a6ba3c8 commit 1df7d40

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
@@ -1049,10 +1049,26 @@ public function testBug6788(): void
10491049
$this->analyse([__DIR__ . '/data/bug-6788.php'], []);
10501050
}
10511051

1052+
#[RequiresPhp('>= 8.0')]
10521053
public function testBug13268(): void
10531054
{
10541055
$this->treatPhpDocTypesAsCertain = true;
10551056
$this->analyse([__DIR__ . '/data/bug-13268.php'], []);
10561057
}
10571058

1059+
#[RequiresPhp('>= 8.0')]
1060+
public function testBug12087(): void
1061+
{
1062+
$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%</>.';
1063+
1064+
$this->treatPhpDocTypesAsCertain = true;
1065+
$this->analyse([__DIR__ . '/data/bug-12087.php'], [
1066+
[
1067+
'Call to function is_null() with null will always evaluate to true.',
1068+
14,
1069+
$tipText,
1070+
],
1071+
]);
1072+
}
1073+
10581074
}
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)