File tree Expand file tree Collapse file tree
rules/CodeQuality/Rector/CallLike Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616use Rector \PHPStan \ScopeFetcher ;
1717use Rector \Rector \AbstractRector ;
1818use Rector \Reflection \ReflectionResolver ;
19+ use Rector \ValueObject \PhpVersionFeature ;
20+ use Rector \VersionBonding \Contract \MinPhpVersionInterface ;
1921use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
2022use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
2123
2224/**
2325 * @see \Rector\Tests\CodeQuality\Rector\CallLike\AddNameToBooleanArgumentRector\AddNameToBooleanArgumentRectorTest
2426 */
25- final class AddNameToBooleanArgumentRector extends AbstractRector
27+ final class AddNameToBooleanArgumentRector extends AbstractRector implements MinPhpVersionInterface
2628{
2729 public function __construct (
2830 private readonly ReflectionResolver $ reflectionResolver ,
@@ -81,7 +83,8 @@ public function refactor(Node $node): ?Node
8183 }
8284
8385 $ wasChanged = false ;
84- for ($ i = $ position ; $ i < count ($ args ); ++$ i ) {
86+ $ counter = count ($ args );
87+ for ($ i = $ position ; $ i < $ counter ; ++$ i ) {
8588 $ arg = $ args [$ i ];
8689 if ($ arg ->name instanceof Identifier) {
8790 continue ;
@@ -103,6 +106,11 @@ public function refactor(Node $node): ?Node
103106 return $ node ;
104107 }
105108
109+ public function provideMinPhpVersion (): int
110+ {
111+ return PhpVersionFeature::NAMED_ARGUMENTS ;
112+ }
113+
106114 private function shouldSkip (CallLike $ callLike ): bool
107115 {
108116 if ($ callLike ->isFirstClassCallable ()) {
Original file line number Diff line number Diff line change @@ -505,4 +505,9 @@ final class PhpVersionFeature
505505 * @see https://wiki.php.net/rfc/clamp_v2
506506 */
507507 public const int CLAMP = PhpVersion::PHP_86 ;
508+
509+ /**
510+ * @see https://php.watch/versions/8.0/named-parameters
511+ */
512+ public const int NAMED_ARGUMENTS = PhpVersion::PHP_80 ;
508513}
You can’t perform that action at this time.
0 commit comments