Completed
Pull Request — master (#570)
by Marcel
02:28 queued 01:11
created
src/Tools/Traits/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/Strategies/QueryParameters/GetFromQueryParamTag.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
     private function getQueryParametersFromDocBlock($tags)
57 57
     {
58 58
         $parameters = collect($tags)
59
-            ->filter(function ($tag) {
59
+            ->filter(function($tag) {
60 60
                 return $tag instanceof Tag && $tag->getName() === 'queryParam';
61 61
             })
62
-            ->mapWithKeys(function ($tag) {
62
+            ->mapWithKeys(function($tag) {
63 63
                 preg_match('/(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content);
64 64
                 $content = preg_replace('/\s?No-example.?/', '', $content);
65 65
                 if (empty($content)) {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
                 }
79 79
 
80 80
                 list($description, $value) = $this->parseParamDescription($description, 'string');
81
-                if (is_null($value) && ! $this->shouldExcludeExample($tag)) {
81
+                if (is_null($value) && !$this->shouldExcludeExample($tag)) {
82 82
                     $value = Str::contains($description, ['number', 'count', 'page'])
83 83
                         ? $this->generateDummyValue('integer')
84 84
                         : $this->generateDummyValue('string');
Please login to merge, or discard this patch.
src/Strategies/Responses/UseTransformerTags.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.
src/Strategies/Responses/ResponseCalls.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function __invoke(Route $route, \ReflectionClass $controller, \ReflectionMethod $method, array $routeRules, array $context = [])
32 32
     {
33 33
         $rulesToApply = $routeRules['response_calls'] ?? [];
34
-        if (! $this->shouldMakeApiCall($route, $rulesToApply, $context)) {
34
+        if (!$this->shouldMakeApiCall($route, $rulesToApply, $context)) {
35 35
             return null;
36 36
         }
37 37
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         try {
46 46
             $response = [200 => $this->makeApiCall($request)->getContent()];
47 47
         } catch (\Exception $e) {
48
-            echo 'Exception thrown during response call for ['.implode(',', $route->methods)."] {$route->uri}.\n";
48
+            echo 'Exception thrown during response call for [' . implode(',', $route->methods) . "] {$route->uri}.\n";
49 49
             if (Flags::$shouldBeVerbose) {
50 50
                 Utils::dumpException($e);
51 51
             } else {
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
         // set URL and query parameters
179 179
         $uri = $request->getRequestUri();
180 180
         $query = $request->getQueryString();
181
-        if (! empty($query)) {
181
+        if (!empty($query)) {
182 182
             $uri .= "?$query";
183 183
         }
184 184
         $response = call_user_func_array([$dispatcher, strtolower($request->method())], [$uri]);
185 185
 
186 186
         // the response from the Dingo dispatcher is the 'raw' response from the controller,
187 187
         // so we have to ensure it's JSON first
188
-        if (! $response instanceof Response) {
188
+        if (!$response instanceof Response) {
189 189
             $response = response()->json($response);
190 190
         }
191 191
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
             return false;
306 306
         }
307 307
 
308
-        if (! empty($context['responses'])) {
308
+        if (!empty($context['responses'])) {
309 309
             // Don't attempt a response call if there are already responses
310 310
             return false;
311 311
         }
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
         $prefix = 'HTTP_';
340 340
         foreach ($headers as $name => $value) {
341 341
             $name = strtr(strtoupper($name), '-', '_');
342
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
343
-                $name = $prefix.$name;
342
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
343
+                $name = $prefix . $name;
344 344
             }
345 345
             $server[$name] = $value;
346 346
         }
Please login to merge, or discard this patch.
src/Strategies/BodyParameters/GetFromBodyParamTag.php 1 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 getBodyParametersFromDocBlock($tags)
56 56
     {
57 57
         $parameters = collect($tags)
58
-            ->filter(function ($tag) {
58
+            ->filter(function($tag) {
59 59
                 return $tag instanceof Tag && $tag->getName() === 'bodyParam';
60 60
             })
61
-            ->mapWithKeys(function ($tag) {
61
+            ->mapWithKeys(function($tag) {
62 62
                 preg_match('/(.+?)\s+(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content);
63 63
                 $content = preg_replace('/\s?No-example.?/', '', $content);
64 64
                 if (empty($content)) {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
                 $type = $this->normalizeParameterType($type);
80 80
                 list($description, $example) = $this->parseParamDescription($description, $type);
81
-                $value = is_null($example) && ! $this->shouldExcludeExample($tag)
81
+                $value = is_null($example) && !$this->shouldExcludeExample($tag)
82 82
                     ? $this->generateDummyValue($type)
83 83
                     : $example;
84 84
 
Please login to merge, or discard this patch.
src/Tools/Generator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $method = $controller->getMethod($methodName);
55 55
 
56 56
         $parsedRoute = [
57
-            'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))),
57
+            'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))),
58 58
             'methods' => $this->getMethods($route),
59 59
             'uri' => $this->getUri($route),
60 60
             'boundUri' => Utils::getFullUrl($route, $rulesToApply['bindings'] ?? ($rulesToApply['response_calls']['bindings'] ?? [])),
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
         $responses = $this->fetchResponses($controller, $method, $route, $rulesToApply, $parsedRoute);
73 73
         $parsedRoute['response'] = $responses;
74
-        $parsedRoute['showresponse'] = ! empty($responses);
74
+        $parsedRoute['showresponse'] = !empty($responses);
75 75
 
76 76
         $parsedRoute['headers'] = $rulesToApply['headers'] ?? [];
77 77
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     {
110 110
         $responses = $this->iterateThroughStrategies('responses', $context, [$route, $controller, $method, $rulesToApply]);
111 111
         if (count($responses)) {
112
-            return collect($responses)->map(function (string $response, int $status) {
112
+            return collect($responses)->map(function(string $response, int $status) {
113 113
                 return [
114 114
                     'status' => $status ?: 200,
115 115
                     'content' => $response,
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
             $strategy = new $strategyClass($this->config);
129 129
             $arguments[] = $context;
130 130
             $results = $strategy(...$arguments);
131
-            if (! is_null($results)) {
131
+            if (!is_null($results)) {
132 132
                 foreach ($results as $index => $item) {
133 133
                     // Using a for loop rather than array_merge or +=
134 134
                     // so it does not renumber numeric keys
135 135
                     // and also allows values to be overwritten
136 136
 
137 137
                     // Don't allow overwriting if an empty value is trying to replace a set one
138
-                    if (! in_array($context[$key], [null, ''], true) && in_array($item, [null, ''], true)) {
138
+                    if (!in_array($context[$key], [null, ''], true) && in_array($item, [null, ''], true)) {
139 139
                         continue;
140 140
                     } else {
141 141
                         $context[$key][$index] = $item;
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
         $values = [];
161 161
 
162 162
         // Remove params which have no examples.
163
-        $params = array_filter($params, function ($details) {
164
-            return ! is_null($details['value']);
163
+        $params = array_filter($params, function($details) {
164
+            return !is_null($details['value']);
165 165
         });
166 166
 
167 167
         foreach ($params as $paramName => $details) {
Please login to merge, or discard this patch.