Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Rules/NarrowPrivateClassMethodParamTypeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ private function validateArgVsParamTypes(array $args, MethodCall $methodCall, Sc
continue;
}

if ($param->variadic) {
return [];
}

$paramRuleError = $this->validateParam($param, $position, $arg->value, $scope);
if (! $paramRuleError instanceof RuleError) {
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Fixture;

use PhpParser\Node;

class SkipVariadics
{
public function run(Node $node, Node $node2, Node $node3)
{
$arr = [$node, $node2, $node3];
$this->takesVariadic(...$arr);
}

private function takesVariadic(Node ...$node)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before this PR, this test on line 18 got the following error:

Parameter 1 should use "array<int, PhpParser\Node>" type as the only type passed to this method

as the error-message suggested phpdoc type does not provide more information, than the native type already has, I suggest to drop the error for such cases

{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static function provideData(): Iterator
yield [__DIR__ . '/Fixture/DoubleShot.php', [[$argErrorMessage, 15], [$paramErrorMessage, 15]]];
yield [__DIR__ . '/Fixture/SkipGenericType.php', []];
yield [__DIR__ . '/Fixture/SkipAbstractBase.php', []];
yield [__DIR__ . '/Fixture/SkipVariadics.php', []];
}

/**
Expand Down