Browse Source

Merge pull request #427 from MacPrawn/master

Fixed display of @fileResponse strategy
Shalvah 6 years ago
parent
commit
355d55eb91

+ 6 - 3
src/Tools/ResponseStrategies/ResponseFileStrategy.php

@@ -32,9 +32,12 @@ class ResponseFileStrategy
      */
     protected function getFileResponses(array $tags)
     {
-        $responseFileTags = array_filter($tags, function ($tag) {
-            return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile';
-        });
+        // avoid "holes" in the keys of the filtered array, by using array_values on the filtered array
+        $responseFileTags = array_values(
+            array_filter($tags, function ($tag) {
+                return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile';
+            })
+        );
 
         if (empty($responseFileTags)) {
             return;

+ 5 - 3
src/Tools/ResponseStrategies/ResponseTagStrategy.php

@@ -32,9 +32,11 @@ class ResponseTagStrategy
      */
     protected function getDocBlockResponses(array $tags)
     {
-        $responseTags = array_filter($tags, function ($tag) {
-            return $tag instanceof Tag && strtolower($tag->getName()) === 'response';
-        });
+        $responseTags = array_values(
+            array_filter($tags, function ($tag) {
+                return $tag instanceof Tag && strtolower($tag->getName()) === 'response';
+            })
+        );
 
         if (empty($responseTags)) {
             return;

+ 5 - 3
src/Tools/ResponseStrategies/TransformerTagsStrategy.php

@@ -127,9 +127,11 @@ class TransformerTagsStrategy
      */
     private function getTransformerTag(array $tags)
     {
-        $transFormerTags = array_filter($tags, function ($tag) {
-            return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']);
-        });
+        $transFormerTags = array_values(
+            array_filter($tags, function ($tag) {
+                return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']);
+            })
+        );
 
         return array_first($transFormerTags);
     }