Completed
Pull Request — master (#572)
by Sang
07:45
created
src/Tools/Traits/ParamHelpers.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@
 block discarded – undo
14 14
     protected function cleanParams(array $params)
15 15
     {
16 16
         $values = [];
17
-        $params = array_filter($params, function ($details) {
18
-            return ! is_null($details['value']);
17
+        $params = array_filter($params, function($details) {
18
+            return !is_null($details['value']);
19 19
         });
20 20
 
21 21
         foreach ($params as $name => $details) {
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::getRouteActionUses($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/RouteMatcher.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
     // for each ruleset in the config file. Not a high priority, though.
55 55
     private function getAllRoutes(bool $usingDingoRouter, array $versions = [])
56 56
     {
57
-        if (! $usingDingoRouter) {
57
+        if (!$usingDingoRouter) {
58 58
             return RouteFacade::getRoutes();
59 59
         }
60 60
 
61 61
         $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes();
62 62
 
63 63
         return collect($allRouteCollections)
64
-            ->flatMap(function (RouteCollection $collection) {
64
+            ->flatMap(function(RouteCollection $collection) {
65 65
                 return $collection->getRoutes();
66 66
             })->toArray();
67 67
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter)
70 70
     {
71 71
         $matchesVersion = $usingDingoRouter
72
-            ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
72
+            ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
73 73
             : true;
74 74
 
75 75
         return Str::is($mustIncludes, $route->getName())
Please login to merge, or discard this patch.
src/Tools/ResponseStrategies/TransformerTagsStrategy.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
             $fractal = new Manager();
51 51
 
52
-            if (! is_null(config('apidoc.fractal.serializer'))) {
52
+            if (!is_null(config('apidoc.fractal.serializer'))) {
53 53
                 $fractal->setSerializer(app(config('apidoc.fractal.serializer')));
54 54
             }
55 55
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     private function getClassToBeTransformed(array $tags, ReflectionMethod $transformerMethod)
83 83
     {
84
-        $modelTag = Arr::first(array_filter($tags, function ($tag) {
84
+        $modelTag = Arr::first(array_filter($tags, function($tag) {
85 85
             return ($tag instanceof Tag) && strtolower($tag->getName()) == 'transformermodel';
86 86
         }));
87 87
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             $type = $modelTag->getContent();
91 91
         } else {
92 92
             $parameter = Arr::first($transformerMethod->getParameters());
93
-            if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) {
93
+            if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) {
94 94
                 // ladies and gentlemen, we have a type!
95 95
                 $type = (string) $parameter->getType();
96 96
             }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     private function getTransformerTag(array $tags)
143 143
     {
144 144
         $transFormerTags = array_values(
145
-            array_filter($tags, function ($tag) {
145
+            array_filter($tags, function($tag) {
146 146
                 return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']);
147 147
             })
148 148
         );
Please login to merge, or discard this patch.