Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeDeclaration] skip variadic constructor param of mixed type on AddParamTypeFromPropertyTypeRector #4887

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
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)) {
Comment on lines +96 to 99
Copy link
Member

Choose a reason for hiding this comment

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

Looks good 👍 , we can move the variadic check to $this->paramTypeAddGuard->isLegal() method if we have another use case in other rule

continue;
}
Expand Down