Skip to content

Commit df8b4c8

Browse files
Merge pull request #80 from nextcloud/fix/helpers/ref-collection
fix(Helpers): Fix ref collection
2 parents 5c7fe08 + 7174bdf commit df8b4c8

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

src/Helpers.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -253,25 +253,11 @@ public static function getOpenAPIAttributeTagsByScope(ClassMethod|Class_|Node $n
253253

254254
public static function collectUsedRefs(array $data): array {
255255
$refs = [];
256-
if (isset($data['$ref'])) {
257-
$refs[] = [$data['$ref']];
258-
}
259-
260-
foreach (['allOf', 'oneOf', 'anyOf', 'properties', 'additionalProperties'] as $group) {
261-
if (!isset($data[$group]) || !is_array($data[$group])) {
262-
continue;
256+
array_walk_recursive($data, function ($value, $key) use (&$refs) {
257+
if ($key === '$ref') {
258+
$refs[] = $value;
263259
}
264-
265-
foreach ($data[$group] as $property) {
266-
if (is_array($property)) {
267-
$refs[] = self::collectUsedRefs($property);
268-
}
269-
}
270-
}
271-
272-
if (isset($data['items'])) {
273-
$refs[] = self::collectUsedRefs($data['items']);
274-
}
275-
return array_merge(...$refs);
260+
});
261+
return $refs;
276262
}
277263
}

0 commit comments

Comments
 (0)