REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.63 KB
Close
//opt/cpanel/ea-wappspector/vendor/rector/rector/rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php
Text
Base64
<?php declare (strict_types=1); namespace Rector\Arguments\Rector\FuncCall; use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; use Rector\Arguments\ArgumentDefaultValueReplacer; use Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use RectorPrefix202411\Webmozart\Assert\Assert; /** * @see \Rector\Tests\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector\FunctionArgumentDefaultValueReplacerRectorTest */ final class FunctionArgumentDefaultValueReplacerRector extends AbstractRector implements ConfigurableRectorInterface { /** * @readonly * @var \Rector\Arguments\ArgumentDefaultValueReplacer */ private $argumentDefaultValueReplacer; /** * @var ReplaceFuncCallArgumentDefaultValue[] */ private $replacedArguments = []; public function __construct(ArgumentDefaultValueReplacer $argumentDefaultValueReplacer) { $this->argumentDefaultValueReplacer = $argumentDefaultValueReplacer; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Streamline the operator arguments of version_compare function', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' version_compare(PHP_VERSION, '5.6', 'gte'); CODE_SAMPLE , <<<'CODE_SAMPLE' version_compare(PHP_VERSION, '5.6', 'ge'); CODE_SAMPLE , [new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge')])]); } /** * @return array<class-string<Node>> */ public function getNodeTypes() : array { return [FuncCall::class]; } /** * @param FuncCall $node */ public function refactor(Node $node) : ?\PhpParser\Node\Expr\FuncCall { $hasChanged = \false; foreach ($this->replacedArguments as $replacedArgument) { if (!$this->isName($node->name, $replacedArgument->getFunction())) { continue; } $changedNode = $this->argumentDefaultValueReplacer->processReplaces($node, $replacedArgument); if ($changedNode instanceof Node) { $hasChanged = \true; } } if ($hasChanged) { return $node; } return null; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allIsAOf($configuration, ReplaceFuncCallArgumentDefaultValue::class); $this->replacedArguments = $configuration; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 1
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
FunctionArgumentDefaultValueReplacerRector.php
2.63 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).