Completed
Pull Request — master (#445)
by
unknown
02:02
created
src/Commands/UpdateDocumentation.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@
 block discarded – undo
42 42
 
43 43
         $documentarian = new Documentarian();
44 44
 
45
-        if (! is_dir($outputPath)) {
46
-            $this->error('There is no existing documentation available at '.$outputPath.'.');
45
+        if (!is_dir($outputPath)) {
46
+            $this->error('There is no existing documentation available at ' . $outputPath . '.');
47 47
 
48 48
             return false;
49 49
         }
50
-        $this->info('Rebuilding API HTML code from '.$outputPath.'/source/index.md');
50
+        $this->info('Rebuilding API HTML code from ' . $outputPath . '/source/index.md');
51 51
 
52 52
         $documentarian->generate($outputPath);
53 53
 
54
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
54
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
55 55
     }
56 56
 }
Please login to merge, or discard this patch.
src/Tools/ResponseStrategies/ResponseCallStrategy.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     public function __invoke(Route $route, array $tags, array $routeProps)
16 16
     {
17 17
         $rulesToApply = $routeProps['rules']['response_calls'] ?? [];
18
-        if (! $this->shouldMakeApiCall($route, $rulesToApply)) {
18
+        if (!$this->shouldMakeApiCall($route, $rulesToApply)) {
19 19
             return;
20 20
         }
21 21
 
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
         // set URL and query parameters
125 125
         $uri = $request->getRequestUri();
126 126
         $query = $request->getQueryString();
127
-        if (! empty($query)) {
127
+        if (!empty($query)) {
128 128
             $uri .= "?$query";
129 129
         }
130 130
         $response = call_user_func_array([$dispatcher, strtolower($request->method())], [$uri]);
131 131
 
132 132
         // the response from the Dingo dispatcher is the 'raw' response from the controller,
133 133
         // so we have to ensure it's JSON first
134
-        if (! $response instanceof Response) {
134
+        if (!$response instanceof Response) {
135 135
             $response = response()->json($response);
136 136
         }
137 137
 
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
         $prefix = 'HTTP_';
239 239
         foreach ($headers as $name => $value) {
240 240
             $name = strtr(strtoupper($name), '-', '_');
241
-            if (! starts_with($name, $prefix) && $name !== 'CONTENT_TYPE') {
242
-                $name = $prefix.$name;
241
+            if (!starts_with($name, $prefix) && $name !== 'CONTENT_TYPE') {
242
+                $name = $prefix . $name;
243 243
             }
244 244
             $server[$name] = $value;
245 245
         }
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
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 
51 51
     private function getAllRoutes(bool $usingDingoRouter, array $versions = [])
52 52
     {
53
-        if (! $usingDingoRouter) {
53
+        if (!$usingDingoRouter) {
54 54
             return RouteFacade::getRoutes();
55 55
         }
56 56
 
57 57
         $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes();
58 58
 
59 59
         return collect($allRouteCollections)
60
-            ->flatMap(function (RouteCollection $collection) {
60
+            ->flatMap(function(RouteCollection $collection) {
61 61
                 return $collection->getRoutes();
62 62
             })->toArray();
63 63
     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter)
66 66
     {
67 67
         $matchesVersion = $usingDingoRouter
68
-            ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
68
+            ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? []))
69 69
             : true;
70 70
 
71 71
         return str_is($mustIncludes, $route->getName())
Please login to merge, or discard this patch.
src/Tools/ResponseResolver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,8 @@
 block discarded – undo
48 48
             /** @var Response[]|null $response */
49 49
             $responses = $strategy($this->route, $tags, $routeProps);
50 50
 
51
-            if (! is_null($responses)) {
52
-                return array_map(function (Response $response) {
51
+            if (!is_null($responses)) {
52
+                return array_map(function(Response $response) {
53 53
                     return ['status' => $response->getStatusCode(), 'content' => $this->getResponseContent($response)];
54 54
                 }, $responses);
55 55
             }
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
                         $mode = $route['methods'][0] === 'PUT' ? 'urlencoded' : 'formdata';
41 41
 
42 42
                         return [
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
                                 'method' => $route['methods'][0],
47 47
                                 'body' => [
48 48
                                     'mode' => $mode,
49
-                                    $mode => collect($route['bodyParameters'])->map(function ($parameter, $key) {
49
+                                    $mode => collect($route['bodyParameters'])->map(function($parameter, $key) {
50 50
                                         return [
51 51
                                             'key' => $key,
52 52
                                             'value' => isset($parameter['value']) ? $parameter['value'] : '',
Please login to merge, or discard this patch.
src/Tools/ResponseStrategies/ResponseTagStrategy.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     protected function getDocBlockResponses(array $tags)
34 34
     {
35 35
         $responseTags = array_values(
36
-            array_filter($tags, function ($tag) {
36
+            array_filter($tags, function($tag) {
37 37
                 return $tag instanceof Tag && strtolower($tag->getName()) === 'response';
38 38
             })
39 39
         );
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             return;
43 43
         }
44 44
 
45
-        return array_map(function (Tag $responseTag) {
45
+        return array_map(function(Tag $responseTag) {
46 46
             preg_match('/^(\d{3})?\s?([\s\S]*)$/', $responseTag->getContent(), $result);
47 47
 
48 48
             $status = $result[1] ?: 200;
Please login to merge, or discard this patch.
src/Commands/GenerateDocumentation.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $generator = new Generator();
57 57
         $parsedRoutes = $this->processRoutes($generator, $routes);
58 58
         $parsedRoutes = collect($parsedRoutes)->groupBy('group')
59
-            ->sortBy(static function ($group) {
59
+            ->sortBy(static function($group) {
60 60
                 /* @var $group Collection */
61 61
                 return $group->first()['group'];
62 62
             }, SORT_NATURAL);
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
     private function writeMarkdown($parsedRoutes)
73 73
     {
74 74
         $outputPath = config('apidoc.output');
75
-        $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md';
76
-        $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md';
77
-        $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md';
78
-        $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md';
75
+        $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md';
76
+        $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md';
77
+        $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md';
78
+        $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md';
79 79
 
80 80
         $infoText = view('apidoc::partials.info')
81 81
             ->with('outputPath', ltrim($outputPath, 'public/'))
82 82
             ->with('showPostmanCollectionButton', config('apidoc.postman'));
83 83
 
84
-        $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) {
85
-            return $routeGroup->map(function ($route) {
84
+        $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) {
85
+            return $routeGroup->map(function($route) {
86 86
                 $route['output'] = (string) view('apidoc::partials.route')->with('route', $route)->render();
87 87
 
88 88
                 return $route;
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
                 $frontmatter = trim($generatedFrontmatter[1], "\n");
103 103
             }
104 104
 
105
-            $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
106
-                return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) {
107
-                    if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) {
108
-                        $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
105
+            $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) {
106
+                return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) {
107
+                    if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) {
108
+                        $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]);
109 109
                         if ($routeDocumentationChanged === false || $this->option('force')) {
110 110
                             if ($routeDocumentationChanged) {
111
-                                $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']);
111
+                                $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
112 112
                             }
113 113
                         } else {
114
-                            $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']);
114
+                            $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']);
115 115
                             $route['modified_output'] = $existingRouteDoc[0];
116 116
                         }
117 117
                     }
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
         }
123 123
 
124 124
         $prependFileContents = file_exists($prependFile)
125
-            ? file_get_contents($prependFile)."\n" : '';
125
+            ? file_get_contents($prependFile) . "\n" : '';
126 126
         $appendFileContents = file_exists($appendFile)
127
-            ? "\n".file_get_contents($appendFile) : '';
127
+            ? "\n" . file_get_contents($appendFile) : '';
128 128
 
129 129
         $documentarian = new Documentarian();
130 130
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             ->with('showPostmanCollectionButton', config('apidoc.postman'))
139 139
             ->with('parsedRoutes', $parsedRouteOutput);
140 140
 
141
-        if (! is_dir($outputPath)) {
141
+        if (!is_dir($outputPath)) {
142 142
             $documentarian->create($outputPath);
143 143
         }
144 144
 
@@ -158,24 +158,24 @@  discard block
 block discarded – undo
158 158
 
159 159
         file_put_contents($compareFile, $compareMarkdown);
160 160
 
161
-        $this->info('Wrote index.md to: '.$outputPath);
161
+        $this->info('Wrote index.md to: ' . $outputPath);
162 162
 
163 163
         $this->info('Generating API HTML code');
164 164
 
165 165
         $documentarian->generate($outputPath);
166 166
 
167
-        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
167
+        $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html');
168 168
 
169 169
         if (config('apidoc.postman')) {
170 170
             $this->info('Generating Postman collection');
171 171
 
172
-            file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes));
172
+            file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes));
173 173
         }
174 174
 
175 175
         if ($logo = config('apidoc.logo')) {
176 176
             copy(
177 177
                 $logo,
178
-                $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png'
178
+                $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png'
179 179
             );
180 180
         }
181 181
     }
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
             /** @var Route $route */
195 195
             if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
196 196
                 $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']);
197
-                $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
197
+                $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
198 198
             } else {
199
-                $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
199
+                $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route));
200 200
             }
201 201
         }
202 202
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     private function isValidRoute(Route $route)
212 212
     {
213
-        return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']);
213
+        return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']);
214 214
     }
215 215
 
216 216
     /**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         list($class, $method) = explode('@', $route);
226 226
         $reflection = new ReflectionClass($class);
227 227
 
228
-        if (! $reflection->hasMethod($method)) {
228
+        if (!$reflection->hasMethod($method)) {
229 229
             return false;
230 230
         }
231 231
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
             $phpdoc = new DocBlock($comment);
236 236
 
237 237
             return collect($phpdoc->getTags())
238
-                ->filter(function ($tag) use ($route) {
238
+                ->filter(function($tag) use ($route) {
239 239
                     return $tag->getName() === 'hideFromAPIDocumentation';
240 240
                 })
241 241
                 ->isEmpty();
Please login to merge, or discard this patch.
src/Tools/ResponseStrategies/ResponseFileStrategy.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         // avoid "holes" in the keys of the filtered array, by using array_values on the filtered array
36 36
         $responseFileTags = array_values(
37
-            array_filter($tags, function ($tag) {
37
+            array_filter($tags, function($tag) {
38 38
                 return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile';
39 39
             })
40 40
         );
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
             return;
44 44
         }
45 45
 
46
-        return array_map(function (Tag $responseFileTag) {
46
+        return array_map(function(Tag $responseFileTag) {
47 47
             preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result);
48 48
             $status = $result[1] ?: 200;
49 49
             $content = $result[2] ? file_get_contents(storage_path(trim($result[2])), true) : '{}';
50
-            $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
50
+            $json = !empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
51 51
             $merged = array_merge(json_decode($content, true), json_decode($json, true));
52 52
 
53 53
             return new JsonResponse($merged, (int) $status);
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
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
             $fractal = new Manager();
49 49
  
50
-            if (! is_null(config('apidoc.fractal.serializer'))) {
50
+            if (!is_null(config('apidoc.fractal.serializer'))) {
51 51
                 $fractal->setSerializer(app(config('apidoc.fractal.serializer')));
52 52
             }
53 53
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     private function getClassToBeTransformed(array $tags, ReflectionMethod $transformerMethod)
81 81
     {
82
-        $modelTag = array_first(array_filter($tags, function ($tag) {
82
+        $modelTag = array_first(array_filter($tags, function($tag) {
83 83
             return ($tag instanceof Tag) && strtolower($tag->getName()) == 'transformermodel';
84 84
         }));
85 85
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             $type = $modelTag->getContent();
89 89
         } else {
90 90
             $parameter = array_first($transformerMethod->getParameters());
91
-            if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) {
91
+            if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) {
92 92
                 // ladies and gentlemen, we have a type!
93 93
                 $type = (string) $parameter->getType();
94 94
             }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     private function getTransformerTag(array $tags)
134 134
     {
135 135
         $transFormerTags = array_values(
136
-            array_filter($tags, function ($tag) {
136
+            array_filter($tags, function($tag) {
137 137
                 return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']);
138 138
             })
139 139
         );
Please login to merge, or discard this patch.