@@ -45,6 +45,11 @@ class RestJsonParser implements Parser
45
45
*/
46
46
private $ functions = [];
47
47
48
+ /**
49
+ * @var array<string, true>
50
+ */
51
+ private $ generatedFunctions = [];
52
+
48
53
/**
49
54
* @var list<ClassName>
50
55
*/
@@ -65,6 +70,7 @@ public function generate(StructureShape $shape, bool $throwOnError = true): Pars
65
70
66
71
$ properties = [];
67
72
$ this ->functions = [];
73
+ $ this ->generatedFunctions = [];
68
74
$ this ->imports = [];
69
75
foreach ($ shape ->getMembers () as $ member ) {
70
76
if (\in_array ($ member ->getLocation (), ['header ' , 'headers ' ])) {
@@ -205,9 +211,9 @@ private function parseElement(string $input, Shape $shape, bool $required, bool
205
211
private function parseResponseStructure (StructureShape $ shape , string $ input , bool $ required ): string
206
212
{
207
213
$ functionName = 'populateResult ' . ucfirst ($ shape ->getName ());
208
- if (!isset ($ this ->functions [$ functionName ])) {
214
+ if (!isset ($ this ->generatedFunctions [$ functionName ])) {
209
215
// prevent recursion
210
- $ this ->functions [$ functionName ] = true ;
216
+ $ this ->generatedFunctions [$ functionName ] = true ;
211
217
212
218
$ properties = [];
213
219
foreach ($ shape ->getMembers () as $ member ) {
@@ -287,9 +293,9 @@ private function parseResponseList(ListShape $shape, string $input, bool $requir
287
293
{
288
294
$ shapeMember = $ shape ->getMember ();
289
295
$ functionName = 'populateResult ' . ucfirst ($ shape ->getName ());
290
- if (!isset ($ this ->functions [$ functionName ])) {
296
+ if (!isset ($ this ->generatedFunctions [$ functionName ])) {
291
297
// prevent recursion
292
- $ this ->functions [$ functionName ] = true ;
298
+ $ this ->generatedFunctions [$ functionName ] = true ;
293
299
294
300
if ($ shapeMember ->getShape () instanceof StructureShape || $ shapeMember ->getShape () instanceof ListShape || $ shapeMember ->getShape () instanceof MapShape) {
295
301
$ listAccessorRequired = true ;
@@ -332,9 +338,9 @@ private function parseResponseMap(MapShape $shape, string $input, bool $required
332
338
{
333
339
$ shapeValue = $ shape ->getValue ();
334
340
$ functionName = 'populateResult ' . ucfirst ($ shape ->getName ());
335
- if (!isset ($ this ->functions [$ functionName ])) {
341
+ if (!isset ($ this ->generatedFunctions [$ functionName ])) {
336
342
// prevent recursion
337
- $ this ->functions [$ functionName ] = true ;
343
+ $ this ->generatedFunctions [$ functionName ] = true ;
338
344
339
345
if (null === $ locationName = $ shape ->getKey ()->getLocationName ()) {
340
346
// We need to use array keys
0 commit comments