Skip to content

Commit 6793426

Browse files
author
Johan Dos Santos
committed
fix(metadata): build Open Api attributes in XmlResourceExtractor
chore: cs fixer
1 parent 84b9679 commit 6793426

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/Metadata/Extractor/XmlResourceExtractor.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff 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');

0 commit comments

Comments
 (0)