@@ -15,17 +15,17 @@ |
||
| 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 | ], 'apidoc-views'); |
| 23 | 23 | |
| 24 | 24 | $this->publishes([ |
| 25 | - __DIR__.'/../config/apidoc.php' => app()->basePath().'/config/apidoc.php', |
|
| 25 | + __DIR__ . '/../config/apidoc.php' => app()->basePath() . '/config/apidoc.php', |
|
| 26 | 26 | ], 'apidoc-config'); |
| 27 | 27 | |
| 28 | - $this->mergeConfigFrom(__DIR__.'/../config/apidoc.php', 'apidoc'); |
|
| 28 | + $this->mergeConfigFrom(__DIR__ . '/../config/apidoc.php', 'apidoc'); |
|
| 29 | 29 | |
| 30 | 30 | if ($this->app->runningInConsole()) { |
| 31 | 31 | $this->commands([ |
@@ -42,15 +42,15 @@ |
||
| 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 | } |
@@ -77,7 +77,7 @@ |
||
| 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 | { |
@@ -13,25 +13,25 @@ |
||
| 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 | ]; |
@@ -51,6 +51,9 @@ |
||
| 51 | 51 | return $this->getBodyParametersFromDocBlock($methodDocBlock->getTags()); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | + /** |
|
| 55 | + * @param Tag[] $tags |
|
| 56 | + */ |
|
| 54 | 57 | private function getBodyParametersFromDocBlock($tags) |
| 55 | 58 | { |
| 56 | 59 | $parameters = collect($tags) |
@@ -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 | |
@@ -52,6 +52,9 @@ |
||
| 52 | 52 | return $this->getQueryParametersFromDocBlock($methodDocBlock->getTags()); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | + /** |
|
| 56 | + * @param Tag[] $tags |
|
| 57 | + */ |
|
| 55 | 58 | private function getQueryParametersFromDocBlock($tags) |
| 56 | 59 | { |
| 57 | 60 | $parameters = collect($tags) |
@@ -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'); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * Get a response from the transformer tags. |
| 50 | 50 | * |
| 51 | - * @param array $tags |
|
| 51 | + * @param Tag[] $tags |
|
| 52 | 52 | * |
| 53 | 53 | * @return array|null |
| 54 | 54 | */ |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * @param string $type |
| 143 | 143 | * |
| 144 | - * @return Model|object |
|
| 144 | + * @return string |
|
| 145 | 145 | */ |
| 146 | 146 | protected function instantiateApiResourceModel(string $type) |
| 147 | 147 | { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | ], |
| 93 | 93 | ]; |
| 94 | 94 | } catch (\Exception $e) { |
| 95 | - echo 'Exception thrown when fetching Eloquent API resource response for ['.implode(',', $route->methods)."] {$route->uri}.\n"; |
|
| 95 | + echo 'Exception thrown when fetching Eloquent API resource response for [' . implode(',', $route->methods) . "] {$route->uri}.\n"; |
|
| 96 | 96 | if (Flags::$shouldBeVerbose) { |
| 97 | 97 | Utils::dumpException($e); |
| 98 | 98 | } else { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | private function getClassToBeTransformed(array $tags): string |
| 127 | 127 | { |
| 128 | - $modelTag = Arr::first(array_filter($tags, function ($tag) { |
|
| 128 | + $modelTag = Arr::first(array_filter($tags, function($tag) { |
|
| 129 | 129 | return ($tag instanceof Tag) && strtolower($tag->getName()) == 'apiresourcemodel'; |
| 130 | 130 | })); |
| 131 | 131 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | private function getApiResourceTag(array $tags) |
| 187 | 187 | { |
| 188 | 188 | $apiResourceTags = array_values( |
| 189 | - array_filter($tags, function ($tag) { |
|
| 189 | + array_filter($tags, function($tag) { |
|
| 190 | 190 | return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['apiresource', 'apiresourcecollection']); |
| 191 | 191 | }) |
| 192 | 192 | ); |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | use Illuminate\Http\Response; |
| 11 | 11 | use Illuminate\Routing\Route; |
| 12 | 12 | use Illuminate\Support\Arr; |
| 13 | -use League\Fractal\Resource\Collection; |
|
| 14 | 13 | use Mpociot\ApiDoc\Extracting\RouteDocBlocker; |
| 15 | 14 | use Mpociot\ApiDoc\Extracting\Strategies\Strategy; |
| 16 | 15 | use Mpociot\ApiDoc\Tools\Flags; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Get a response from the transformer tags. |
| 48 | 48 | * |
| 49 | - * @param array $tags |
|
| 49 | + * @param Tag[] $tags |
|
| 50 | 50 | * |
| 51 | 51 | * @return array|null |
| 52 | 52 | */ |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * @param string $type |
| 143 | 143 | * |
| 144 | - * @return Model|object |
|
| 144 | + * @return string |
|
| 145 | 145 | */ |
| 146 | 146 | protected function instantiateTransformerModel(string $type) |
| 147 | 147 | { |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $fractal = new Manager(); |
| 65 | 65 | |
| 66 | - if (! is_null(config('apidoc.fractal.serializer'))) { |
|
| 66 | + if (!is_null(config('apidoc.fractal.serializer'))) { |
|
| 67 | 67 | $fractal->setSerializer(app(config('apidoc.fractal.serializer'))); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | ], |
| 83 | 83 | ]; |
| 84 | 84 | } catch (\Exception $e) { |
| 85 | - echo 'Exception thrown when fetching transformer response for ['.implode(',', $route->methods)."] {$route->uri}.\n"; |
|
| 85 | + echo 'Exception thrown when fetching transformer response for [' . implode(',', $route->methods) . "] {$route->uri}.\n"; |
|
| 86 | 86 | if (Flags::$shouldBeVerbose) { |
| 87 | 87 | Utils::dumpException($e); |
| 88 | 88 | } else { |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | private function getClassToBeTransformed(array $tags, ReflectionMethod $transformerMethod): string |
| 118 | 118 | { |
| 119 | - $modelTag = Arr::first(array_filter($tags, function ($tag) { |
|
| 119 | + $modelTag = Arr::first(array_filter($tags, function($tag) { |
|
| 120 | 120 | return ($tag instanceof Tag) && strtolower($tag->getName()) == 'transformermodel'; |
| 121 | 121 | })); |
| 122 | 122 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $type = $modelTag->getContent(); |
| 126 | 126 | } else { |
| 127 | 127 | $parameter = Arr::first($transformerMethod->getParameters()); |
| 128 | - if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) { |
|
| 128 | + if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) { |
|
| 129 | 129 | // Ladies and gentlemen, we have a type! |
| 130 | 130 | $type = (string) $parameter->getType(); |
| 131 | 131 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | private function getTransformerTag(array $tags) |
| 187 | 187 | { |
| 188 | 188 | $transformerTags = array_values( |
| 189 | - array_filter($tags, function ($tag) { |
|
| 189 | + array_filter($tags, function($tag) { |
|
| 190 | 190 | return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']); |
| 191 | 191 | }) |
| 192 | 192 | ); |
@@ -52,6 +52,9 @@ |
||
| 52 | 52 | return $this->getUrlParametersFromDocBlock($methodDocBlock->getTags()); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | + /** |
|
| 56 | + * @param Tag[] $tags |
|
| 57 | + */ |
|
| 55 | 58 | private function getUrlParametersFromDocBlock($tags) |
| 56 | 59 | { |
| 57 | 60 | $parameters = collect($tags) |
@@ -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'); |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | private function getAllRoutes(bool $usingDingoRouter) |
| 66 | 66 | { |
| 67 | - if (! $usingDingoRouter) { |
|
| 67 | + if (!$usingDingoRouter) { |
|
| 68 | 68 | return RouteFacade::getRoutes(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes(); |
| 72 | 72 | |
| 73 | 73 | return collect($allRouteCollections) |
| 74 | - ->flatMap(function (RouteCollection $collection) { |
|
| 74 | + ->flatMap(function(RouteCollection $collection) { |
|
| 75 | 75 | return $collection->getRoutes(); |
| 76 | 76 | })->toArray(); |
| 77 | 77 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter) |
| 80 | 80 | { |
| 81 | 81 | $matchesVersion = $usingDingoRouter |
| 82 | - ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
| 82 | + ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
| 83 | 83 | : true; |
| 84 | 84 | |
| 85 | 85 | return Str::is($mustIncludes, $route->getName()) |