Completed
Pull Request — master (#589)
by
unknown
14:06
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/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/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
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             $response = $this->makeApiCall($request);
47 47
             $response = [$response->getStatusCode() => $response->getContent()];
48 48
         } catch (\Exception $e) {
49
-            echo 'Exception thrown during response call for ['.implode(',', $route->methods)."] {$route->uri}.\n";
49
+            echo 'Exception thrown during response call for [' . implode(',', $route->methods) . "] {$route->uri}.\n";
50 50
             if (Flags::$shouldBeVerbose) {
51 51
                 Utils::dumpException($e);
52 52
             } else {
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
         // set URL and query parameters
180 180
         $uri = $request->getRequestUri();
181 181
         $query = $request->getQueryString();
182
-        if (! empty($query)) {
182
+        if (!empty($query)) {
183 183
             $uri .= "?$query";
184 184
         }
185 185
         $response = call_user_func_array([$dispatcher, strtolower($request->method())], [$uri]);
186 186
 
187 187
         // the response from the Dingo dispatcher is the 'raw' response from the controller,
188 188
         // so we have to ensure it's JSON first
189
-        if (! $response instanceof Response) {
189
+        if (!$response instanceof Response) {
190 190
             $response = response()->json($response);
191 191
         }
192 192
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
             return false;
307 307
         }
308 308
 
309
-        if (! empty($context['responses'])) {
309
+        if (!empty($context['responses'])) {
310 310
             // Don't attempt a response call if there are already responses
311 311
             return false;
312 312
         }
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
         $prefix = 'HTTP_';
341 341
         foreach ($headers as $name => $value) {
342 342
             $name = strtr(strtoupper($name), '-', '_');
343
-            if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
344
-                $name = $prefix.$name;
343
+            if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') {
344
+                $name = $prefix . $name;
345 345
             }
346 346
             $server[$name] = $value;
347 347
         }
Please login to merge, or discard this patch.
src/Strategies/Metadata/GetFromMiddleware.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
         $headers = [];
64 64
         if ($authMiddleware) {
65 65
             $guard = preg_replace('/^auth:/', '', $authMiddleware);
66
-            $driver = config('auth.guards.'.$guard.'.driver');
66
+            $driver = config('auth.guards.' . $guard . '.driver');
67 67
             if ($driver === 'token') {
68 68
                 $headers['Authorization'] = 'Token {token}';
69 69
             } else if ($driver === 'passport' || $driver === 'jwt') {
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
         $baseHeaders = $rulesToApply['headers'] ?? [];
77 77
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     {
114 114
         $responses = $this->iterateThroughStrategies('responses', $context, [$route, $controller, $method, $rulesToApply]);
115 115
         if (count($responses)) {
116
-            return collect($responses)->map(function (string $response, int $status) {
116
+            return collect($responses)->map(function(string $response, int $status) {
117 117
                 return [
118 118
                     'status' => $status ?: 200,
119 119
                     'content' => $response,
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
             $strategy = new $strategyClass($stage, $this->config);
153 153
             $arguments[] = $context;
154 154
             $results = $strategy(...$arguments);
155
-            if (! is_null($results)) {
155
+            if (!is_null($results)) {
156 156
                 foreach ($results as $index => $item) {
157 157
                     // Using a for loop rather than array_merge or +=
158 158
                     // so it does not renumber numeric keys
159 159
                     // and also allows values to be overwritten
160 160
 
161 161
                     // Don't allow overwriting if an empty value is trying to replace a set one
162
-                    if (! in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) {
162
+                    if (!in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) {
163 163
                         continue;
164 164
                     } else {
165 165
                         $context[$stage][$index] = $item;
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
         $values = [];
185 185
 
186 186
         // Remove params which have no examples.
187
-        $params = array_filter($params, function ($details) {
188
-            return ! is_null($details['value']);
187
+        $params = array_filter($params, function($details) {
188
+            return !is_null($details['value']);
189 189
         });
190 190
 
191 191
         foreach ($params as $paramName => $details) {
Please login to merge, or discard this patch.