UseUse::getSubNodeNames()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace PhpParser\Node\Stmt;
4
5
use PhpParser\Node;
6
use PhpParser\Error;
7
8
class UseUse extends Node\Stmt
9
{
10
    /** @var int One of the Stmt\Use_::TYPE_* constants. Will only differ from TYPE_UNKNOWN for mixed group uses */
11
    public $type;
12
    /** @var Node\Name Namespace, class, function or constant to alias */
13
    public $name;
14
    /** @var string Alias */
15
    public $alias;
16
17
    /**
18
     * Constructs an alias (use) node.
19
     *
20
     * @param Node\Name   $name       Namespace/Class to alias
21
     * @param null|string $alias      Alias
22
     * @param int         $type       Type of the use element (for mixed group use declarations only)
23
     * @param array       $attributes Additional attributes
24
     */
25
    public function __construct(Node\Name $name, $alias = null, $type = Use_::TYPE_UNKNOWN, array $attributes = array()) {
26
        if (null === $alias) {
27
            $alias = $name->getLast();
28
        }
29
30
        if ('self' == strtolower($alias) || 'parent' == strtolower($alias)) {
31
            throw new Error(sprintf(
32
                'Cannot use %s as %s because \'%2$s\' is a special class name',
33
                $name, $alias
34
            ));
35
        }
36
37
        parent::__construct($attributes);
38
        $this->type = $type;
39
        $this->name = $name;
40
        $this->alias = $alias;
41
    }
42
43
    public function getSubNodeNames() {
44
        return array('type', 'name', 'alias');
45
    }
46
}
47