← All changes
|
vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php
+19
-3
3.2
→
3.5.9
View file →
| @@ -18,14 +18,16 @@ | ||
| 18 | 18 | protected $constants = []; |
| 19 | 19 | |
| 20 | 20 | /** @var Node\AttributeGroup[] */ |
| 21 | 21 | protected $attributeGroups = []; |
| 22 | + /** @var Identifier|Node\Name|Node\ComplexType */ | |
| 23 | + protected $type; | |
| 22 | 24 | |
| 23 | 25 | /** |
| 24 | 26 | * Creates a class constant builder |
| 25 | 27 | * |
| 26 | 28 | * @param string|Identifier $name Name |
| 27 | - * @param Node\Expr|bool|null|int|float|string|array $value Value | |
| 29 | + * @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value | |
| 28 | 30 | */ |
| 29 | 31 | public function __construct($name, $value) { |
| 30 | 32 | $this->constants = [new Const_($name, BuilderHelpers::normalizeValue($value))]; |
| 31 | 33 | } |
| @@ -33,9 +35,9 @@ | ||
| 33 | 35 | /** |
| 34 | 36 | * Add another constant to const group |
| 35 | 37 | * |
| 36 | 38 | * @param string|Identifier $name Name |
| 37 | - * @param Node\Expr|bool|null|int|float|string|array $value Value | |
| 39 | + * @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value | |
| 38 | 40 | * |
| 39 | 41 | * @return $this The builder instance (for fluid interface) |
| 40 | 42 | */ |
| 41 | 43 | public function addConst($name, $value) { |
| @@ -116,8 +118,21 @@ | ||
| 116 | 118 | return $this; |
| 117 | 119 | } |
| 118 | 120 | |
| 119 | 121 | /** |
| 122 | + * Sets the constant type. | |
| 123 | + * | |
| 124 | + * @param string|Node\Name|Identifier|Node\ComplexType $type | |
| 125 | + * | |
| 126 | + * @return $this | |
| 127 | + */ | |
| 128 | + public function setType($type) { | |
| 129 | + $this->type = BuilderHelpers::normalizeType($type); | |
| 130 | + | |
| 131 | + return $this; | |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 120 | 135 | * Returns the built class node. |
| 121 | 136 | * |
| 122 | 137 | * @return Stmt\ClassConst The built constant node |
| 123 | 138 | */ |
| @@ -125,8 +140,9 @@ | ||
| 125 | 140 | return new Stmt\ClassConst( |
| 126 | 141 | $this->constants, |
| 127 | 142 | $this->flags, |
| 128 | 143 | $this->attributes, |
| 129 | - $this->attributeGroups | |
| 144 | + $this->attributeGroups, | |
| 145 | + $this->type | |
| 130 | 146 | ); |
| 131 | 147 | } |
| 132 | 148 | } |