@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function getValue(): mixed |
| 12 | 12 | { |
| 13 | - if (!filter_has_var(INPUT_POST, $this->key) && isset($_POST[$this->key])) { |
|
| 13 | + if ( ! filter_has_var(INPUT_POST, $this->key) && isset($_POST[$this->key])) { |
|
| 14 | 14 | return $_POST[$this->key]; |
| 15 | 15 | } |
| 16 | 16 | $value = $this->isMulti() ? filter_input(INPUT_POST, $this->key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY) : filter_input(INPUT_POST, $this->key); |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function getValue(): mixed |
| 12 | 12 | { |
| 13 | - if (!filter_has_var(INPUT_COOKIE, $this->key) && isset($_COOKIE[$this->key])) { |
|
| 13 | + if ( ! filter_has_var(INPUT_COOKIE, $this->key) && isset($_COOKIE[$this->key])) { |
|
| 14 | 14 | return $_COOKIE[$this->key]; |
| 15 | 15 | } |
| 16 | 16 | $value = filter_input(INPUT_COOKIE, $this->key); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $outputValid = count($outputs) === 0; // back compatibility for handlers with no outputs defined |
| 108 | 108 | $outputValidatorErrors = []; |
| 109 | 109 | foreach ($outputs as $output) { |
| 110 | - if (!$output instanceof OutputInterface) { |
|
| 110 | + if ( ! $output instanceof OutputInterface) { |
|
| 111 | 111 | $outputValidatorErrors[] = ['Output does not implement OutputInterface']; |
| 112 | 112 | continue; |
| 113 | 113 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | $outputValidatorErrors[] = $validationResult->getErrors(); |
| 120 | 120 | } |
| 121 | - if (!$outputValid) { |
|
| 121 | + if ( ! $outputValid) { |
|
| 122 | 122 | $response = $this->errorHandler->handleSchema($outputValidatorErrors, $params); |
| 123 | 123 | $code = $response->getCode(); |
| 124 | 124 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | private function checkAuth(ApiAuthorizationInterface $authorization, array $params): ?IResponse |
| 158 | 158 | { |
| 159 | 159 | try { |
| 160 | - if (!$authorization->authorized()) { |
|
| 160 | + if ( ! $authorization->authorized()) { |
|
| 161 | 161 | $response = $this->errorHandler->handleAuthorization($authorization, $params); |
| 162 | 162 | $this->response->setCode($response->getCode()); |
| 163 | 163 | return $response; |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | private function checkRateLimit(RateLimitInterface $rateLimit): ?IResponse |
| 174 | 174 | { |
| 175 | 175 | $rateLimitResponse = $rateLimit->check(); |
| 176 | - if (!$rateLimitResponse) { |
|
| 176 | + if ( ! $rateLimitResponse) { |
|
| 177 | 177 | return null; |
| 178 | 178 | } |
| 179 | 179 | |
@@ -181,12 +181,12 @@ discard block |
||
| 181 | 181 | $remaining = $rateLimitResponse->getRemaining(); |
| 182 | 182 | $retryAfter = $rateLimitResponse->getRetryAfter(); |
| 183 | 183 | |
| 184 | - $this->response->addHeader('X-RateLimit-Limit', (string)$limit); |
|
| 185 | - $this->response->addHeader('X-RateLimit-Remaining', (string)$remaining); |
|
| 184 | + $this->response->addHeader('X-RateLimit-Limit', (string) $limit); |
|
| 185 | + $this->response->addHeader('X-RateLimit-Remaining', (string) $remaining); |
|
| 186 | 186 | |
| 187 | 187 | if ($remaining === 0) { |
| 188 | 188 | $this->response->setCode(Response::S429_TOO_MANY_REQUESTS); |
| 189 | - $this->response->addHeader('Retry-After', (string)$retryAfter); |
|
| 189 | + $this->response->addHeader('Retry-After', (string) $retryAfter); |
|
| 190 | 190 | return $rateLimitResponse->getErrorResponse() ?: new JsonResponse(['status' => 'error', 'message' => 'Too many requests. Retry after ' . $retryAfter . ' seconds.']); |
| 191 | 191 | } |
| 192 | 192 | return null; |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | private function getRequestDomain(): ?string |
| 250 | 250 | { |
| 251 | - if (!filter_input(INPUT_SERVER, 'HTTP_REFERER')) { |
|
| 251 | + if ( ! filter_input(INPUT_SERVER, 'HTTP_REFERER')) { |
|
| 252 | 252 | return null; |
| 253 | 253 | } |
| 254 | 254 | $refererParsedUrl = parse_url(filter_input(INPUT_SERVER, 'HTTP_REFERER')); |
| 255 | - if (!(isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) { |
|
| 255 | + if ( ! (isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) { |
|
| 256 | 256 | return null; |
| 257 | 257 | } |
| 258 | 258 | $url = $refererParsedUrl['scheme'] . '://' . $refererParsedUrl['host']; |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | /** |
| 128 | 128 | * @param mixed[] $values |
| 129 | 129 | * @return mixed[] |
| 130 | - */ |
|
| 130 | + */ |
|
| 131 | 131 | private function filterFormValues(array $values): array |
| 132 | 132 | { |
| 133 | 133 | foreach ($this->handler->params() as $param) { |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | return $this->code; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function getExpiration(): DateTimeInterface|false|null |
|
| 47 | + public function getExpiration(): DateTimeInterface | false | null |
|
| 48 | 48 | { |
| 49 | 49 | return $this->expiration; |
| 50 | 50 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * @return array<mixed>|JsonSerializable |
| 56 | 56 | */ |
| 57 | - public function getPayload(): array|JsonSerializable |
|
| 57 | + public function getPayload(): array | JsonSerializable |
|
| 58 | 58 | { |
| 59 | 59 | return $this->payload; |
| 60 | 60 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | return $this->charset; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function getExpiration(): DateTimeInterface|false|null |
|
| 72 | + public function getExpiration(): DateTimeInterface | false | null |
|
| 73 | 73 | { |
| 74 | 74 | return $this->expiration; |
| 75 | 75 | } |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | 'paths' => $this->getPaths($apis, $baseUrl, $basePath), |
| 219 | 219 | ]; |
| 220 | 220 | |
| 221 | - if (!$securitySchemes) { |
|
| 221 | + if ( ! $securitySchemes) { |
|
| 222 | 222 | unset($data['components']['securitySchemes']); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if (!empty($this->definitions)) { |
|
| 225 | + if ( ! empty($this->definitions)) { |
|
| 226 | 226 | $data['components']['schemas'] = array_merge($this->definitions, $data['components']['schemas']); |
| 227 | 227 | } |
| 228 | 228 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | private function getApis(string $version): array |
| 241 | 241 | { |
| 242 | - return array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) { |
|
| 242 | + return array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) { |
|
| 243 | 243 | return $version === $api->getEndpoint()->getVersion(); |
| 244 | 244 | }); |
| 245 | 245 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $parameters = $this->createParamsList($handler); |
| 273 | 273 | $requestBody = $this->createRequestBody($handler); |
| 274 | 274 | |
| 275 | - if (!empty($parameters) || !empty($requestBody)) { |
|
| 275 | + if ( ! empty($parameters) || ! empty($requestBody)) { |
|
| 276 | 276 | $responses[IResponse::S400_BAD_REQUEST] = [ |
| 277 | 277 | 'description' => 'Bad request', |
| 278 | 278 | 'content' => [ |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | $authorization = $api->getAuthorization(); |
| 289 | 289 | |
| 290 | - if (!$authorization instanceof NoAuthorization) { |
|
| 290 | + if ( ! $authorization instanceof NoAuthorization) { |
|
| 291 | 291 | $responses[IResponse::S401_Unauthorized] = [ |
| 292 | 292 | 'description' => 'Operation forbidden', |
| 293 | 293 | 'content' => [ |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | foreach ($handler->outputs() as $output) { |
| 315 | 315 | if ($output instanceof JsonOutput) { |
| 316 | 316 | $schema = $this->transformSchema(json_decode($output->getSchema(), true)); |
| 317 | - if (!isset($responses[$output->getCode()])) { |
|
| 317 | + if ( ! isset($responses[$output->getCode()])) { |
|
| 318 | 318 | $responses[$output->getCode()] = [ |
| 319 | 319 | 'description' => $output->getDescription(), |
| 320 | 320 | 'content' => [ |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | ], |
| 324 | 324 | ], |
| 325 | 325 | ]; |
| 326 | - if (!empty($examples = $output->getExamples())) { |
|
| 326 | + if ( ! empty($examples = $output->getExamples())) { |
|
| 327 | 327 | if (count($examples) === 1) { |
| 328 | 328 | $example = is_array($output->getExample()) ? $output->getExample() : json_decode($output->getExample(), true); |
| 329 | 329 | /** @phpstan-ignore-next-line */ |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | } else { |
| 340 | - if (!isset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']['oneOf'])) { |
|
| 340 | + if ( ! isset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']['oneOf'])) { |
|
| 341 | 341 | /** @phpstan-ignore-next-line */ |
| 342 | 342 | $tmp = $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']; |
| 343 | 343 | unset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']); |
@@ -367,11 +367,11 @@ discard block |
||
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if (!empty($parameters)) { |
|
| 370 | + if ( ! empty($parameters)) { |
|
| 371 | 371 | $settings['parameters'] = $parameters; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if (!empty($requestBody)) { |
|
| 374 | + if ( ! empty($requestBody)) { |
|
| 375 | 375 | $settings['requestBody'] = $requestBody; |
| 376 | 376 | } |
| 377 | 377 | |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | foreach ($handler->params() as $param) { |
| 510 | 510 | if ($param instanceof JsonInputParam) { |
| 511 | 511 | $schema = json_decode($param->getSchema(), true); |
| 512 | - if (!empty($examples = $param->getExamples())) { |
|
| 512 | + if ( ! empty($examples = $param->getExamples())) { |
|
| 513 | 513 | if (count($examples) === 1) { |
| 514 | 514 | $schema['example'] = is_array($param->getExample()) ? $param->getExample() : json_decode($param->getExample(), true); |
| 515 | 515 | } else { |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | $schema = [ |
| 530 | 530 | 'type' => 'string', |
| 531 | 531 | ]; |
| 532 | - if (!empty($examples = $param->getExamples())) { |
|
| 532 | + if ( ! empty($examples = $param->getExamples())) { |
|
| 533 | 533 | if (count($examples) === 1) { |
| 534 | 534 | $schema['example'] = $param->getExample(); |
| 535 | 535 | } else { |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | - if (!empty($requestBody['properties'])) { |
|
| 597 | + if ( ! empty($requestBody['properties'])) { |
|
| 598 | 598 | $requestBodySchema = [ |
| 599 | 599 | 'type' => 'object', |
| 600 | 600 | 'properties' => $requestBody['properties'], |