← All changes
|
vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php
+47
-1
3.2
→
3.5.9
View file →
| @@ -18,8 +18,10 @@ | ||
| 18 | 18 | protected $byRef = false; |
| 19 | 19 | |
| 20 | 20 | protected $variadic = false; |
| 21 | 21 | |
| 22 | + protected $flags = 0; | |
| 23 | + | |
| 22 | 24 | /** @var Node\AttributeGroup[] */ |
| 23 | 25 | protected $attributeGroups = []; |
| 24 | 26 | |
| 25 | 27 | /** |
| @@ -95,8 +97,52 @@ | ||
| 95 | 97 | return $this; |
| 96 | 98 | } |
| 97 | 99 | |
| 98 | 100 | /** |
| 101 | + * Makes the (promoted) parameter public. | |
| 102 | + * | |
| 103 | + * @return $this The builder instance (for fluid interface) | |
| 104 | + */ | |
| 105 | + public function makePublic() { | |
| 106 | + $this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_PUBLIC); | |
| 107 | + | |
| 108 | + return $this; | |
| 109 | + } | |
| 110 | + | |
| 111 | + /** | |
| 112 | + * Makes the (promoted) parameter protected. | |
| 113 | + * | |
| 114 | + * @return $this The builder instance (for fluid interface) | |
| 115 | + */ | |
| 116 | + public function makeProtected() { | |
| 117 | + $this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_PROTECTED); | |
| 118 | + | |
| 119 | + return $this; | |
| 120 | + } | |
| 121 | + | |
| 122 | + /** | |
| 123 | + * Makes the (promoted) parameter private. | |
| 124 | + * | |
| 125 | + * @return $this The builder instance (for fluid interface) | |
| 126 | + */ | |
| 127 | + public function makePrivate() { | |
| 128 | + $this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_PRIVATE); | |
| 129 | + | |
| 130 | + return $this; | |
| 131 | + } | |
| 132 | + | |
| 133 | + /** | |
| 134 | + * Makes the (promoted) parameter readonly. | |
| 135 | + * | |
| 136 | + * @return $this The builder instance (for fluid interface) | |
| 137 | + */ | |
| 138 | + public function makeReadonly() { | |
| 139 | + $this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_READONLY); | |
| 140 | + | |
| 141 | + return $this; | |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 99 | 145 | * Adds an attribute group. |
| 100 | 146 | * |
| 101 | 147 | * @param Node\Attribute|Node\AttributeGroup $attribute |
| 102 | 148 | * |
| @@ -115,8 +161,8 @@ | ||
| 115 | 161 | */ |
| 116 | 162 | public function getNode() : Node { |
| 117 | 163 | return new Node\Param( |
| 118 | 164 | new Node\Expr\Variable($this->name), |
| 119 | - $this->default, $this->type, $this->byRef, $this->variadic, [], 0, $this->attributeGroups | |
| 165 | + $this->default, $this->type, $this->byRef, $this->variadic, [], $this->flags, $this->attributeGroups | |
| 120 | 166 | ); |
| 121 | 167 | } |
| 122 | 168 | } |