Skip variadic arguments from property promotion (#5046)

This commit is contained in:
Grzegorz Korba 2020-12-30 20:31:55 +01:00 committed by GitHub
parent bf9e31b515
commit 7a82928e08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -96,12 +96,16 @@ CODE_SAMPLE
foreach ($promotionCandidates as $promotionCandidate) { foreach ($promotionCandidates as $promotionCandidate) {
// does property have some useful annotations? // does property have some useful annotations?
$property = $promotionCandidate->getProperty(); $property = $promotionCandidate->getProperty();
$param = $promotionCandidate->getParam();
if ($param->variadic) {
continue;
}
$this->removeNode($property); $this->removeNode($property);
$this->removeNode($promotionCandidate->getAssign()); $this->removeNode($promotionCandidate->getAssign());
$property = $promotionCandidate->getProperty(); $property = $promotionCandidate->getProperty();
$param = $promotionCandidate->getParam();
$this->decorateParamWithPropertyPhpDocInfo($property, $param); $this->decorateParamWithPropertyPhpDocInfo($property, $param);

View File

@ -0,0 +1,14 @@
<?php
namespace Rector\Php80\Tests\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\Fixture;
class SkipVariadicArguments
{
/** @var string[] */
private array $bars;
public function __construct(string ...$bars)
{
$this->bars = $bars;
}
}