Skip to content

Commit 30567c9

Browse files
committed
add failling test
1 parent bf5ba33 commit 30567c9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,10 @@ public function testBug12847(): void
20732073
39,
20742074
'mixed is empty.',
20752075
],
2076+
[
2077+
"Parameter #1 \$array of function doSomethingWithInt expects non-empty-array<int>, non-empty-array&hasOffsetValue('foo', 'hello') given.",
2078+
73,
2079+
],
20762080
]);
20772081
}
20782082

tests/PHPStan/Rules/Functions/data/bug-12847.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,23 @@ function doSomething(array $array): void
4747
{
4848

4949
}
50+
51+
/**
52+
* @param non-empty-array<int> $array
53+
*/
54+
function doSomethingWithInt(array $array): void
55+
{
56+
57+
}
58+
59+
function doFooBarInt(array $array):void {
60+
if (array_key_exists('foo', $array) && $array['foo'] === 17) {
61+
doSomethingWithInt($array);
62+
}
63+
}
64+
65+
function doFooBarString(array $array):void {
66+
if (array_key_exists('foo', $array) && $array['foo'] === "hello") {
67+
doSomethingWithInt($array);
68+
}
69+
}

0 commit comments

Comments
 (0)