Completed
Pull Request — master (#139)
by Roman
12:41
created
src/Misc/ConsoleRequest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
src/Link/ApiLinkMacro.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
         if (count($args) < 3) {
31 31
             $message = "Invalid link destination, too few arguments.";
32
-            if (!Debugger::$productionMode) {
32
+            if ( ! Debugger::$productionMode) {
33 33
                 throw new InvalidLinkException($message);
34 34
             }
35 35
             Debugger::log($message, Debugger::EXCEPTION);
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
         ];
46 46
 
47 47
         return $writer->write('echo ($this->filters->apiLink)((new Tomaj\NetteApi\EndpointIdentifier(' .
48
-            $arguments['method']  . ', ' .
49
-            $arguments['version']  . ', ' .
48
+            $arguments['method'] . ', ' .
49
+            $arguments['version'] . ', ' .
50 50
             $arguments['package'] . ', ' .
51 51
             $arguments['action'] . ')), ' . $arguments['params'] . ')');
52 52
     }
Please login to merge, or discard this patch.
src/Presenters/ApiPresenter.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,15 +108,15 @@  discard block
 block discarded – undo
108 108
                 }
109 109
                 $outputValidatorErrors[] = $validationResult->getErrors();
110 110
             }
111
-            if (!$outputValid) {
111
+            if ( ! $outputValid) {
112 112
                 Debugger::log($outputValidatorErrors, Debugger::ERROR);
113
-                if (!Debugger::$productionMode) {
113
+                if ( ! Debugger::$productionMode) {
114 114
                     $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error', 'details' => $outputValidatorErrors]);
115 115
                 }
116 116
             }
117 117
             $code = $response->getCode();
118 118
         } catch (Throwable $exception) {
119
-            if (!Debugger::$productionMode) {
119
+            if ( ! Debugger::$productionMode) {
120 120
                 $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error', 'detail' => $exception->getMessage()]);
121 121
             } else {
122 122
                 $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error']);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
     private function checkAuth(ApiAuthorizationInterface $authorization): ?IResponse
152 152
     {
153
-        if (!$authorization->authorized()) {
153
+        if ( ! $authorization->authorized()) {
154 154
             $this->response->setCode(Response::S403_FORBIDDEN);
155 155
             return new JsonResponse(['status' => 'error', 'message' => $authorization->getErrorMessage()]);
156 156
         }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     private function checkRateLimit(RateLimitInterface $rateLimit): ?IResponse
161 161
     {
162 162
         $rateLimitResponse = $rateLimit->check();
163
-        if (!$rateLimitResponse) {
163
+        if ( ! $rateLimitResponse) {
164 164
             return null;
165 165
         }
166 166
 
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
         $remaining = $rateLimitResponse->getRemaining();
169 169
         $retryAfter = $rateLimitResponse->getRetryAfter();
170 170
 
171
-        $this->response->addHeader('X-RateLimit-Limit', (string)$limit);
172
-        $this->response->addHeader('X-RateLimit-Remaining', (string)$remaining);
171
+        $this->response->addHeader('X-RateLimit-Limit', (string) $limit);
172
+        $this->response->addHeader('X-RateLimit-Remaining', (string) $remaining);
173 173
 
174 174
         if ($remaining === 0) {
175 175
             $this->response->setCode(Response::S429_TOO_MANY_REQUESTS);
176
-            $this->response->addHeader('Retry-After', (string)$retryAfter);
176
+            $this->response->addHeader('Retry-After', (string) $retryAfter);
177 177
             return $rateLimitResponse->getErrorResponse() ?: new JsonResponse(['status' => 'error', 'message' => 'Too many requests. Retry after ' . $retryAfter . ' seconds.']);
178 178
         }
179 179
         return null;
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 
236 236
     private function getRequestDomain(): ?string
237 237
     {
238
-        if (!filter_input(INPUT_SERVER, 'HTTP_REFERER')) {
238
+        if ( ! filter_input(INPUT_SERVER, 'HTTP_REFERER')) {
239 239
             return null;
240 240
         }
241 241
         $refererParsedUrl = parse_url(filter_input(INPUT_SERVER, 'HTTP_REFERER'));
242
-        if (!(isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) {
242
+        if ( ! (isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) {
243 243
             return null;
244 244
         }
245 245
         $url = $refererParsedUrl['scheme'] . '://' . $refererParsedUrl['host'];
Please login to merge, or discard this patch.
src/Handlers/OpenApiHandler.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $data = [
161 161
             'openapi' => '3.0.0',
162 162
             'info' => [
163
-                'version' => (string)$version,
163
+                'version' => (string) $version,
164 164
                 'title' => 'Nette API',
165 165
             ],
166 166
             'servers' => [
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
             'paths' => $this->getPaths($apis, $baseUrl, $basePath),
220 220
         ];
221 221
 
222
-        if (!$securitySchemes) {
222
+        if ( ! $securitySchemes) {
223 223
             unset($data['components']['securitySchemes']);
224 224
         }
225 225
 
226
-        if (!empty($this->definitions)) {
226
+        if ( ! empty($this->definitions)) {
227 227
             $data['components']['schemas'] = array_merge($this->definitions, $data['components']['schemas']);
228 228
         }
229 229
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
     private function getApis(int $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
     }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
             $parameters = $this->createParamsList($handler);
300 300
             $requestBody = $this->createRequestBody($handler);
301 301
 
302
-            if (!empty($parameters) || !empty($requestBody)) {
302
+            if ( ! empty($parameters) || ! empty($requestBody)) {
303 303
                 $responses[IResponse::S400_BAD_REQUEST] = [
304 304
                     'description' => 'Bad request',
305 305
                     'content' => [
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
             $authorization = $api->getAuthorization();
316 316
 
317
-            if (!$authorization instanceof NoAuthorization) {
317
+            if ( ! $authorization instanceof NoAuthorization) {
318 318
                 $responses[IResponse::S403_FORBIDDEN] = [
319 319
                     'description' => 'Operation forbidden',
320 320
                     'content' => [
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
                 ],
339 339
             ];
340 340
 
341
-            if (!empty($parameters)) {
341
+            if ( ! empty($parameters)) {
342 342
                 $settings['parameters'] = $parameters;
343 343
             }
344 344
 
345
-            if (!empty($requestBody)) {
345
+            if ( ! empty($requestBody)) {
346 346
                 $settings['requestBody'] = $requestBody;
347 347
             }
348 348
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
             }
556 556
         }
557 557
 
558
-        if (!empty($requestBody['properties'])) {
558
+        if ( ! empty($requestBody['properties'])) {
559 559
             $requestBodySchema = [
560 560
                 'type' => 'object',
561 561
                 'properties' => $requestBody['properties'],
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
     {
625 625
         $processedRefs = [];
626 626
         foreach ($this->transformers as $transformer) {
627
-            if (!method_exists($transformer, 'schema')) {
627
+            if ( ! method_exists($transformer, 'schema')) {
628 628
                 continue;
629 629
             }
630 630
             $stringForReplace = json_encode($this->transformSchema($transformer->schema()));
Please login to merge, or discard this patch.