Skip to content
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
Expand Up @@ -16,13 +16,15 @@
use Rector\PHPStan\ScopeFetcher;
use Rector\Rector\AbstractRector;
use Rector\Reflection\ReflectionResolver;
use Rector\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @see \Rector\Tests\CodeQuality\Rector\CallLike\AddNameToBooleanArgumentRector\AddNameToBooleanArgumentRectorTest
*/
final class AddNameToBooleanArgumentRector extends AbstractRector
final class AddNameToBooleanArgumentRector extends AbstractRector implements MinPhpVersionInterface
{
public function __construct(
private readonly ReflectionResolver $reflectionResolver,
Expand Down Expand Up @@ -81,7 +83,8 @@ public function refactor(Node $node): ?Node
}

$wasChanged = false;
for ($i = $position; $i < count($args); ++$i) {
$counter = count($args);
for ($i = $position; $i < $counter; ++$i) {
$arg = $args[$i];
if ($arg->name instanceof Identifier) {
continue;
Expand All @@ -103,6 +106,11 @@ public function refactor(Node $node): ?Node
return $node;
}

public function provideMinPhpVersion(): int
{
return PhpVersionFeature::NAMED_ARGUMENTS;
}

private function shouldSkip(CallLike $callLike): bool
{
if ($callLike->isFirstClassCallable()) {
Expand Down
5 changes: 5 additions & 0 deletions src/ValueObject/PhpVersionFeature.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,9 @@ final class PhpVersionFeature
* @see https://wiki.php.net/rfc/clamp_v2
*/
public const int CLAMP = PhpVersion::PHP_86;

/**
* @see https://php.watch/versions/8.0/named-parameters
*/
public const int NAMED_ARGUMENTS = PhpVersion::PHP_80;
}
Loading