@@ -138,7 +138,7 @@ private function handlePrototypedArrayNode(PrototypedArrayNode $node, ClassBuild
138
138
$ parameterType = $ this ->getParameterType ($ prototype );
139
139
if (null !== $ parameterType || $ prototype instanceof ScalarNode) {
140
140
$ property = $ class ->addProperty ($ node ->getName ());
141
- if (null === $ node ->getKeyAttribute ()) {
141
+ if (null === $ key = $ node ->getKeyAttribute ()) {
142
142
$ body = '
143
143
public function NAME(TYPE $value): self
144
144
{
@@ -149,13 +149,14 @@ public function NAME(TYPE $value): self
149
149
$ class ->addMethod ($ methodName , $ body , ['PROPERTY ' => $ property ->getName (), 'TYPE ' => $ parameterType ]);
150
150
} else {
151
151
$ body = '
152
- public function NAME(string $key , TYPE $value ): self
152
+ public function NAME(string $VAR , TYPE $VALUE ): self
153
153
{
154
- $this->PROPERTY[$key ] = $value ;
154
+ $this->PROPERTY[$VAR ] = $VALUE ;
155
155
156
156
return $this;
157
157
} ' ;
158
- $ class ->addMethod ($ methodName , $ body , ['PROPERTY ' => $ property ->getName (), 'TYPE ' => $ parameterType ]);
158
+
159
+ $ class ->addMethod ($ methodName , $ body , ['PROPERTY ' => $ property ->getName (), 'TYPE ' => $ parameterType , 'VAR ' =>$ key , 'VALUE ' =>' value ' === $ key ? 'data ' : 'value ' ]);
159
160
}
160
161
161
162
return ;
@@ -166,7 +167,7 @@ public function NAME(string $key, TYPE $value): self
166
167
$ this ->classes [] = $ childClass ;
167
168
$ property = $ class ->addProperty ($ node ->getName (), $ childClass ->getName ().'[] ' );
168
169
169
- if (null === $ node ->getKeyAttribute ()) {
170
+ if (null === $ key = $ node ->getKeyAttribute ()) {
170
171
$ body = '
171
172
public function NAME(array $value = []): CLASS
172
173
{
@@ -175,11 +176,11 @@ public function NAME(array $value = []): CLASS
175
176
$ class ->addMethod ($ methodName , $ body , ['PROPERTY ' => $ property ->getName (), 'CLASS ' => $ childClass ->getFqcn ()]);
176
177
} else {
177
178
$ body = '
178
- public function NAME(string $key , array $value = []): CLASS
179
+ public function NAME(string $VAR , array $VALUE = []): CLASS
179
180
{
180
- return $this->PROPERTY[$key ] = new CLASS($value );
181
+ return $this->PROPERTY[$VAR ] = new CLASS($VALUE );
181
182
} ' ;
182
- $ class ->addMethod ($ methodName , $ body , ['PROPERTY ' => $ property ->getName (), 'CLASS ' => $ childClass ->getFqcn ()]);
183
+ $ class ->addMethod ($ methodName , $ body , ['PROPERTY ' => $ property ->getName (), 'CLASS ' => $ childClass ->getFqcn (), ' VAR ' => $ key , ' VALUE ' => ' value ' === $ key ? ' data ' : ' value ' ]);
183
184
}
184
185
185
186
$ this ->buildNode ($ prototype , $ childClass , $ namespace .'\\' .$ childClass ->getName ());
0 commit comments