@@ -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 | ]; |
@@ -56,10 +56,10 @@ discard block |
||
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 |
||
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'); |
@@ -49,7 +49,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | ); |
@@ -55,10 +55,10 @@ discard block |
||
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 |
||
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 |
@@ -54,7 +54,7 @@ discard block |
||
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 |
||
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 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $responses = $this->iterateThroughStrategies('responses', $context, [$route, $controller, $method, $rulesToApply]); |
109 | 109 | if (count($responses)) { |
110 | - return collect($responses)->map(function (string $response, int $status) { |
|
110 | + return collect($responses)->map(function(string $response, int $status) { |
|
111 | 111 | return [ |
112 | 112 | 'status' => $status ?: 200, |
113 | 113 | 'content' => $response, |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | $strategy = new $strategyClass($stage, $this->config); |
127 | 127 | $arguments[] = $context; |
128 | 128 | $results = $strategy(...$arguments); |
129 | - if (! is_null($results)) { |
|
129 | + if (!is_null($results)) { |
|
130 | 130 | foreach ($results as $index => $item) { |
131 | 131 | // Using a for loop rather than array_merge or += |
132 | 132 | // so it does not renumber numeric keys |
133 | 133 | // and also allows values to be overwritten |
134 | 134 | |
135 | 135 | // Don't allow overwriting if an empty value is trying to replace a set one |
136 | - if (! in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) { |
|
136 | + if (!in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) { |
|
137 | 137 | continue; |
138 | 138 | } else { |
139 | 139 | $context[$stage][$index] = $item; |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | $values = []; |
159 | 159 | |
160 | 160 | // Remove params which have no examples. |
161 | - $params = array_filter($params, function ($details) { |
|
162 | - return ! is_null($details['value']); |
|
161 | + $params = array_filter($params, function($details) { |
|
162 | + return !is_null($details['value']); |
|
163 | 163 | }); |
164 | 164 | |
165 | 165 | foreach ($params as $paramName => $details) { |
@@ -31,7 +31,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | use Mpociot\ApiDoc\Strategies\Strategy; |
11 | 11 | use Mpociot\ApiDoc\Tools\Traits\DocBlockParamHelpers; |
12 | 12 | |
13 | -class GetFromRequestClass extends Strategy{ |
|
13 | +class GetFromRequestClass extends Strategy { |
|
14 | 14 | |
15 | 15 | use DocBlockParamHelpers; |
16 | 16 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | ? $paramType->__toString() |
28 | 28 | : $paramType->getName(); |
29 | 29 | |
30 | - $parameters = array_merge($parameters , $this->getBodyParametersFromRequestClass($parameterClassName)); |
|
30 | + $parameters = array_merge($parameters, $this->getBodyParametersFromRequestClass($parameterClassName)); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | return $parameters; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $instance = $r->newInstanceWithoutConstructor(); |
42 | 42 | $parameters = $instance->rules(); |
43 | 43 | foreach ($parameters as $key => $value) { |
44 | - $arrayParams = array_merge($arrayParams,$this->explodeParams($key , $value)); |
|
44 | + $arrayParams = array_merge($arrayParams, $this->explodeParams($key, $value)); |
|
45 | 45 | } |
46 | 46 | } catch (Throwable $e) { |
47 | 47 | echo $e->getMessage(); |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | return $arrayParams; |
51 | 51 | } |
52 | 52 | |
53 | - public function explodeParams($field , $paramsValue){ |
|
53 | + public function explodeParams($field, $paramsValue) { |
|
54 | 54 | $params = explode('|', $paramsValue); |
55 | 55 | $required = false; |
56 | 56 | $description = []; |
57 | 57 | $type = ''; |
58 | - foreach($params as $param){ |
|
59 | - if($param === 'required'){ |
|
58 | + foreach ($params as $param) { |
|
59 | + if ($param === 'required') { |
|
60 | 60 | $required = true; |
61 | 61 | } |
62 | - elseif($param === 'string' || $param === 'integer' ||$param === 'array' ||$param === 'boolean' ||$param === 'float' ||$param === 'number'|| $param === 'object'){ |
|
62 | + elseif ($param === 'string' || $param === 'integer' || $param === 'array' || $param === 'boolean' || $param === 'float' || $param === 'number' || $param === 'object') { |
|
63 | 63 | $type = $param; |
64 | 64 | } |
65 | - else{ |
|
65 | + else { |
|
66 | 66 | $description [] = $param; |
67 | 67 | } |
68 | 68 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | return [ |
71 | 71 | $field=> [ |
72 | 72 | 'type'=> $type, |
73 | - 'description'=> implode(" ",$description), |
|
73 | + 'description'=> implode(" ", $description), |
|
74 | 74 | 'required'=>$required, |
75 | 75 | 'value'=>$this->generateDummyValue($type) |
76 | 76 | ] |
@@ -58,11 +58,9 @@ |
||
58 | 58 | foreach($params as $param){ |
59 | 59 | if($param === 'required'){ |
60 | 60 | $required = true; |
61 | - } |
|
62 | - elseif($param === 'string' || $param === 'integer' ||$param === 'array' ||$param === 'boolean' ||$param === 'float' ||$param === 'number'|| $param === 'object'){ |
|
61 | + } elseif($param === 'string' || $param === 'integer' ||$param === 'array' ||$param === 'boolean' ||$param === 'float' ||$param === 'number'|| $param === 'object'){ |
|
63 | 62 | $type = $param; |
64 | - } |
|
65 | - else{ |
|
63 | + } else{ |
|
66 | 64 | $description [] = $param; |
67 | 65 | } |
68 | 66 | } |