Removed modules/contrib/media module to allow update to the core media module
[yaffs-website] / vendor / nikic / php-parser / lib / PhpParser / Builder / Use_.php
1 <?php declare(strict_types=1);
2
3 namespace PhpParser\Builder;
4
5 use PhpParser\Builder;
6 use PhpParser\BuilderHelpers;
7 use PhpParser\Node;
8 use PhpParser\Node\Stmt;
9
10 class Use_ implements Builder
11 {
12     protected $name;
13     protected $type;
14     protected $alias = null;
15
16     /**
17      * Creates a name use (alias) builder.
18      *
19      * @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias
20      * @param int              $type One of the Stmt\Use_::TYPE_* constants
21      */
22     public function __construct($name, int $type) {
23         $this->name = BuilderHelpers::normalizeName($name);
24         $this->type = $type;
25     }
26
27     /**
28      * Sets alias for used name.
29      *
30      * @param string $alias Alias to use (last component of full name by default)
31      *
32      * @return $this The builder instance (for fluid interface)
33      */
34     public function as(string $alias) {
35         $this->alias = $alias;
36         return $this;
37     }
38
39     /**
40      * Returns the built node.
41      *
42      * @return Node The built node
43      */
44     public function getNode() : Node {
45         return new Stmt\Use_([
46             new Stmt\UseUse($this->name, $this->alias)
47         ], $this->type);
48     }
49 }