Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
12:7a779792577d | 13:5fb285c0d0e3 |
---|---|
1 <?php | 1 <?php declare(strict_types=1); |
2 | 2 |
3 namespace PhpParser\Builder; | 3 namespace PhpParser\Builder; |
4 | 4 |
5 use PhpParser\BuilderAbstract; | 5 use PhpParser\Builder; |
6 use PhpParser\BuilderHelpers; | |
6 use PhpParser\Node; | 7 use PhpParser\Node; |
7 use PhpParser\Node\Stmt; | 8 use PhpParser\Node\Stmt; |
8 | 9 |
9 /** | 10 class Use_ implements Builder |
10 * @method $this as(string $alias) Sets alias for used name. | 11 { |
11 */ | |
12 class Use_ extends BuilderAbstract { | |
13 protected $name; | 12 protected $name; |
14 protected $type; | 13 protected $type; |
15 protected $alias = null; | 14 protected $alias = null; |
16 | 15 |
17 /** | 16 /** |
18 * Creates a name use (alias) builder. | 17 * Creates a name use (alias) builder. |
19 * | 18 * |
20 * @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias | 19 * @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias |
21 * @param int $type One of the Stmt\Use_::TYPE_* constants | 20 * @param int $type One of the Stmt\Use_::TYPE_* constants |
22 */ | 21 */ |
23 public function __construct($name, $type) { | 22 public function __construct($name, int $type) { |
24 $this->name = $this->normalizeName($name); | 23 $this->name = BuilderHelpers::normalizeName($name); |
25 $this->type = $type; | 24 $this->type = $type; |
26 } | 25 } |
27 | 26 |
28 /** | 27 /** |
29 * Sets alias for used name. | 28 * Sets alias for used name. |
30 * | 29 * |
31 * @param string $alias Alias to use (last component of full name by default) | 30 * @param string $alias Alias to use (last component of full name by default) |
32 * | 31 * |
33 * @return $this The builder instance (for fluid interface) | 32 * @return $this The builder instance (for fluid interface) |
34 */ | 33 */ |
35 protected function as_($alias) { | 34 public function as(string $alias) { |
36 $this->alias = $alias; | 35 $this->alias = $alias; |
37 return $this; | 36 return $this; |
38 } | |
39 public function __call($name, $args) { | |
40 if (method_exists($this, $name . '_')) { | |
41 return call_user_func_array(array($this, $name . '_'), $args); | |
42 } | |
43 | |
44 throw new \LogicException(sprintf('Method "%s" does not exist', $name)); | |
45 } | 37 } |
46 | 38 |
47 /** | 39 /** |
48 * Returns the built node. | 40 * Returns the built node. |
49 * | 41 * |
50 * @return Node The built node | 42 * @return Node The built node |
51 */ | 43 */ |
52 public function getNode() { | 44 public function getNode() : Node { |
53 $alias = null !== $this->alias ? $this->alias : $this->name->getLast(); | 45 return new Stmt\Use_([ |
54 return new Stmt\Use_(array( | 46 new Stmt\UseUse($this->name, $this->alias) |
55 new Stmt\UseUse($this->name, $alias) | 47 ], $this->type); |
56 ), $this->type); | |
57 } | 48 } |
58 } | 49 } |