File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -178,8 +178,23 @@ private function buildOpenapi(\SimpleXMLElement $resource): bool|OpenApiOperatio
178178 $ openapi = $ resource ->openapi ;
179179 $ data = [];
180180 $ attributes = $ openapi ->attributes ();
181- foreach ($ attributes as $ attribute ) {
182- $ data [$ attribute ->getName ()] = $ this ->phpize ($ attributes , 'deprecated ' , 'deprecated ' === $ attribute ->getName () ? 'bool ' : 'string ' );
181+
182+ /*
183+ * \SimpleXMLElement should not be read in an iteration because of a known bug in SimpleXML lib that resets the iterator
184+ * and leads to infinite loop
185+ * https://bugs.php.net/bug.php?id=55098
186+ * https://github.com/php/php-src/issues/12208
187+ * https://github.com/php/php-src/issues/12192
188+ *
189+ * attribute names are stored in an iteration and values are fetched in another one
190+ */
191+ $ attributeNames = [];
192+ foreach ($ attributes as $ name => $ attribute ) {
193+ $ attributeNames [] = $ name ;
194+ }
195+
196+ foreach ($ attributeNames as $ attributeName ) {
197+ $ data [$ attributeName ] = $ this ->phpize ($ attributes , $ attributeName , 'deprecated ' === $ attributeName ? 'bool ' : 'string ' );
183198 }
184199
185200 $ data ['tags ' ] = $ this ->buildArrayValue ($ resource , 'tag ' );
You can’t perform that action at this time.
0 commit comments