REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.37 KB
Close
//opt/cpanel/ea-wappspector/vendor/rector/rector/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php
Text
Base64
<?php declare (strict_types=1); namespace Rector\CodingStyle\Rector\FuncCall; use PhpParser\Node; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\MethodCall; use Rector\CodingStyle\NodeFactory\ArrayCallableToMethodCallFactory; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector\CallUserFuncToMethodCallRectorTest */ final class CallUserFuncToMethodCallRector extends AbstractRector { /** * @readonly * @var \Rector\CodingStyle\NodeFactory\ArrayCallableToMethodCallFactory */ private $arrayCallableToMethodCallFactory; public function __construct(ArrayCallableToMethodCallFactory $arrayCallableToMethodCallFactory) { $this->arrayCallableToMethodCallFactory = $arrayCallableToMethodCallFactory; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Refactor call_user_func() on known class method to a method call', [new CodeSample(<<<'CODE_SAMPLE' final class SomeClass { public function run() { $result = \call_user_func([$this->property, 'method'], $args); } } CODE_SAMPLE , <<<'CODE_SAMPLE' final class SomeClass { public function run() { $result = $this->property->method($args); } } CODE_SAMPLE )]); } /** * @return array<class-string<Node>> */ public function getNodeTypes() : array { return [FuncCall::class]; } /** * @param FuncCall $node */ public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'call_user_func')) { return null; } if ($node->isFirstClassCallable()) { return null; } if (!isset($node->getArgs()[0])) { return null; } $firstArgValue = $node->getArgs()[0]->value; if (!$firstArgValue instanceof Array_) { return null; } $methodCall = $this->arrayCallableToMethodCallFactory->create($firstArgValue); if (!$methodCall instanceof MethodCall) { return null; } $originalArgs = $node->args; unset($originalArgs[0]); $methodCall->args = $originalArgs; return $methodCall; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 8
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
ArraySpreadInsteadOfArrayMergeRector.php
5.67 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
CallUserFuncArrayToVariadicRector.php
3.52 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
CallUserFuncToMethodCallRector.php
2.37 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
ConsistentImplodeRector.php
2.59 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
CountArrayToEmptyArrayComparisonRector.php
5.74 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
FunctionFirstClassCallableRector.php
2.99 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
StrictArraySearchRector.php
1.21 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
VersionCompareFuncCallToConstantRector.php
3.85 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).