diff --git a/src/Rules/FunctionCallParametersCheck.php b/src/Rules/FunctionCallParametersCheck.php index e6f4043250..57ae028018 100644 --- a/src/Rules/FunctionCallParametersCheck.php +++ b/src/Rules/FunctionCallParametersCheck.php @@ -188,6 +188,16 @@ public function check( $arg->getStartLine(), ]; } + + if (count($arguments) === 0 && $type->isIterableAtLeastOnce()->yes()) { + $arguments[] = [ + $arg->value, + $type->getIterableValueType(), + true, + null, + $arg->getStartLine(), + ]; + } } else { $arguments[] = [ $arg->value, diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index aaba0745cc..85560738eb 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -2169,6 +2169,16 @@ public function testBug8922(): void $this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-8922.php'], $errors); } + public function testBug10020(): void + { + $this->analyse([__DIR__ . '/data/bug-10020.php'], []); + } + + public function testBug8506(): void + { + $this->analyse([__DIR__ . '/data/bug-8506.php'], []); + } + public function testBug13065(): void { $errors = []; diff --git a/tests/PHPStan/Rules/Functions/data/bug-10020.php b/tests/PHPStan/Rules/Functions/data/bug-10020.php new file mode 100644 index 0000000000..d59791a868 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-10020.php @@ -0,0 +1,22 @@ +doLoad(false, \func_get_args()); +} + +$projectDir = __DIR__; +$environment = 'dev'; + +$files = array_reverse(array_filter([ + $projectDir.'/.env', + $projectDir.'/.env.'.$environment, + $projectDir.'/.env.local', + $projectDir.'/.env.'.$environment.'.local', +], 'file_exists')); + +if ($files !== []) { + load(...$files); +} diff --git a/tests/PHPStan/Rules/Functions/data/bug-8506.php b/tests/PHPStan/Rules/Functions/data/bug-8506.php new file mode 100644 index 0000000000..be6d538329 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-8506.php @@ -0,0 +1,18 @@ +