Skip to content

Commit 94150ef

Browse files
Understand at least one argument for non empty array
1 parent 5878035 commit 94150ef

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/Rules/FunctionCallParametersCheck.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,16 @@ public function check(
188188
$arg->getStartLine(),
189189
];
190190
}
191+
192+
if (count($arguments) === 0 && $type->isIterableAtLeastOnce()->yes()) {
193+
$arguments[] = [
194+
$arg->value,
195+
$type->getIterableValueType(),
196+
true,
197+
null,
198+
$arg->getStartLine(),
199+
];
200+
}
191201
} else {
192202
$arguments[] = [
193203
$arg->value,

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,6 +2169,11 @@ public function testBug8922(): void
21692169
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-8922.php'], $errors);
21702170
}
21712171

2172+
public function testBug10020(): void
2173+
{
2174+
$this->analyse([__DIR__ . '/data/bug-10020.php'], []);
2175+
}
2176+
21722177
public function testBug13065(): void
21732178
{
21742179
$errors = [];
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug10020;
4+
5+
function load(string $path, string ...$extraPaths): void
6+
{
7+
//$this->doLoad(false, \func_get_args());
8+
}
9+
10+
$projectDir = __DIR__;
11+
$environment = 'dev';
12+
13+
$files = array_reverse(array_filter([
14+
$projectDir.'/.env',
15+
$projectDir.'/.env.'.$environment,
16+
$projectDir.'/.env.local',
17+
$projectDir.'/.env.'.$environment.'.local',
18+
], 'file_exists'));
19+
20+
if ($files !== []) {
21+
load(...$files);
22+
}

0 commit comments

Comments
 (0)