Completed
Pull Request — master (#570)
by Marcel
01:55
created
src/Tools/Utils.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
      * @param string $uri
50 50
      * @param array $bindings
51 51
      *
52
-     * @return mixed
52
+     * @return string
53 53
      */
54 54
     public static function replaceUrlParameterBindings(string $uri, array $bindings)
55 55
     {
Please login to merge, or discard this patch.
src/Strategies/Metadata/GetFromDocBlocks.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     protected function getAuthStatusFromDocBlock(array $tags)
38 38
     {
39 39
         $authTag = collect($tags)
40
-            ->first(function ($tag) {
40
+            ->first(function($tag) {
41 41
                 return $tag instanceof Tag && strtolower($tag->getName()) === 'authenticated';
42 42
             });
43 43
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     protected function getRouteGroupDescriptionAndTitle(DocBlock $methodDocBlock, DocBlock $controllerDocBlock)
54 54
     {
55 55
         // @group tag on the method overrides that on the controller
56
-        if (! empty($methodDocBlock->getTags())) {
56
+        if (!empty($methodDocBlock->getTags())) {
57 57
             foreach ($methodDocBlock->getTags() as $tag) {
58 58
                 if ($tag->getName() === 'group') {
59 59
                     $routeGroupParts = explode("\n", trim($tag->getContent()));
Please login to merge, or discard this patch.
src/Strategies/Responses/UseResponseTag.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     protected function getDocBlockResponses(array $tags)
44 44
     {
45 45
         $responseTags = array_values(
46
-            array_filter($tags, function ($tag) {
46
+            array_filter($tags, function($tag) {
47 47
                 return $tag instanceof Tag && strtolower($tag->getName()) === 'response';
48 48
             })
49 49
         );
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             return null;
53 53
         }
54 54
 
55
-        $responses = array_map(function (Tag $responseTag) {
55
+        $responses = array_map(function(Tag $responseTag) {
56 56
             preg_match('/^(\d{3})?\s?([\s\S]*)$/', $responseTag->getContent(), $result);
57 57
 
58 58
             $status = $result[1] ?: 200;
Please login to merge, or discard this patch.
src/Strategies/Responses/UseResponseFileTag.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         // Avoid "holes" in the keys of the filtered array, by using array_values on the filtered array
46 46
         $responseFileTags = array_values(
47
-            array_filter($tags, function ($tag) {
47
+            array_filter($tags, function($tag) {
48 48
                 return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile';
49 49
             })
50 50
         );
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
             return null;
54 54
         }
55 55
 
56
-        $responses = array_map(function (Tag $responseFileTag) {
56
+        $responses = array_map(function(Tag $responseFileTag) {
57 57
             preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result);
58 58
             $status = $result[1] ?: 200;
59 59
             $content = $result[2] ? file_get_contents(storage_path(trim($result[2])), true) : '{}';
60
-            $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
60
+            $json = !empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
61 61
             $merged = array_merge(json_decode($content, true), json_decode($json, true));
62 62
 
63 63
             return [json_encode($merged), (int) $status];
Please login to merge, or discard this patch.
src/Commands/GenerateDocumentation.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         $parsedRoutes = $this->processRoutes($generator, $routes);
85 85
         $groupedRoutes = collect($parsedRoutes)
86 86
             ->groupBy('groupName')
87
-            ->sortBy(static function ($group) {
87
+            ->sortBy(static function($group) {
88 88
                 /* @var $group Collection */
89 89
                 return $group->first()['groupName'];
90 90
             }, SORT_NATURAL);
@@ -100,19 +100,19 @@  discard block
 block discarded – undo
100 100
     private function writeMarkdown($parsedRoutes)
101 101
     {
102 102
         $outputPath = $this->docConfig->get('output');
103
-        $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md';
104
-        $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md';
105
-        $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md';
106
-        $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md';
103
+        $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md';
104
+        $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md';
105
+        $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md';
106
+        $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md';
107 107
 
108 108
         $infoText = view('apidoc::partials.info')
109 109
             ->with('outputPath', ltrim($outputPath, 'public/'))
110 110
             ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection());
111 111
 
112 112
         $settings = ['languages' => $this->docConfig->get('example_languages')];
113
-        $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) use ($settings) {
114
-            return $routeGroup->map(function ($route) use ($settings) {
115
-                if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) {
113
+        $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) use ($settings) {
114
+            return $routeGroup->map(function($route) use ($settings) {
115
+                if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) {
116 116
                     $route['headers']['Content-Type'] = 'application/json';
117 117
                 }
118 118
                 $route['output'] = (string) view('apidoc::partials.route')
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
                 $frontmatter = trim($generatedFrontmatter[1], "\n");
140 140
             }
141 141
 
142
-            $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
143
-                return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) {
144
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) {
145
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
142
+            $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
143
+                return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) {
144
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) {
145
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
146 146
                         if ($routeDocumentationChanged === false || $this->option('force')) {
147 147
                             if ($routeDocumentationChanged) {
148
-                                $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
148
+                                $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
149 149
                             }
150 150
                         } else {
151
-                            $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
151
+                            $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
152 152
                             $route['modified_output'] = $existingRouteDoc[0];
153 153
                         }
154 154
                     }
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
         }
160 160
 
161 161
         $prependFileContents = file_exists($prependFile)
162
-            ? file_get_contents($prependFile)."\n" : '';
162
+            ? file_get_contents($prependFile) . "\n" : '';
163 163
         $appendFileContents = file_exists($appendFile)
164
-            ? "\n".file_get_contents($appendFile) : '';
164
+            ? "\n" . file_get_contents($appendFile) : '';
165 165
 
166 166
         $documentarian = new Documentarian();
167 167
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
             ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection())
176 176
             ->with('parsedRoutes', $parsedRouteOutput);
177 177
 
178
-        if (! is_dir($outputPath)) {
178
+        if (!is_dir($outputPath)) {
179 179
             $documentarian->create($outputPath);
180 180
         }
181 181
 
@@ -195,24 +195,24 @@  discard block
 block discarded – undo
195 195
 
196 196
         file_put_contents($compareFile, $compareMarkdown);
197 197
 
198
-        $this->info('Wrote index.md to: '.$outputPath);
198
+        $this->info('Wrote index.md to: ' . $outputPath);
199 199
 
200 200
         $this->info('Generating API HTML code');
201 201
 
202 202
         $documentarian->generate($outputPath);
203 203
 
204
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
204
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
205 205
 
206 206
         if ($this->shouldGeneratePostmanCollection()) {
207 207
             $this->info('Generating Postman collection');
208 208
 
209
-            file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
209
+            file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes));
210 210
         }
211 211
 
212 212
         if ($logo = $this->docConfig->get('logo')) {
213 213
             copy(
214 214
                 $logo,
215
-                $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png'
215
+                $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png'
216 216
             );
217 217
         }
218 218
     }
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
             /** @var Route $route */
232 232
             if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction())) {
233 233
                 $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']);
234
-                $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
234
+                $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
235 235
             } else {
236
-                $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
236
+                $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
237 237
             }
238 238
         }
239 239
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
             $action = implode('@', $action);
253 253
         }
254 254
 
255
-        return ! is_callable($action) && ! is_null($action);
255
+        return !is_callable($action) && !is_null($action);
256 256
     }
257 257
 
258 258
     /**
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         list($class, $method) = Utils::getRouteClassAndMethodNames($action);
268 268
         $reflection = new ReflectionClass($class);
269 269
 
270
-        if (! $reflection->hasMethod($method)) {
270
+        if (!$reflection->hasMethod($method)) {
271 271
             return false;
272 272
         }
273 273
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             $phpdoc = new DocBlock($comment);
278 278
 
279 279
             return collect($phpdoc->getTags())
280
-                ->filter(function ($tag) {
280
+                ->filter(function($tag) {
281 281
                     return $tag->getName() === 'hideFromAPIDocumentation';
282 282
                 })
283 283
                 ->isEmpty();
Please login to merge, or discard this patch.
src/Tools/RouteDocBlocker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 
21 21
         $class = new ReflectionClass($className);
22 22
 
23
-        if (! $class->hasMethod($methodName)) {
23
+        if (!$class->hasMethod($methodName)) {
24 24
             throw new \Exception("Error while fetching docblock for route: Class $className does not contain method $methodName");
25 25
         }
26 26
 
Please login to merge, or discard this patch.
src/Tools/Traits/ParamHelpers.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
      *
78 78
      * @param string $type
79 79
      *
80
-     * @return mixed|string
80
+     * @return string
81 81
      */
82 82
     protected function normalizeParameterType(string $type)
83 83
     {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@
 block discarded – undo
13 13
             $faker->seed($this->config->get('faker_seed'));
14 14
         }
15 15
         $fakeFactories = [
16
-            'integer' => function () use ($faker) {
16
+            'integer' => function() use ($faker) {
17 17
                 return $faker->numberBetween(1, 20);
18 18
             },
19
-            'number' => function () use ($faker) {
19
+            'number' => function() use ($faker) {
20 20
                 return $faker->randomFloat();
21 21
             },
22
-            'float' => function () use ($faker) {
22
+            'float' => function() use ($faker) {
23 23
                 return $faker->randomFloat();
24 24
             },
25
-            'boolean' => function () use ($faker) {
25
+            'boolean' => function() use ($faker) {
26 26
                 return $faker->boolean();
27 27
             },
28
-            'string' => function () use ($faker) {
28
+            'string' => function() use ($faker) {
29 29
                 return $faker->word;
30 30
             },
31
-            'array' => function () {
31
+            'array' => function() {
32 32
                 return [];
33 33
             },
34
-            'object' => function () {
34
+            'object' => function() {
35 35
                 return new \stdClass;
36 36
             },
37 37
         ];
Please login to merge, or discard this patch.
src/Strategies/QueryParameters/GetFromQueryParamTag.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
     private function getQueryParametersFromDocBlock($tags)
57 57
     {
58 58
         $parameters = collect($tags)
59
-            ->filter(function ($tag) {
59
+            ->filter(function($tag) {
60 60
                 return $tag instanceof Tag && $tag->getName() === 'queryParam';
61 61
             })
62
-            ->mapWithKeys(function ($tag) {
62
+            ->mapWithKeys(function($tag) {
63 63
                 preg_match('/(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content);
64 64
                 $content = preg_replace('/\s?No-example.?/', '', $content);
65 65
                 if (empty($content)) {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
                 }
79 79
 
80 80
                 list($description, $value) = $this->parseParamDescription($description, 'string');
81
-                if (is_null($value) && ! $this->shouldExcludeExample($tag)) {
81
+                if (is_null($value) && !$this->shouldExcludeExample($tag)) {
82 82
                     $value = Str::contains($description, ['number', 'count', 'page'])
83 83
                         ? $this->generateDummyValue('integer')
84 84
                         : $this->generateDummyValue('string');
Please login to merge, or discard this patch.
src/Strategies/Responses/ResponseCalls.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function __invoke(Route $route, \ReflectionClass $controller, \ReflectionMethod $method, array $routeRules, array $context = [])
32 32
     {
33 33
         $rulesToApply = $routeRules['response_calls'] ?? [];
34
-        if (! $this->shouldMakeApiCall($route, $rulesToApply, $context)) {
34
+        if (!$this->shouldMakeApiCall($route, $rulesToApply, $context)) {
35 35
             return null;
36 36
         }
37 37
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         try {
46 46
             $response = [200 => $this->makeApiCall($request)->getContent()];
47 47
         } catch (\Exception $e) {
48
-            echo 'Exception thrown during response call for ['.implode(',', $route->methods)."] {$route->uri}.\n";
48
+            echo 'Exception thrown during response call for [' . implode(',', $route->methods) . "] {$route->uri}.\n";
49 49
             if (Flags::$shouldBeVerbose) {
50 50
                 Utils::dumpException($e);
51 51
             } else {
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
         // set URL and query parameters
179 179
         $uri = $request->getRequestUri();
180 180
         $query = $request->getQueryString();
181
-        if (! empty($query)) {
181
+        if (!empty($query)) {
182 182
             $uri .= "?$query";
183 183
         }
184 184
         $response = call_user_func_array([$dispatcher, strtolower($request->method())], [$uri]);
185 185
 
186 186
         // the response from the Dingo dispatcher is the 'raw' response from the controller,
187 187
         // so we have to ensure it's JSON first
188
-        if (! $response instanceof Response) {
188
+        if (!$response instanceof Response) {
189 189
             $response = response()->json($response);
190 190
         }
191 191
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
             return false;
306 306
         }
307 307
 
308
-        if (! empty($context['responses'])) {
308
+        if (!empty($context['responses'])) {
309 309
             // Don't attempt a response call if there are already responses
310 310
             return false;
311 311
         }
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
         $prefix = 'HTTP_';
340 340
         foreach ($headers as $name => $value) {
341 341
             $name = strtr(strtoupper($name), '-', '_');
342
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
343
-                $name = $prefix.$name;
342
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
343
+                $name = $prefix . $name;
344 344
             }
345 345
             $server[$name] = $value;
346 346
         }
Please login to merge, or discard this patch.