Completed
Pull Request — master (#128)
by
unknown
26:03 queued 11:07
created
src/Handlers/OpenApiHandler.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'],
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/Misc/ConsoleRequest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             }
52 52
 
53 53
             $parsedUrl = parse_url($url);
54
-            if (!isset($parsedUrl['query'])) {
54
+            if ( ! isset($parsedUrl['query'])) {
55 55
                 $separator = '?';
56 56
             } else {
57 57
                 $separator = '&';
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                     } elseif ($param->getType() === InputParam::TYPE_COOKIE) {
177 177
                         $cookieFields[$key][] = $valueData;
178 178
                     } else {
179
-                        $getFields[$key][] = urlencode((string)$valueData);
179
+                        $getFields[$key][] = urlencode((string) $valueData);
180 180
                     }
181 181
                 } else {
182 182
                     if (in_array($param->getType(), [InputParam::TYPE_POST, InputParam::TYPE_FILE])) {
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                     } elseif ($param->getType() === InputParam::TYPE_COOKIE) {
187 187
                         $cookieFields[$key] = $valueData;
188 188
                     } else {
189
-                        $getFields[$key] = urlencode((string)$valueData);
189
+                        $getFields[$key] = urlencode((string) $valueData);
190 190
                     }
191 191
                 }
192 192
             }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     {
231 231
         $result = [];
232 232
         foreach ($values as $key => $value) {
233
-            if (!is_array($value)) {
233
+            if ( ! is_array($value)) {
234 234
                 $result[$key] = $value;
235 235
                 continue;
236 236
             }
Please login to merge, or discard this patch.