Skip to content

Commit

Permalink
[TypeDeclaration] skip variadic constructor param of mixed type on Ad…
Browse files Browse the repository at this point in the history
…dParamTypeFromPropertyTypeRector (#4887)

* skip variadic constructor param of mixed type

* [WIP] add testcase for explicit type

* remove unneeded expectation as it is the same as input fixture

* Revert "[WIP] add testcase for explicit type"

This reverts commit 353a75f.

Taking over type of doc block would be nice. As discussed in PR:
we can't rely on docblock, so skipping is the safest.
  • Loading branch information
Celebrate-Reinhard committed Aug 31, 2023
1 parent cf69407 commit 4b0a688
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector\Fixture;

final class SkipVariadicConstructorParamOfMixedType
{
/**
* @var mixed[]
*/
private array $elements;

public function __construct(...$elements)
{
$this->elements = $elements;
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ public function refactor(Node $node): ?ClassMethod
if ($param->type instanceof Node) {
continue;
}

if ($param->variadic) {
continue;
}
if (! $this->paramTypeAddGuard->isLegal($param, $node)) {
continue;
}
Expand Down

0 comments on commit 4b0a688

Please sign in to comment.