Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 5fb285c0d0e3 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
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\BuilderHelpers; |
7 use PhpParser\Node\Identifier; | |
8 use PhpParser\Node\Name; | |
9 use PhpParser\Node\NullableType; | |
7 use PhpParser\Node\Stmt; | 10 use PhpParser\Node\Stmt; |
8 | 11 |
9 class Property implements PhpParser\Builder | 12 class Property implements PhpParser\Builder |
10 { | 13 { |
11 protected $name; | 14 protected $name; |
12 | 15 |
13 protected $flags = 0; | 16 protected $flags = 0; |
14 protected $default = null; | 17 protected $default = null; |
15 protected $attributes = []; | 18 protected $attributes = []; |
19 | |
20 /** @var null|Identifier|Name|NullableType */ | |
21 protected $type; | |
16 | 22 |
17 /** | 23 /** |
18 * Creates a property builder. | 24 * Creates a property builder. |
19 * | 25 * |
20 * @param string $name Name of the property | 26 * @param string $name Name of the property |
94 | 100 |
95 return $this; | 101 return $this; |
96 } | 102 } |
97 | 103 |
98 /** | 104 /** |
105 * Sets the property type for PHP 7.4+. | |
106 * | |
107 * @param string|Name|NullableType|Identifier $type | |
108 * | |
109 * @return $this | |
110 */ | |
111 public function setType($type) { | |
112 $this->type = BuilderHelpers::normalizeType($type); | |
113 | |
114 return $this; | |
115 } | |
116 | |
117 /** | |
99 * Returns the built class node. | 118 * Returns the built class node. |
100 * | 119 * |
101 * @return Stmt\Property The built property node | 120 * @return Stmt\Property The built property node |
102 */ | 121 */ |
103 public function getNode() : PhpParser\Node { | 122 public function getNode() : PhpParser\Node { |
104 return new Stmt\Property( | 123 return new Stmt\Property( |
105 $this->flags !== 0 ? $this->flags : Stmt\Class_::MODIFIER_PUBLIC, | 124 $this->flags !== 0 ? $this->flags : Stmt\Class_::MODIFIER_PUBLIC, |
106 [ | 125 [ |
107 new Stmt\PropertyProperty($this->name, $this->default) | 126 new Stmt\PropertyProperty($this->name, $this->default) |
108 ], | 127 ], |
109 $this->attributes | 128 $this->attributes, |
129 $this->type | |
110 ); | 130 ); |
111 } | 131 } |
112 } | 132 } |