Skip to content

Commit 67cd905

Browse files
authored
NarrowPrivateClassMethodParamTypeRule: Skip variadics (#66)
* NarrowPrivateClassMethodParamTypeRule: Skip variadics * remove unused import
1 parent bba4be9 commit 67cd905

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Rules/NarrowPrivateClassMethodParamTypeRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ private function validateArgVsParamTypes(array $args, MethodCall $methodCall, Sc
110110
continue;
111111
}
112112

113+
if ($param->variadic) {
114+
return [];
115+
}
116+
113117
$paramRuleError = $this->validateParam($param, $position, $arg->value, $scope);
114118
if (! $paramRuleError instanceof RuleError) {
115119
continue;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\Fixture;
6+
7+
use PhpParser\Node;
8+
9+
class SkipVariadics
10+
{
11+
public function run(Node $node, Node $node2, Node $node3)
12+
{
13+
$arr = [$node, $node2, $node3];
14+
$this->takesVariadic(...$arr);
15+
}
16+
17+
private function takesVariadic(Node ...$node)
18+
{
19+
20+
}
21+
}

tests/Rules/NarrowPrivateClassMethodParamTypeRule/NarrowPrivateClassMethodParamTypeRuleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public static function provideData(): Iterator
5050
yield [__DIR__ . '/Fixture/DoubleShot.php', [[$argErrorMessage, 15], [$paramErrorMessage, 15]]];
5151
yield [__DIR__ . '/Fixture/SkipGenericType.php', []];
5252
yield [__DIR__ . '/Fixture/SkipAbstractBase.php', []];
53+
yield [__DIR__ . '/Fixture/SkipVariadics.php', []];
5354
}
5455

5556
/**

0 commit comments

Comments
 (0)