Skip to content

Commit bcd4f93

Browse files
Fix
1 parent 988666d commit bcd4f93

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/Reflection/ParametersAcceptorSelector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public static function selectFromArgs(
205205
}
206206

207207
if (isset($args[0]) && (bool) $args[0]->getAttribute(ImplodeArgVisitor::ATTRIBUTE_NAME)) {
208-
if (isset($args[1])) {
208+
if (isset($args[1]) || $args[0]->name?->name === 'array') {
209209
$parameters = [
210210
new NativeParameterReflection('separator', false, new StringType(), PassedByReference::createNo(), false, null),
211211
new NativeParameterReflection('array', false, new ArrayType(new MixedType(), new MixedType()), PassedByReference::createNo(), false, null),

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,20 @@ public function testImplodeOnLessThanPhp74(): void
364364
$this->analyse([__DIR__ . '/data/implode-74.php'], $errors);
365365
}
366366

367+
public function testImplodeNamedParameters(): void
368+
{
369+
$this->analyse([__DIR__ . '/data/implode-named-parameters.php'], [
370+
[
371+
'Missing parameter $separator (string) in call to function implode.',
372+
6,
373+
],
374+
[
375+
'Missing parameter $separator (string) in call to function join.',
376+
7,
377+
],
378+
]);
379+
}
380+
367381
public function testVariableIsNotNullAfterSeriesOfConditions(): void
368382
{
369383
require_once __DIR__ . '/data/variable-is-not-null-after-conditions.php';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace ImplodeNamedParameters;
4+
5+
function (): void {
6+
implode(array: ['']); // error
7+
join(array: ['']); // error
8+
implode(separator: '', array: ['']);
9+
join(separator: '', array: ['']);
10+
};

0 commit comments

Comments
 (0)