Test Failed
Pull Request — master (#28)
by Pádraic
02:32
created

IgnoreNamespaceScoperNodeVisitor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
B enterNode() 0 12 5
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the humbug/php-scoper package.
7
 *
8
 * Copyright (c) 2017 Théo FIDRY <[email protected]>,
9
 *                    Pádraic Brady <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
16
namespace Humbug\PhpScoper\NodeVisitor;
17
18
use PhpParser\Node;
19
use PhpParser\Node\Name\FullyQualified;
20
use PhpParser\Node\Stmt\UseUse;
21
use PhpParser\NodeVisitorAbstract;
22
23
final class IgnoreNamespaceScoperNodeVisitor extends NodeVisitorAbstract
24
{
25
26
    /**
27
     * @var array Class names to ignore when scoping
28
     */
29
    private $reserved = ['toberemoved'];
30
31
    /**
32
     * @param Node $node
33
     */
34
    public function enterNode(Node $node)
35
    {
36
        /**
37
         * @todo  UseUse should not be skipped if part of FullyQualified sub-section
38
         */
39
        if ($node instanceof UseUse && in_array((string) $node->name, $this->reserved)) {
40
            $node->setAttribute('phpscoper_ignore', true);
41
        }
42
        if ($node instanceof FullyQualified && in_array((string) $node, $this->reserved)) {
43
            $node->setAttribute('phpscoper_ignore', true);
44
        }
45
    }
46
}
47