Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
 
3
namespace PhpParser\Node\Stmt;
4
 
5
use PhpParser\Node;
6
use PhpParser\Node\Identifier;
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 Identifier|null 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|Identifier $alias      Alias
22
     * @param int                    $type       Type of the use element (for mixed group use only)
23
     * @param array                  $attributes Additional attributes
24
     */
25
    public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) {
26
        $this->attributes = $attributes;
27
        $this->type = $type;
28
        $this->name = $name;
29
        $this->alias = \is_string($alias) ? new Identifier($alias) : $alias;
30
    }
31
 
32
    public function getSubNodeNames() : array {
33
        return ['type', 'name', 'alias'];
34
    }
35
 
36
    /**
37
     * Get alias. If not explicitly given this is the last component of the used name.
38
     *
39
     * @return Identifier
40
     */
41
    public function getAlias() : Identifier {
42
        if (null !== $this->alias) {
43
            return $this->alias;
44
        }
45
 
46
        return new Identifier($this->name->getLast());
47
    }
48
 
49
    public function getType() : string {
50
        return 'Stmt_UseUse';
51
    }
52
}