Skip to content

Commit 9cf4eb8

Browse files
authored
Regression test
1 parent 7896011 commit 9cf4eb8

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,4 +1687,18 @@ public function testBug10974(): void
16871687
$this->analyse([__DIR__ . '/data/bug-10974.php'], []);
16881688
}
16891689

1690+
public function testCountArrayShift(): void
1691+
{
1692+
$this->analyse([__DIR__ . '/data/count-array-shift.php'], [
1693+
[
1694+
'Parameter #1 $value of function count expects array|Countable, array|false given.',
1695+
10,
1696+
],
1697+
[
1698+
'Parameter #1 $value of function count expects array|Countable, array|false given.',
1699+
18,
1700+
],
1701+
]);
1702+
}
1703+
16901704
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace CountArrayShift;
4+
5+
/** @param array<mixed>|false $a */
6+
function foo($a): void
7+
{
8+
while (count($a) > 0) {
9+
array_shift($a);
10+
}
11+
}
12+
13+
/** @param non-empty-array<mixed>|false $a */
14+
function bar($a): void
15+
{
16+
while (count($a) > 0) {
17+
array_shift($a);
18+
}
19+
}

0 commit comments

Comments
 (0)