mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-06 03:10:50 +00:00
59 lines
1.1 KiB
PHP
59 lines
1.1 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Rector\Rector\Contrib\Nette;
|
|
|
|
use PhpParser\Node;
|
|
use PhpParser\Node\Expr\StaticCall;
|
|
use PhpParser\Node\Identifier;
|
|
use Rector\Deprecation\SetNames;
|
|
use Rector\Rector\AbstractRector;
|
|
|
|
final class HtmlAddMethodRector extends AbstractRector
|
|
{
|
|
/**
|
|
* @var Node
|
|
*/
|
|
private $previousNode;
|
|
|
|
public function getSetName(): string
|
|
{
|
|
return SetNames::NETTE;
|
|
}
|
|
|
|
public function sinceVersion(): float
|
|
{
|
|
return 2.4;
|
|
}
|
|
|
|
public function isCandidate(Node $node): bool
|
|
{
|
|
if (! $node instanceof StaticCall) {
|
|
return false;
|
|
}
|
|
|
|
if (! $node->name instanceof Identifier) {
|
|
return false;
|
|
}
|
|
|
|
if ($node->class->getLast() !== 'Html') {
|
|
return false;
|
|
}
|
|
|
|
if ((string) $node->name !== 'add') {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @param StaticCall $node
|
|
*/
|
|
public function refactor(Node $node): ?Node
|
|
{
|
|
$node->name->name = 'addHtml';
|
|
|
|
return $node;
|
|
}
|
|
}
|