diff --git a/Formatter/AbstractFormatter.php b/Formatter/AbstractFormatter.php index 17a421d..2f0f243 100644 --- a/Formatter/AbstractFormatter.php +++ b/Formatter/AbstractFormatter.php @@ -127,17 +127,19 @@ abstract class AbstractFormatter implements FormatterInterface { $array = array(); foreach ($collection as $coll) { - if(is_null($coll['annotation']->getSection())) { - $array[$coll['resource']][] = $coll['annotation']->toArray(); - } else { - $array[$coll['annotation']->getSection()][] = $coll['annotation']->toArray(); - } + $array[$coll['annotation']->getSection()][$coll['resource']][] = $coll['annotation']->toArray(); } $processedCollection = array(); - foreach ($array as $path => $annotations) { - foreach ($annotations as $annotation) { - $processedCollection[$path][] = $this->processAnnotation($annotation); + foreach ($array as $section => $resources) { + foreach ($resources as $path => $annotations) { + foreach ($annotations as $annotation) { + if($section) { + $processedCollection[$section][$path][] = $this->processAnnotation($annotation); + } else { + $processedCollection['others'][$path][] = $this->processAnnotation($annotation); + } + } } }