mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 18:00:50 +00:00
dd875cd0c9
d09ae7400a
Add "custom-rule" command to make creating rules easy (#5498)
46 lines
1006 B
PHP
46 lines
1006 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Utils\Rector\Rector;
|
|
|
|
use PhpParser\Node;
|
|
use Rector\Rector\AbstractRector;
|
|
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
|
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|
|
|
/**
|
|
* @see \Utils\Rector\Tests\Rector\__Name__Test
|
|
*/
|
|
final class __Name__ extends AbstractRector
|
|
{
|
|
public function getRuleDefinition(): RuleDefinition
|
|
{
|
|
return new RuleDefinition('// @todo fill the description', [
|
|
new CodeSample(
|
|
'// @todo fill code before',
|
|
'// @todo fill code after'
|
|
)
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @return array<class-string<Node>>
|
|
*/
|
|
public function getNodeTypes(): array
|
|
{
|
|
// @todo select node type
|
|
return [\PhpParser\Node\Stmt\Class_::class];
|
|
}
|
|
|
|
/**
|
|
* @param \PhpParser\Node\Stmt\Class_ $node
|
|
*/
|
|
public function refactor(Node $node): ?Node
|
|
{
|
|
// @todo change the node
|
|
|
|
return $node;
|
|
}
|
|
}
|