Skip to content

Commit 45c1da6

Browse files
committed
Added regression test
1 parent 276e275 commit 45c1da6

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,4 +1054,18 @@ public function testBug12087(): void
10541054
]);
10551055
}
10561056

1057+
public function testBug9666(): void
1058+
{
1059+
$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%</>.';
1060+
1061+
$this->treatPhpDocTypesAsCertain = true;
1062+
$this->analyse([__DIR__ . '/data/bug-9666.php'], [
1063+
[
1064+
'Call to function is_bool() with bool will always evaluate to true.',
1065+
20,
1066+
$tipText,
1067+
],
1068+
]);
1069+
}
1070+
10571071
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Bug9666;
4+
5+
class A
6+
{
7+
/**
8+
* @return array<int,bool>
9+
*/
10+
function b()
11+
{
12+
return [];
13+
}
14+
}
15+
16+
function doFoo() {
17+
$a = new A();
18+
$b = $a->b();
19+
$c = null;
20+
if ($b && is_bool($c = reset($b))) {
21+
//
22+
}
23+
}
24+

0 commit comments

Comments
 (0)