Skip to content

Commit 54cfbd4

Browse files
committed
Added regression test
1 parent 1df7d40 commit 54cfbd4

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
@@ -1071,4 +1071,18 @@ public function testBug12087(): void
10711071
]);
10721072
}
10731073

1074+
public function testBug9666(): void
1075+
{
1076+
$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%</>.';
1077+
1078+
$this->treatPhpDocTypesAsCertain = true;
1079+
$this->analyse([__DIR__ . '/data/bug-9666.php'], [
1080+
[
1081+
'Call to function is_bool() with bool will always evaluate to true.',
1082+
20,
1083+
$tipText,
1084+
],
1085+
]);
1086+
}
1087+
10741088
}
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)