Completed
Push — master ( c5c478...380cbb )
by Marcel
10:11 queued 07:50
created
src/Generators/AbstractGenerator.php 2 patches
Doc Comments   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     /**
27 27
      * @param Route $route
28 28
      *
29
-     * @return mixed
29
+     * @return string
30 30
      */
31 31
     public function getUri(Route $route)
32 32
     {
@@ -90,7 +90,6 @@  discard block
 block discarded – undo
90 90
     /**
91 91
      * Prepares / Disables route middlewares.
92 92
      *
93
-     * @param  bool $disable
94 93
      *
95 94
      * @return  void
96 95
      */
@@ -161,7 +160,7 @@  discard block
 block discarded – undo
161 160
      * @param $route
162 161
      * @param array $bindings
163 162
      *
164
-     * @return mixed
163
+     * @return string
165 164
      */
166 165
     protected function addRouteModelBindings($route, $bindings)
167 166
     {
@@ -177,7 +176,7 @@  discard block
 block discarded – undo
177 176
     /**
178 177
      * @param  \Illuminate\Routing\Route  $route
179 178
      *
180
-     * @return array
179
+     * @return Route
181 180
      */
182 181
     protected function getRouteDescription($route)
183 182
     {
@@ -260,7 +259,7 @@  discard block
 block discarded – undo
260 259
     /**
261 260
      * @param $response
262 261
      *
263
-     * @return mixed
262
+     * @return Route
264 263
      */
265 264
     private function getResponseContent($response)
266 265
     {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             $response = $docblockResponse;
64 64
             $showresponse = true;
65 65
         }
66
-        if (! $response) {
66
+        if (!$response) {
67 67
             $transformerResponse = $this->getTransformerResponse($routeDescription['tags']);
68 68
             if ($transformerResponse) {
69 69
                 // we have a transformer response from the docblock ( @transformer || @transformercollection )
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         $content = $this->getResponseContent($response);
76 76
 
77 77
         return [
78
-            'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))),
78
+            'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))),
79 79
             'resource' => $routeGroup,
80 80
             'title' => $routeDescription['short'],
81 81
             'description' => $routeDescription['long'],
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function getDocblockResponse($tags)
107 107
     {
108
-        $responseTags = array_filter($tags, function ($tag) {
109
-            if (! ($tag instanceof Tag)) {
108
+        $responseTags = array_filter($tags, function($tag) {
109
+            if (!($tag instanceof Tag)) {
110 110
                 return false;
111 111
             }
112 112
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         $methods = $this->getMethods($route);
144 144
 
145 145
         // Split headers into key - value pairs
146
-        $headers = collect($headers)->map(function ($value) {
146
+        $headers = collect($headers)->map(function($value) {
147 147
             $split = explode(':', $value); // explode to get key + values
148 148
             $key = array_shift($split); // extract the key and keep the values in the array
149 149
             $value = implode(':', $split); // implode values into string again
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $uri = $this->getUri($route);
169 169
         foreach ($bindings as $model => $id) {
170
-            $uri = str_replace('{'.$model.'}', $id, $uri);
171
-            $uri = str_replace('{'.$model.'?}', $id, $uri);
170
+            $uri = str_replace('{' . $model . '}', $id, $uri);
171
+            $uri = str_replace('{' . $model . '?}', $id, $uri);
172 172
         }
173 173
 
174 174
         return $uri;
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
         foreach ($headers as $name => $value) {
248 248
             $name = strtr(strtoupper($name), '-', '_');
249 249
 
250
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
251
-                $name = $prefix.$name;
250
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
251
+                $name = $prefix . $name;
252 252
             }
253 253
 
254 254
             $server[$name] = $value;
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
     protected function getTransformerResponse($tags)
287 287
     {
288 288
         try {
289
-            $transFormerTags = array_filter($tags, function ($tag) {
290
-                if (! ($tag instanceof Tag)) {
289
+            $transFormerTags = array_filter($tags, function($tag) {
290
+                if (!($tag instanceof Tag)) {
291 291
                     return false;
292 292
                 }
293 293
 
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
                 return false;
299 299
             }
300 300
 
301
-            $modelTag = array_first(array_filter($tags, function ($tag) {
302
-                if (! ($tag instanceof Tag)) {
301
+            $modelTag = array_first(array_filter($tags, function($tag) {
302
+                if (!($tag instanceof Tag)) {
303 303
                     return false;
304 304
                 }
305 305
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
             }));
308 308
             $tag = \array_first($transFormerTags);
309 309
             $transformer = $tag->getContent();
310
-            if (! \class_exists($transformer)) {
310
+            if (!\class_exists($transformer)) {
311 311
                 // if we can't find the transformer we can't generate a response
312 312
                 return;
313 313
             }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
             if (version_compare(PHP_VERSION, '7.0.0') >= 0 && \is_null($type)) {
324 324
                 // we can only get the type with reflection for PHP 7
325 325
                 if ($parameter->hasType() &&
326
-                    ! $parameter->getType()->isBuiltin() &&
326
+                    !$parameter->getType()->isBuiltin() &&
327 327
                     \class_exists((string) $parameter->getType())) {
328 328
                     //we have a type
329 329
                     $type = (string) $parameter->getType();
Please login to merge, or discard this patch.
src/Generators/LaravelGenerator.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,6 @@
 block discarded – undo
41 41
     /**
42 42
      * Prepares / Disables route middlewares.
43 43
      *
44
-     * @param  bool $disable
45 44
      *
46 45
      * @return  void
47 46
      */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
      */
58 58
     public function prepareMiddleware($enable = true)
59 59
     {
60
-        App::instance('middleware.disable', ! $enable);
60
+        App::instance('middleware.disable', !$enable);
61 61
     }
62 62
 
63 63
     /**
Please login to merge, or discard this patch.
src/Generators/DingoGenerator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
     {
26 26
         $dispatcher = app('Dingo\Api\Dispatcher')->raw();
27 27
 
28
-        collect($server)->map(function ($key, $value) use ($dispatcher) {
28
+        collect($server)->map(function($key, $value) use ($dispatcher) {
29 29
             $dispatcher->header($value, $key);
30 30
         });
31 31
 
Please login to merge, or discard this patch.
src/Commands/UpdateDocumentation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 
45 45
         $documentarian = new Documentarian();
46 46
 
47
-        if (! is_dir($outputPath)) {
48
-            $this->error('There is no generated documentation available at '.$outputPath.'.');
47
+        if (!is_dir($outputPath)) {
48
+            $this->error('There is no generated documentation available at ' . $outputPath . '.');
49 49
 
50 50
             return false;
51 51
         }
@@ -53,6 +53,6 @@  discard block
 block discarded – undo
53 53
 
54 54
         $documentarian->generate($outputPath);
55 55
 
56
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
56
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
57 57
     }
58 58
 }
Please login to merge, or discard this patch.
src/Postman/CollectionWriter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
                 'description' => '',
33 33
                 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json',
34 34
             ],
35
-            'item' => $this->routeGroups->map(function ($routes, $groupName) {
35
+            'item' => $this->routeGroups->map(function($routes, $groupName) {
36 36
                 return [
37 37
                     'name' => $groupName,
38 38
                     'description' => '',
39
-                    'item' => $routes->map(function ($route) {
39
+                    'item' => $routes->map(function($route) {
40 40
                         return [
41 41
                             'name' => $route['title'] != '' ? $route['title'] : url($route['uri']),
42 42
                             'request' => [
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
                                 'method' => $route['methods'][0],
45 45
                                 'body' => [
46 46
                                     'mode' => 'formdata',
47
-                                    'formdata' => collect($route['parameters'])->map(function ($parameter, $key) {
47
+                                    'formdata' => collect($route['parameters'])->map(function($parameter, $key) {
48 48
                                         return [
49 49
                                             'key' => $key,
50 50
                                             'value' => isset($parameter['value']) ? $parameter['value'] : '',
Please login to merge, or discard this patch.
src/ApiDocGeneratorServiceProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@
 block discarded – undo
15 15
      */
16 16
     public function boot()
17 17
     {
18
-        $this->loadViewsFrom(__DIR__.'/../resources/views/', 'apidoc');
18
+        $this->loadViewsFrom(__DIR__ . '/../resources/views/', 'apidoc');
19 19
 
20 20
         $this->publishes([
21
-            __DIR__.'/../resources/views' => app()->basePath().'/resources/views/vendor/apidoc',
21
+            __DIR__ . '/../resources/views' => app()->basePath() . '/resources/views/vendor/apidoc',
22 22
         ], 'views');
23 23
 
24 24
         $this->publishes([
25
-            __DIR__.'/../config/apidoc.php' => config_path('apidoc.php'),
25
+            __DIR__ . '/../config/apidoc.php' => config_path('apidoc.php'),
26 26
         ], 'config');
27 27
 
28 28
         if ($this->app->runningInConsole()) {
Please login to merge, or discard this patch.
src/Tools/RouteMatcher.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 
49 49
     private function getAllRoutes(bool $usingDingoRouter, array $versions = [])
50 50
     {
51
-        if (! $usingDingoRouter) {
51
+        if (!$usingDingoRouter) {
52 52
             return RouteFacade::getRoutes();
53 53
         }
54 54
 
55 55
         $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes();
56 56
 
57 57
         return collect($allRouteCollections)
58
-            ->flatMap(function (RouteCollection $collection) {
58
+            ->flatMap(function(RouteCollection $collection) {
59 59
                 return $collection->getRoutes();
60 60
             })->toArray();
61 61
     }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter)
64 64
     {
65 65
         $matchesVersion = $usingDingoRouter
66
-            ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
66
+            ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
67 67
             : true;
68 68
 
69 69
         return in_array($route->getName(), $mustIncludes)
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
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
         $parsedRoutes = $this->processRoutes($generator, $routes);
61 61
         $parsedRoutes = collect($parsedRoutes)->groupBy('resource')
62
-            ->sort(function ($a, $b) {
62
+            ->sort(function($a, $b) {
63 63
                 return strcmp($a->first()['resource'], $b->first()['resource']);
64 64
             });
65 65
 
@@ -74,17 +74,17 @@  discard block
 block discarded – undo
74 74
     private function writeMarkdown($parsedRoutes)
75 75
     {
76 76
         $outputPath = $this->option('output');
77
-        $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md';
78
-        $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md';
79
-        $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md';
80
-        $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md';
77
+        $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md';
78
+        $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md';
79
+        $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md';
80
+        $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md';
81 81
 
82 82
         $infoText = view('apidoc::partials.info')
83 83
             ->with('outputPath', ltrim($outputPath, 'public/'))
84
-            ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection'));
84
+            ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection'));
85 85
 
86
-        $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) {
87
-            return $routeGroup->map(function ($route) {
86
+        $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) {
87
+            return $routeGroup->map(function($route) {
88 88
                 $route['output'] = (string) view('apidoc::partials.route')->with('parsedRoute', $route)->render();
89 89
 
90 90
                 return $route;
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
                 $frontmatter = trim($generatedFrontmatter[1], "\n");
105 105
             }
106 106
 
107
-            $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
108
-                return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) {
109
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $routeMatch)) {
110
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]);
107
+            $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
108
+                return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) {
109
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $routeMatch)) {
110
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]);
111 111
                         if ($routeDocumentationChanged === false || $this->option('force')) {
112 112
                             if ($routeDocumentationChanged) {
113
-                                $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
113
+                                $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
114 114
                             }
115 115
                         } else {
116
-                            $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
116
+                            $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
117 117
                             $route['modified_output'] = $routeMatch[0];
118 118
                         }
119 119
                     }
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
         }
125 125
 
126 126
         $prependFileContents = file_exists($prependFile)
127
-            ? file_get_contents($prependFile)."\n" : '';
127
+            ? file_get_contents($prependFile) . "\n" : '';
128 128
         $appendFileContents = file_exists($appendFile)
129
-            ? "\n".file_get_contents($appendFile) : '';
129
+            ? "\n" . file_get_contents($appendFile) : '';
130 130
 
131 131
         $documentarian = new Documentarian();
132 132
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
             ->with('prependMd', $prependFileContents)
138 138
             ->with('appendMd', $appendFileContents)
139 139
             ->with('outputPath', $this->option('output'))
140
-            ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection'))
140
+            ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection'))
141 141
             ->with('parsedRoutes', $parsedRouteOutput);
142 142
 
143
-        if (! is_dir($outputPath)) {
143
+        if (!is_dir($outputPath)) {
144 144
             $documentarian->create($outputPath);
145 145
         }
146 146
 
@@ -155,23 +155,23 @@  discard block
 block discarded – undo
155 155
             ->with('prependMd', $prependFileContents)
156 156
             ->with('appendMd', $appendFileContents)
157 157
             ->with('outputPath', $this->option('output'))
158
-            ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection'))
158
+            ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection'))
159 159
             ->with('parsedRoutes', $parsedRouteOutput);
160 160
 
161 161
         file_put_contents($compareFile, $compareMarkdown);
162 162
 
163
-        $this->info('Wrote index.md to: '.$outputPath);
163
+        $this->info('Wrote index.md to: ' . $outputPath);
164 164
 
165 165
         $this->info('Generating API HTML code');
166 166
 
167 167
         $documentarian->generate($outputPath);
168 168
 
169
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
169
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
170 170
 
171 171
         if ($this->option('noPostmanCollection') !== true) {
172 172
             $this->info('Generating Postman collection');
173 173
 
174
-            file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
174
+            file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes));
175 175
         }
176 176
     }
177 177
 
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
             /** @var Route $route */
189 189
             if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
190 190
                 $parsedRoutes[] = $generator->processRoute($route, $apply);
191
-                $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
191
+                $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
192 192
             } else {
193
-                $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
193
+                $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
194 194
             }
195 195
         }
196 196
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     private function isValidRoute(Route $route)
206 206
     {
207
-        return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']);
207
+        return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']);
208 208
     }
209 209
 
210 210
     /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
             $phpdoc = new DocBlock($comment);
222 222
 
223 223
             return collect($phpdoc->getTags())
224
-                ->filter(function ($tag) use ($route) {
224
+                ->filter(function($tag) use ($route) {
225 225
                     return $tag->getName() === 'hideFromAPIDocumentation';
226 226
                 })
227 227
                 ->isEmpty();
Please login to merge, or discard this patch.