Completed
Pull Request — master (#608)
by
unknown
12:02
created
src/ApiDocGeneratorServiceProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,17 +15,17 @@
 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
         ], '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([
Please login to merge, or discard this patch.
src/Commands/RebuildDocumentation.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/Extracting/ParamHelpers.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@
 block discarded – undo
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
         ];
Please login to merge, or discard this patch.
src/Extracting/Strategies/BodyParameters/GetFromBodyParamTag.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -51,6 +51,9 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Extracting/Strategies/QueryParameters/GetFromQueryParamTag.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -52,6 +52,9 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
src/Extracting/Strategies/Responses/UseApiResourceTags.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
 use Mpociot\Reflection\DocBlock;
15 15
 use Mpociot\Reflection\DocBlock\Tag;
16 16
 use Illuminate\Database\Eloquent\Model;
17
-use League\Fractal\Resource\Collection;
18 17
 use Mpociot\ApiDoc\Extracting\RouteDocBlocker;
19 18
 use Illuminate\Http\Resources\Json\JsonResource;
20 19
 use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         );
Please login to merge, or discard this patch.
src/Extracting/Strategies/Responses/UseTransformerTags.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         );
Please login to merge, or discard this patch.
src/Extracting/Strategies/UrlParameters/GetFromUrlParamTag.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -52,6 +52,9 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
src/Writing/PostmanCollectionWriter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,32 +40,32 @@  discard block
 block discarded – undo
40 40
         $collection = [
41 41
             'variables' => [],
42 42
             'info' => [
43
-                'name' => config('apidoc.postman.name') ?: config('app.name').' API',
43
+                'name' => config('apidoc.postman.name') ?: config('app.name') . ' API',
44 44
                 '_postman_id' => Uuid::uuid4()->toString(),
45 45
                 'description' => config('apidoc.postman.description') ?: '',
46 46
                 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json',
47 47
             ],
48
-            'item' => $this->routeGroups->map(function ($routes, $groupName) {
48
+            'item' => $this->routeGroups->map(function($routes, $groupName) {
49 49
                 return [
50 50
                     'name' => $groupName,
51 51
                     'description' => '',
52
-                    'item' => $routes->map(function ($route) {
52
+                    'item' => $routes->map(function($route) {
53 53
                         $mode = $route['methods'][0] === 'PUT' ? 'urlencoded' : 'formdata';
54 54
 
55 55
                         return [
56 56
                             'name' => $route['metadata']['title'] != '' ? $route['metadata']['title'] : url($route['uri']),
57 57
                             'request' => [
58
-                                'url' => url($route['uri']).(collect($route['queryParameters'])->isEmpty()
58
+                                'url' => url($route['uri']) . (collect($route['queryParameters'])->isEmpty()
59 59
                                         ? ''
60
-                                        : ('?'.implode('&', collect($route['queryParameters'])->map(function ($parameter, $key) {
61
-                                            return urlencode($key).'='.urlencode($parameter['value'] ?? '');
60
+                                        : ('?' . implode('&', collect($route['queryParameters'])->map(function($parameter, $key) {
61
+                                            return urlencode($key) . '=' . urlencode($parameter['value'] ?? '');
62 62
                                         })->all()))),
63 63
                                 'method' => $route['methods'][0],
64 64
                                 'header' => collect($route['headers'])
65 65
                                     ->union([
66 66
                                         'Accept' => 'application/json',
67 67
                                     ])
68
-                                    ->map(function ($value, $header) {
68
+                                    ->map(function($value, $header) {
69 69
                                         return [
70 70
                                             'key' => $header,
71 71
                                             'value' => $value,
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                                     ->values()->all(),
75 75
                                 'body' => [
76 76
                                     'mode' => $mode,
77
-                                    $mode => collect($route['bodyParameters'])->map(function ($parameter, $key) {
77
+                                    $mode => collect($route['bodyParameters'])->map(function($parameter, $key) {
78 78
                                         return [
79 79
                                             'key' => $key,
80 80
                                             'value' => $parameter['value'] ?? '',
Please login to merge, or discard this patch.