@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | if (count($args) < 3) { |
| 29 | 29 | $message = "Invalid link destination, too few arguments."; |
| 30 | - if (!Debugger::$productionMode) { |
|
| 30 | + if ( ! Debugger::$productionMode) { |
|
| 31 | 31 | throw new InvalidLinkException($message); |
| 32 | 32 | } |
| 33 | 33 | Debugger::log($message, Debugger::EXCEPTION); |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | return $writer->write('echo ($presenter->context->getByType("' . ApiLink::class . '"))' . |
| 46 | 46 | '->link((new Tomaj\NetteApi\EndpointIdentifier(' . |
| 47 | - $arguments['method'] . ', ' . |
|
| 48 | - $arguments['version'] . ', ' . |
|
| 47 | + $arguments['method'] . ', ' . |
|
| 48 | + $arguments['version'] . ', ' . |
|
| 49 | 49 | $arguments['package'] . ', ' . |
| 50 | 50 | $arguments['action'] . ')), ' . $arguments['params'] . ')'); |
| 51 | 51 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $data = [ |
| 149 | 149 | 'openapi' => '3.0.0', |
| 150 | 150 | 'info' => [ |
| 151 | - 'version' => (string)$version, |
|
| 151 | + 'version' => (string) $version, |
|
| 152 | 152 | 'title' => 'Nette API', |
| 153 | 153 | ], |
| 154 | 154 | 'servers' => [ |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | 'paths' => $this->getPaths($apis, $baseUrl, $basePath), |
| 208 | 208 | ]; |
| 209 | 209 | |
| 210 | - if (!$securitySchemes) { |
|
| 210 | + if ( ! $securitySchemes) { |
|
| 211 | 211 | unset($data['components']['securitySchemes']); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - if (!empty($this->definitions)) { |
|
| 214 | + if ( ! empty($this->definitions)) { |
|
| 215 | 215 | $data['components']['schemas'] = array_merge($this->definitions, $data['components']['schemas']); |
| 216 | 216 | } |
| 217 | 217 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | private function getApis(int $version): array |
| 227 | 227 | { |
| 228 | - return array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) { |
|
| 228 | + return array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) { |
|
| 229 | 229 | return $version === $api->getEndpoint()->getVersion(); |
| 230 | 230 | }); |
| 231 | 231 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $parameters = $this->createParamsList($handler); |
| 286 | 286 | $requestBody = $this->createRequestBody($handler); |
| 287 | 287 | |
| 288 | - if (!empty($parameters) || !empty($requestBody)) { |
|
| 288 | + if ( ! empty($parameters) || ! empty($requestBody)) { |
|
| 289 | 289 | $responses[IResponse::S400_BAD_REQUEST] = [ |
| 290 | 290 | 'description' => 'Bad request', |
| 291 | 291 | 'content' => [ |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | $authorization = $api->getAuthorization(); |
| 302 | 302 | |
| 303 | - if (!$authorization instanceof NoAuthorization) { |
|
| 303 | + if ( ! $authorization instanceof NoAuthorization) { |
|
| 304 | 304 | $responses[IResponse::S403_FORBIDDEN] = [ |
| 305 | 305 | 'description' => 'Operation forbidden', |
| 306 | 306 | 'content' => [ |
@@ -324,11 +324,11 @@ discard block |
||
| 324 | 324 | ], |
| 325 | 325 | ]; |
| 326 | 326 | |
| 327 | - if (!empty($parameters)) { |
|
| 327 | + if ( ! empty($parameters)) { |
|
| 328 | 328 | $settings['parameters'] = $parameters; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if (!empty($requestBody)) { |
|
| 331 | + if ( ! empty($requestBody)) { |
|
| 332 | 332 | $settings['requestBody'] = $requestBody; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - if (!empty($requestBody['properties'])) { |
|
| 515 | + if ( ! empty($requestBody['properties'])) { |
|
| 516 | 516 | $requestBodySchema = [ |
| 517 | 517 | 'type' => 'object', |
| 518 | 518 | 'properties' => $requestBody['properties'], |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $paramsProcessor = new ParamsProcessor($handler->params()); |
| 84 | 84 | if ($paramsProcessor->isError()) { |
| 85 | 85 | $this->response->setCode(Response::S400_BAD_REQUEST); |
| 86 | - if (!Debugger::$productionMode) { |
|
| 86 | + if ( ! Debugger::$productionMode) { |
|
| 87 | 87 | $response = new JsonResponse(['status' => 'error', 'message' => 'wrong input', 'detail' => $paramsProcessor->getErrors()]); |
| 88 | 88 | } else { |
| 89 | 89 | $response = new JsonResponse(['status' => 'error', 'message' => 'wrong input']); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $outputValid = count($handler->outputs()) === 0; // back compatibility for handlers with no outputs defined |
| 98 | 98 | $outputValidatorErrors = []; |
| 99 | 99 | foreach ($handler->outputs() as $output) { |
| 100 | - if (!$output instanceof OutputInterface) { |
|
| 100 | + if ( ! $output instanceof OutputInterface) { |
|
| 101 | 101 | $outputValidatorErrors[] = ["Output does not implement OutputInterface"]; |
| 102 | 102 | continue; |
| 103 | 103 | } |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | $outputValidatorErrors[] = $validationResult->getErrors(); |
| 110 | 110 | } |
| 111 | - if (!$outputValid) { |
|
| 111 | + if ( ! $outputValid) { |
|
| 112 | 112 | $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error', 'details' => $outputValidatorErrors]); |
| 113 | 113 | } |
| 114 | 114 | $code = $response->getCode(); |
| 115 | 115 | } catch (Throwable $exception) { |
| 116 | - if (!Debugger::$productionMode) { |
|
| 116 | + if ( ! Debugger::$productionMode) { |
|
| 117 | 117 | $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error', 'detail' => $exception->getMessage()]); |
| 118 | 118 | } else { |
| 119 | 119 | $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error']); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | private function checkAuth(ApiAuthorizationInterface $authorization): ?IResponse |
| 149 | 149 | { |
| 150 | - if (!$authorization->authorized()) { |
|
| 150 | + if ( ! $authorization->authorized()) { |
|
| 151 | 151 | $this->response->setCode(Response::S403_FORBIDDEN); |
| 152 | 152 | return new JsonResponse(['status' => 'error', 'message' => $authorization->getErrorMessage()]); |
| 153 | 153 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | private function checkRateLimit(RateLimitInterface $rateLimit): ?IResponse |
| 158 | 158 | { |
| 159 | 159 | $rateLimitResponse = $rateLimit->check(); |
| 160 | - if (!$rateLimitResponse) { |
|
| 160 | + if ( ! $rateLimitResponse) { |
|
| 161 | 161 | return null; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | $remaining = $rateLimitResponse->getRemaining(); |
| 166 | 166 | $retryAfter = $rateLimitResponse->getRetryAfter(); |
| 167 | 167 | |
| 168 | - $this->response->addHeader('X-RateLimit-Limit', (string)$limit); |
|
| 169 | - $this->response->addHeader('X-RateLimit-Remaining', (string)$remaining); |
|
| 168 | + $this->response->addHeader('X-RateLimit-Limit', (string) $limit); |
|
| 169 | + $this->response->addHeader('X-RateLimit-Remaining', (string) $remaining); |
|
| 170 | 170 | |
| 171 | 171 | if ($remaining === 0) { |
| 172 | 172 | $this->response->setCode(Response::S429_TOO_MANY_REQUESTS); |
| 173 | - $this->response->addHeader('Retry-After', (string)$retryAfter); |
|
| 173 | + $this->response->addHeader('Retry-After', (string) $retryAfter); |
|
| 174 | 174 | return $rateLimitResponse->getErrorResponse() ?: new JsonResponse(['status' => 'error', 'message' => 'Too many requests. Retry after ' . $retryAfter . ' seconds.']); |
| 175 | 175 | } |
| 176 | 176 | return null; |
@@ -232,11 +232,11 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | private function getRequestDomain(): ?string |
| 234 | 234 | { |
| 235 | - if (!filter_input(INPUT_SERVER, 'HTTP_REFERER')) { |
|
| 235 | + if ( ! filter_input(INPUT_SERVER, 'HTTP_REFERER')) { |
|
| 236 | 236 | return null; |
| 237 | 237 | } |
| 238 | 238 | $refererParsedUrl = parse_url(filter_input(INPUT_SERVER, 'HTTP_REFERER')); |
| 239 | - if (!(isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) { |
|
| 239 | + if ( ! (isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) { |
|
| 240 | 240 | return null; |
| 241 | 241 | } |
| 242 | 242 | $url = $refererParsedUrl['scheme'] . '://' . $refererParsedUrl['host']; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } elseif ($param->getType() === InputParam::TYPE_COOKIE) { |
| 170 | 170 | $cookieFields[$key][] = $valueData; |
| 171 | 171 | } else { |
| 172 | - $getFields[$key][] = urlencode((string)$valueData); |
|
| 172 | + $getFields[$key][] = urlencode((string) $valueData); |
|
| 173 | 173 | } |
| 174 | 174 | } else { |
| 175 | 175 | if (in_array($param->getType(), [InputParam::TYPE_POST, InputParam::TYPE_FILE])) { |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } elseif ($param->getType() === InputParam::TYPE_COOKIE) { |
| 180 | 180 | $cookieFields[$key] = $valueData; |
| 181 | 181 | } else { |
| 182 | - $getFields[$key] = urlencode((string)$valueData); |
|
| 182 | + $getFields[$key] = urlencode((string) $valueData); |
|
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $result = []; |
| 225 | 225 | foreach ($values as $key => $value) { |
| 226 | - if (!is_array($value)) { |
|
| 226 | + if ( ! is_array($value)) { |
|
| 227 | 227 | $result[$key] = $value; |
| 228 | 228 | continue; |
| 229 | 229 | } |