Skip to content

Commit 6ef4dfc

Browse files
committed
Added regression test
1 parent 0cfddca commit 6ef4dfc

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
@@ -1060,4 +1060,18 @@ public function testBug12087(): void
10601060
]);
10611061
}
10621062

1063+
public function testBug9666(): void
1064+
{
1065+
$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%</>.';
1066+
1067+
$this->treatPhpDocTypesAsCertain = true;
1068+
$this->analyse([__DIR__ . '/data/bug-9666.php'], [
1069+
[
1070+
'Call to function is_bool() with bool will always evaluate to true.',
1071+
20,
1072+
$tipText,
1073+
],
1074+
]);
1075+
}
1076+
10631077
}
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)