Skip to content

Commit 3a449fa

Browse files
authored
[Symfony73] Skip empty result of named arguments on ConstraintOptionsToNamedArgumentsRector (#853)
1 parent e2bf487 commit 3a449fa

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\Symfony\Tests\Symfony73\Rector\Class_\ConstraintOptionsToNamedArgumentsRector\Fixture;
4+
5+
use Symfony\Component\Validator\Constraints\GroupSequence;
6+
7+
final class SkipResultEmptyNamedArguments
8+
{
9+
public function run(bool $param)
10+
{
11+
$constraints = new GroupSequence(['group1', 'group2']);
12+
}
13+
}

rules/Symfony73/Rector/Class_/ConstraintOptionsToNamedArgumentsRector.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
2020
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
2121

22+
/**
23+
* @see \Rector\Symfony\Tests\Symfony73\Rector\Class_\ConstraintOptionsToNamedArgumentsRector\ConstraintOptionsToNamedArgumentsRectorTest
24+
*/
2225
final class ConstraintOptionsToNamedArgumentsRector extends AbstractRector
2326
{
2427
public function __construct(
@@ -130,6 +133,10 @@ public function refactor(Node $node): ?Node
130133
$namedArgs[] = $arg;
131134
}
132135

136+
if ($namedArgs === []) {
137+
return null;
138+
}
139+
133140
$node->args = $namedArgs;
134141

135142
return $node;

0 commit comments

Comments
 (0)