aboutsummaryrefslogtreecommitdiff
path: root/lib/Rectors/Studip60/RemoveFunctionCallRector.php
blob: c08ee5bb63ec1b43204ee0d767a0df55853f0e5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);

namespace Studip\Rectors\Studip60;

use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Rector\AbstractRector;

final class RemoveFunctionCallRector extends AbstractRector implements ConfigurableRectorInterface
{
    private array $removes = [];

    public function getNodeTypes(): array
    {
        return [FuncCall::class];
    }

    public function refactor(Node $node)
    {
        if (!$this->isNames($node, $this->removes)) {
            return null;
        }

        if (!isset($node->args[0])) {
            return null;
        }

        return $node->args[0]->value;
    }

    /**
     * @param mixed[] $configuration
     */
    public function configure(array $configuration): void
    {
        $this->removes = $configuration;
    }
}