@@ -138,7 +138,7 @@ private function handlePrototypedArrayNode(PrototypedArrayNode $node, ClassBuild
138138 $ parameterType = $ this ->getParameterType ($ prototype );
139139 if (null !== $ parameterType || $ prototype instanceof ScalarNode) {
140140 $ property = $ class ->addProperty ($ node ->getName ());
141- if (null === $ node ->getKeyAttribute ()) {
141+ if (null === $ key = $ node ->getKeyAttribute ()) {
142142 $ body = '
143143public function NAME(TYPE $value): self
144144{
@@ -149,13 +149,14 @@ public function NAME(TYPE $value): self
149149 $ class ->addMethod ($ methodName , $ body , ['PROPERTY ' => $ property ->getName (), 'TYPE ' => $ parameterType ]);
150150 } else {
151151 $ body = '
152- public function NAME(string $key , TYPE $value ): self
152+ public function NAME(string $VAR , TYPE $VALUE ): self
153153{
154- $this->PROPERTY[$key ] = $value ;
154+ $this->PROPERTY[$VAR ] = $VALUE ;
155155
156156 return $this;
157157} ' ;
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 ' ]);
159160 }
160161
161162 return ;
@@ -166,7 +167,7 @@ public function NAME(string $key, TYPE $value): self
166167 $ this ->classes [] = $ childClass ;
167168 $ property = $ class ->addProperty ($ node ->getName (), $ childClass ->getName ().'[] ' );
168169
169- if (null === $ node ->getKeyAttribute ()) {
170+ if (null === $ key = $ node ->getKeyAttribute ()) {
170171 $ body = '
171172public function NAME(array $value = []): CLASS
172173{
@@ -175,11 +176,11 @@ public function NAME(array $value = []): CLASS
175176 $ class ->addMethod ($ methodName , $ body , ['PROPERTY ' => $ property ->getName (), 'CLASS ' => $ childClass ->getFqcn ()]);
176177 } else {
177178 $ body = '
178- public function NAME(string $key , array $value = []): CLASS
179+ public function NAME(string $VAR , array $VALUE = []): CLASS
179180{
180- return $this->PROPERTY[$key ] = new CLASS($value );
181+ return $this->PROPERTY[$VAR ] = new CLASS($VALUE );
181182} ' ;
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 ' ]);
183184 }
184185
185186 $ this ->buildNode ($ prototype , $ childClass , $ namespace .'\\' .$ childClass ->getName ());
0 commit comments