@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | private function getUrlParametersFromDocBlock($tags) |
56 | 56 | { |
57 | 57 | $parameters = collect($tags) |
58 | - ->filter(function ($tag) { |
|
58 | + ->filter(function($tag) { |
|
59 | 59 | return $tag instanceof Tag && $tag->getName() === 'urlParam'; |
60 | 60 | }) |
61 | - ->mapWithKeys(function (Tag $tag) { |
|
61 | + ->mapWithKeys(function(Tag $tag) { |
|
62 | 62 | // Format: |
63 | 63 | // @urlParam <name> <"required" (optional)> <description> |
64 | 64 | // Examples: |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | list($description, $value) = $this->parseParamDescription($description, 'string'); |
85 | - if (is_null($value) && ! $this->shouldExcludeExample($tag->getContent())) { |
|
85 | + if (is_null($value) && !$this->shouldExcludeExample($tag->getContent())) { |
|
86 | 86 | $value = Str::contains($description, ['number', 'count', 'page']) |
87 | 87 | ? $this->generateDummyValue('integer') |
88 | 88 | : $this->generateDummyValue('string'); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | private function getQueryParametersFromDocBlock($tags) |
56 | 56 | { |
57 | 57 | $parameters = collect($tags) |
58 | - ->filter(function ($tag) { |
|
58 | + ->filter(function($tag) { |
|
59 | 59 | return $tag instanceof Tag && $tag->getName() === 'queryParam'; |
60 | 60 | }) |
61 | - ->mapWithKeys(function (Tag $tag) { |
|
61 | + ->mapWithKeys(function(Tag $tag) { |
|
62 | 62 | // Format: |
63 | 63 | // @queryParam <name> <"required" (optional)> <description> |
64 | 64 | // Examples: |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | list($description, $value) = $this->parseParamDescription($description, 'string'); |
85 | - if (is_null($value) && ! $this->shouldExcludeExample($tag->getContent())) { |
|
85 | + if (is_null($value) && !$this->shouldExcludeExample($tag->getContent())) { |
|
86 | 86 | $value = Str::contains($description, ['number', 'count', 'page']) |
87 | 87 | ? $this->generateDummyValue('integer') |
88 | 88 | : $this->generateDummyValue('string'); |
@@ -37,7 +37,7 @@ discard block |
||
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 |
||
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())); |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | private function getBodyParametersFromDocBlock($tags) |
55 | 55 | { |
56 | 56 | $parameters = collect($tags) |
57 | - ->filter(function ($tag) { |
|
57 | + ->filter(function($tag) { |
|
58 | 58 | return $tag instanceof Tag && $tag->getName() === 'bodyParam'; |
59 | 59 | }) |
60 | - ->mapWithKeys(function (Tag $tag) { |
|
60 | + ->mapWithKeys(function(Tag $tag) { |
|
61 | 61 | // Format: |
62 | 62 | // @bodyParam <name> <type> <"required" (optional)> <description> |
63 | 63 | // Examples: |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | $type = $this->normalizeParameterType($type); |
84 | 84 | list($description, $example) = $this->parseParamDescription($description, $type); |
85 | - $value = is_null($example) && ! $this->shouldExcludeExample($tag->getContent()) |
|
85 | + $value = is_null($example) && !$this->shouldExcludeExample($tag->getContent()) |
|
86 | 86 | ? $this->generateDummyValue($type) |
87 | 87 | : $example; |
88 | 88 |
@@ -14,25 +14,25 @@ |
||
14 | 14 | $faker->seed($this->config->get('faker_seed')); |
15 | 15 | } |
16 | 16 | $fakeFactories = [ |
17 | - 'integer' => function () use ($faker) { |
|
17 | + 'integer' => function() use ($faker) { |
|
18 | 18 | return $faker->numberBetween(1, 20); |
19 | 19 | }, |
20 | - 'number' => function () use ($faker) { |
|
20 | + 'number' => function() use ($faker) { |
|
21 | 21 | return $faker->randomFloat(); |
22 | 22 | }, |
23 | - 'float' => function () use ($faker) { |
|
23 | + 'float' => function() use ($faker) { |
|
24 | 24 | return $faker->randomFloat(); |
25 | 25 | }, |
26 | - 'boolean' => function () use ($faker) { |
|
26 | + 'boolean' => function() use ($faker) { |
|
27 | 27 | return $faker->boolean(); |
28 | 28 | }, |
29 | - 'string' => function () use ($faker) { |
|
29 | + 'string' => function() use ($faker) { |
|
30 | 30 | return $faker->word; |
31 | 31 | }, |
32 | - 'array' => function () { |
|
32 | + 'array' => function() { |
|
33 | 33 | return []; |
34 | 34 | }, |
35 | - 'object' => function () { |
|
35 | + 'object' => function() { |
|
36 | 36 | return new stdClass(); |
37 | 37 | }, |
38 | 38 | ]; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $groupedRoutes = collect($parsedRoutes) |
72 | 72 | ->groupBy('metadata.groupName') |
73 | - ->sortBy(static function ($group) { |
|
73 | + ->sortBy(static function($group) { |
|
74 | 74 | /* @var $group Collection */ |
75 | 75 | return $group->first()['metadata']['groupName']; |
76 | 76 | }, SORT_NATURAL); |
@@ -106,17 +106,17 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | $routeControllerAndMethod = Utils::getRouteClassAndMethodNames($route->getAction()); |
109 | - if (! $this->isValidRoute($routeControllerAndMethod)) { |
|
109 | + if (!$this->isValidRoute($routeControllerAndMethod)) { |
|
110 | 110 | $this->warn(sprintf($messageFormat, 'Skipping invalid', $routeMethods, $routePath)); |
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | - if (! $this->doesControllerMethodExist($routeControllerAndMethod)) { |
|
114 | + if (!$this->doesControllerMethodExist($routeControllerAndMethod)) { |
|
115 | 115 | $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath) . ': Controller method does not exist.'); |
116 | 116 | continue; |
117 | 117 | } |
118 | 118 | |
119 | - if (! $this->isRouteVisibleForDocumentation($routeControllerAndMethod)) { |
|
119 | + if (!$this->isRouteVisibleForDocumentation($routeControllerAndMethod)) { |
|
120 | 120 | $this->warn(sprintf($messageFormat, 'Skipping', $routeMethods, $routePath) . ': @hideFromAPIDocumentation was specified.'); |
121 | 121 | continue; |
122 | 122 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $routeControllerAndMethod = implode('@', $routeControllerAndMethod); |
144 | 144 | } |
145 | 145 | |
146 | - return ! is_callable($routeControllerAndMethod) && ! is_null($routeControllerAndMethod); |
|
146 | + return !is_callable($routeControllerAndMethod) && !is_null($routeControllerAndMethod); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | [$class, $method] = $routeControllerAndMethod; |
169 | 169 | $reflection = new ReflectionClass($class); |
170 | 170 | |
171 | - if (! $reflection->hasMethod($method)) { |
|
171 | + if (!$reflection->hasMethod($method)) { |
|
172 | 172 | return false; |
173 | 173 | } |
174 | 174 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $tags = $tags->concat($phpdoc->getTags()); |
200 | 200 | } |
201 | 201 | |
202 | - return $tags->filter(function ($tag) { |
|
202 | + return $tags->filter(function($tag) { |
|
203 | 203 | return $tag->getName() === 'hideFromAPIDocumentation'; |
204 | 204 | })->isEmpty(); |
205 | 205 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | public function handle() |
16 | 16 | { |
17 | 17 | $sourceOutputPath = 'resources/docs/source'; |
18 | - if (! is_dir($sourceOutputPath)) { |
|
18 | + if (!is_dir($sourceOutputPath)) { |
|
19 | 19 | $this->error('There is no existing documentation available at ' . $sourceOutputPath . '.'); |
20 | 20 | |
21 | 21 | return false; |
@@ -18,7 +18,7 @@ |
||
18 | 18 | Route::prefix($path) |
19 | 19 | ->namespace('\Mpociot\ApiDoc\Http') |
20 | 20 | ->middleware(static::middleware()) |
21 | - ->group(function () { |
|
21 | + ->group(function() { |
|
22 | 22 | Route::get('/', 'Controller@html')->name('apidoc'); |
23 | 23 | Route::get('.json', 'Controller@json')->name('apidoc.json'); |
24 | 24 | }); |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | $generatedDocumentation = file_get_contents($targetFile); |
115 | 115 | $compareDocumentation = file_get_contents($compareFile); |
116 | 116 | |
117 | - $parsedRouteOutput->transform(function (Collection $routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
118 | - return $routeGroup->transform(function (array $route) use ($generatedDocumentation, $compareDocumentation) { |
|
117 | + $parsedRouteOutput->transform(function(Collection $routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
118 | + return $routeGroup->transform(function(array $route) use ($generatedDocumentation, $compareDocumentation) { |
|
119 | 119 | if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
120 | 120 | $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
121 | 121 | if ($routeDocumentationChanged === false || $this->forceIt) { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $this->output->info('Writing index.md and source files to: ' . $this->sourceOutputPath); |
150 | 150 | |
151 | - if (! is_dir($this->sourceOutputPath)) { |
|
151 | + if (!is_dir($this->sourceOutputPath)) { |
|
152 | 152 | $documentarian = new Documentarian(); |
153 | 153 | $documentarian->create($this->sourceOutputPath); |
154 | 154 | } |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | |
175 | 175 | public function generateMarkdownOutputForEachRoute(Collection $parsedRoutes, array $settings): Collection |
176 | 176 | { |
177 | - $parsedRouteOutput = $parsedRoutes->map(function (Collection $routeGroup) use ($settings) { |
|
178 | - return $routeGroup->map(function (array $route) use ($settings) { |
|
179 | - if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) { |
|
177 | + $parsedRouteOutput = $parsedRoutes->map(function(Collection $routeGroup) use ($settings) { |
|
178 | + return $routeGroup->map(function(array $route) use ($settings) { |
|
179 | + if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) { |
|
180 | 180 | // Set content type if the user forgot to set it |
181 | 181 | $route['headers']['Content-Type'] = 'application/json'; |
182 | 182 | } |
183 | 183 | |
184 | - $hasRequestOptions = ! empty($route['headers']) || ! empty($route['cleanQueryParameters']) || ! empty($route['cleanBodyParameters']); |
|
184 | + $hasRequestOptions = !empty($route['headers']) || !empty($route['cleanQueryParameters']) || !empty($route['cleanBodyParameters']); |
|
185 | 185 | $route['output'] = (string) view('apidoc::partials.route') |
186 | 186 | ->with('hasRequestOptions', $hasRequestOptions) |
187 | 187 | ->with('route', $route) |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | protected function copyAssetsFromSourceFolderToPublicFolder(): void |
254 | 254 | { |
255 | 255 | $publicPath = $this->config->get('output_folder') ?? 'public/docs'; |
256 | - if (! is_dir($publicPath)) { |
|
256 | + if (!is_dir($publicPath)) { |
|
257 | 257 | mkdir($publicPath, 0777, true); |
258 | 258 | mkdir("{$publicPath}/css"); |
259 | 259 | mkdir("{$publicPath}/js"); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | rename("{$this->sourceOutputPath}/index.html", "{$this->outputPath}/index.html"); |
275 | 275 | } else { |
276 | 276 | // Move output to resources/views |
277 | - if (! is_dir($this->outputPath)) { |
|
277 | + if (!is_dir($this->outputPath)) { |
|
278 | 278 | mkdir($this->outputPath); |
279 | 279 | } |
280 | 280 | rename("{$this->sourceOutputPath}/index.html", "$this->outputPath/index.blade.php"); |