Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/lib/PhpParser/Builder/Param.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 | 129ea1e6d783 |
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; | 5 use PhpParser; |
6 use PhpParser\BuilderHelpers; | |
6 use PhpParser\Node; | 7 use PhpParser\Node; |
7 | 8 |
8 class Param extends PhpParser\BuilderAbstract | 9 class Param implements PhpParser\Builder |
9 { | 10 { |
10 protected $name; | 11 protected $name; |
11 | 12 |
12 protected $default = null; | 13 protected $default = null; |
13 | 14 |
21 /** | 22 /** |
22 * Creates a parameter builder. | 23 * Creates a parameter builder. |
23 * | 24 * |
24 * @param string $name Name of the parameter | 25 * @param string $name Name of the parameter |
25 */ | 26 */ |
26 public function __construct($name) { | 27 public function __construct(string $name) { |
27 $this->name = $name; | 28 $this->name = $name; |
28 } | 29 } |
29 | 30 |
30 /** | 31 /** |
31 * Sets default value for the parameter. | 32 * Sets default value for the parameter. |
33 * @param mixed $value Default value to use | 34 * @param mixed $value Default value to use |
34 * | 35 * |
35 * @return $this The builder instance (for fluid interface) | 36 * @return $this The builder instance (for fluid interface) |
36 */ | 37 */ |
37 public function setDefault($value) { | 38 public function setDefault($value) { |
38 $this->default = $this->normalizeValue($value); | 39 $this->default = BuilderHelpers::normalizeValue($value); |
39 | 40 |
40 return $this; | 41 return $this; |
41 } | 42 } |
42 | 43 |
43 /** | 44 /** |
46 * @param string|Node\Name|Node\NullableType $type Type hint to use | 47 * @param string|Node\Name|Node\NullableType $type Type hint to use |
47 * | 48 * |
48 * @return $this The builder instance (for fluid interface) | 49 * @return $this The builder instance (for fluid interface) |
49 */ | 50 */ |
50 public function setTypeHint($type) { | 51 public function setTypeHint($type) { |
51 $this->type = $this->normalizeType($type); | 52 $this->type = BuilderHelpers::normalizeType($type); |
52 if ($this->type === 'void') { | 53 if ($this->type == 'void') { |
53 throw new \LogicException('Parameter type cannot be void'); | 54 throw new \LogicException('Parameter type cannot be void'); |
54 } | 55 } |
55 | 56 |
56 return $this; | 57 return $this; |
57 } | 58 } |
81 /** | 82 /** |
82 * Returns the built parameter node. | 83 * Returns the built parameter node. |
83 * | 84 * |
84 * @return Node\Param The built parameter node | 85 * @return Node\Param The built parameter node |
85 */ | 86 */ |
86 public function getNode() { | 87 public function getNode() : Node { |
87 return new Node\Param( | 88 return new Node\Param( |
88 $this->name, $this->default, $this->type, $this->byRef, $this->variadic | 89 new Node\Expr\Variable($this->name), |
90 $this->default, $this->type, $this->byRef, $this->variadic | |
89 ); | 91 ); |
90 } | 92 } |
91 } | 93 } |