Skip to content

Commit 5f3c308

Browse files
committed
added regression test
1 parent 72177cf commit 5f3c308

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,4 +1121,15 @@ public function testBug7773(): void
11211121
$this->analyse([__DIR__ . '/data/bug-7773.php'], []);
11221122
}
11231123

1124+
public function testPr4375(): void
1125+
{
1126+
$this->treatPhpDocTypesAsCertain = true;
1127+
$this->analyse([__DIR__ . '/data/pr-4375.php'], [
1128+
[
1129+
'Call to function array_key_exists() with string and array<string, *NEVER*> will always evaluate to false.',
1130+
14,
1131+
],
1132+
]);
1133+
}
1134+
11241135
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace PR2375;
4+
5+
final class Foo
6+
{
7+
public function processNode(): array
8+
{
9+
$methods = [];
10+
foreach ($this->get() as $collected) {
11+
foreach ($collected as [$className, $methodName, $classDisplayName]) {
12+
$className = strtolower($className);
13+
14+
if (!array_key_exists($className, $methods)) {
15+
$methods[$className] = [];
16+
}
17+
$methods[$className][strtolower($methodName)] = $classDisplayName . '::' . $methodName;
18+
}
19+
}
20+
21+
return [];
22+
}
23+
24+
private function get(): array {
25+
return [];
26+
}
27+
}

0 commit comments

Comments
 (0)