Passed
Branch main (21a390)
by Dimitri
11:42
created
src/Http/Middleware.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
      */
50 50
     public function add($middlewares): self
51 51
     {
52
-        if (! is_array($middlewares)) {
52
+        if (!is_array($middlewares)) {
53 53
             $middlewares = [$middlewares];
54 54
         }
55 55
 
Please login to merge, or discard this patch.
src/Http/ResponseEmitter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         }
112 112
         $body = $response->getBody();
113 113
 
114
-        if (! $body->isSeekable()) {
114
+        if (!$body->isSeekable()) {
115 115
             echo $body;
116 116
 
117 117
             return;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
         $body->rewind();
121 121
 
122
-        while (! $body->eof()) {
122
+        while (!$body->eof()) {
123 123
             echo $body->read($maxBufferLength);
124 124
         }
125 125
     }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 
139 139
         $body = $response->getBody();
140 140
 
141
-        if (! $body->isSeekable()) {
141
+        if (!$body->isSeekable()) {
142 142
             $contents = $body->getContents();
143 143
             echo substr($contents, $first, $last - $first + 1);
144 144
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         $pos    = 0;
151 151
         $length = $last - $first + 1;
152 152
 
153
-        while (! $body->eof() && $pos < $length) {
153
+        while (!$body->eof() && $pos < $length) {
154 154
             if (($pos + $maxBufferLength) > $length) {
155 155
                 echo $body->read($length - $pos);
156 156
                 break;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                 $key        = strtolower($key);
234 234
                 $data[$key] = $value;
235 235
             }
236
-            if (! empty($data['expires'])) {
236
+            if (!empty($data['expires'])) {
237 237
                 $data['expires'] = strtotime($data['expires']);
238 238
             }
239 239
             setcookie(
Please login to merge, or discard this patch.
src/Http/Response.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
         $this->_streamMode   = $options['streamMode'] ?? $this->_streamMode;
451 451
 
452 452
         if (isset($options['stream'])) {
453
-            if (! $options['stream'] instanceof StreamInterface) {
453
+            if (!$options['stream'] instanceof StreamInterface) {
454 454
                 throw new InvalidArgumentException('Stream option must be an object that implements StreamInterface');
455 455
             }
456 456
             $this->stream = $options['stream'];
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             $this->_setStatus($options['status']);
467 467
         }
468 468
 
469
-        if (! isset($options['charset'])) {
469
+        if (!isset($options['charset'])) {
470 470
             $options['charset'] = config('app.charset');
471 471
         }
472 472
         $this->_charset = $options['charset'];
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
     protected function _clearHeader(string $header): void
595 595
     {
596 596
         $normalized = strtolower($header);
597
-        if (! isset($this->headerNames[$normalized])) {
597
+        if (!isset($this->headerNames[$normalized])) {
598 598
             return;
599 599
         }
600 600
         $original = $this->headerNames[$normalized];
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
      */
834 834
     public function withCache($since, $time = '+1 day'): static
835 835
     {
836
-        if (! is_int($time)) {
836
+        if (!is_int($time)) {
837 837
             $time = strtotime($time);
838 838
             if ($time === false) {
839 839
                 throw new InvalidArgumentException(
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
      */
1288 1288
     public function getCookie(string $name): ?array
1289 1289
     {
1290
-        if (! $this->_cookies->has($name)) {
1290
+        if (!$this->_cookies->has($name)) {
1291 1291
             return null;
1292 1292
         }
1293 1293
 
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 
1361 1361
         $extension = strtolower($file->getExtension());
1362 1362
         $mapped    = $this->getMimeType($extension);
1363
-        if ((! $extension || ! $mapped) && $options['download'] === null) {
1363
+        if ((!$extension || !$mapped) && $options['download'] === null) {
1364 1364
             $options['download'] = true;
1365 1365
         }
1366 1366
 
@@ -1424,12 +1424,12 @@  discard block
 block discarded – undo
1424 1424
         if (strpos($path, '../') !== false || strpos($path, '..\\') !== false) {
1425 1425
             throw new LoadException('The requested file contains `..` and will not be read.');
1426 1426
         }
1427
-        if (! is_file($path)) {
1428
-            $path = APP_PATH . $path;  // @phpstan-ignore-line
1427
+        if (!is_file($path)) {
1428
+            $path = APP_PATH . $path; // @phpstan-ignore-line
1429 1429
         }
1430 1430
 
1431 1431
         $file = new SplFileInfo($path);
1432
-        if (! $file->isFile() || ! $file->isReadable()) {
1432
+        if (!$file->isFile() || !$file->isReadable()) {
1433 1433
             if (on_dev()) {
1434 1434
                 throw new LoadException(sprintf('The requested file %s was not found or not readable', $path));
1435 1435
             }
Please login to merge, or discard this patch.
src/Http/ServerRequest.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         $this->cookies = $config['cookies'];
251 251
 
252 252
         if (isset($config['uri'])) {
253
-            if (! $config['uri'] instanceof UriInterface) {
253
+            if (!$config['uri'] instanceof UriInterface) {
254 254
                 throw new FrameworkException('The `uri` key must be an instance of ' . UriInterface::class);
255 255
             }
256 256
             $uri = $config['uri'];
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
         $ref = $this->getEnv('HTTP_REFERER');
391 391
 
392 392
         $base = /* Configure::read('App.fullBaseUrl') .  */ $this->webroot;
393
-        if (! empty($ref) && ! empty($base)) {
393
+        if (!empty($ref) && !empty($base)) {
394 394
             if ($local && strpos($ref, $base) === 0) {
395 395
                 $ref = substr($ref, strlen($base));
396 396
                 if ($ref === '' || strpos($ref, '//') === 0) {
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 
403 403
                 return $ref;
404 404
             }
405
-            if (! $local) {
405
+            if (!$local) {
406 406
                 return $ref;
407 407
             }
408 408
         }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
         }
455 455
 
456 456
         $type = strtolower($type);
457
-        if (! isset(static::$_detectors[$type])) {
457
+        if (!isset(static::$_detectors[$type])) {
458 458
             return false;
459 459
         }
460 460
         if ($args) {
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
         foreach ($detect['header'] as $header => $value) {
534 534
             $header = $this->getEnv('http_' . $header);
535 535
             if ($header !== null) {
536
-                if (! is_string($value) && ! is_bool($value) && is_callable($value)) {
536
+                if (!is_string($value) && !is_bool($value) && is_callable($value)) {
537 537
                     return $value($header);
538 538
                 }
539 539
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
     public function isAll(array $types): bool
607 607
     {
608 608
         foreach ($types as $type) {
609
-            if (! $this->is($type)) {
609
+            if (!$this->is($type)) {
610 610
                 return false;
611 611
             }
612 612
         }
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
     protected function normalizeHeaderName(string $name): string
710 710
     {
711 711
         $name = str_replace('-', '_', strtoupper($name));
712
-        if (! in_array($name, ['CONTENT_LENGTH', 'CONTENT_TYPE'], true)) {
712
+        if (!in_array($name, ['CONTENT_LENGTH', 'CONTENT_TYPE'], true)) {
713 713
             $name = 'HTTP_' . $name;
714 714
         }
715 715
 
@@ -892,8 +892,8 @@  discard block
 block discarded – undo
892 892
         $new = clone $this;
893 893
 
894 894
         if (
895
-            ! is_string($method)
896
-            || ! preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)
895
+            !is_string($method)
896
+            || !preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)
897 897
         ) {
898 898
             throw new InvalidArgumentException(sprintf(
899 899
                 'Unsupported HTTP method "%s" provided',
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
                 }
1138 1138
             }
1139 1139
 
1140
-            if (! isset($accept[$prefValue])) {
1140
+            if (!isset($accept[$prefValue])) {
1141 1141
                 $accept[$prefValue] = [];
1142 1142
             }
1143 1143
             if ($prefValue) {
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
         if ($name === null) {
1216 1216
             return $this->data;
1217 1217
         }
1218
-        if (! is_array($this->data) && $name) {
1218
+        if (!is_array($this->data) && $name) {
1219 1219
             return $default;
1220 1220
         }
1221 1221
 
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
1356 1356
      */
1357 1357
     public function withProtocolVersion($version): self
1358 1358
     {
1359
-        if (! preg_match('/^(1\.[01]|2)$/', $version)) {
1359
+        if (!preg_match('/^(1\.[01]|2)$/', $version)) {
1360 1360
             throw new InvalidArgumentException("Unsupported protocol version '{$version}' provided");
1361 1361
         }
1362 1362
         $new           = clone $this;
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
     public function getEnv(string $key, ?string $default = null): ?string
1379 1379
     {
1380 1380
         $key = strtoupper($key);
1381
-        if (! array_key_exists($key, $this->_environment)) {
1381
+        if (!array_key_exists($key, $this->_environment)) {
1382 1382
             $this->_environment[$key] = env($key);
1383 1383
         }
1384 1384
 
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
         $file = Arr::get($this->uploadedFiles, $path);
1591 1591
         if (is_array($file)) {
1592 1592
             foreach ($file as $f) {
1593
-                if (! ($f instanceof UploadedFile)) {
1593
+                if (!($f instanceof UploadedFile)) {
1594 1594
                     return null;
1595 1595
                 }
1596 1596
             }
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
             return $file;
1599 1599
         }
1600 1600
 
1601
-        if (! ($file instanceof UploadedFile)) {
1601
+        if (!($file instanceof UploadedFile)) {
1602 1602
             return null;
1603 1603
         }
1604 1604
 
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
                 continue;
1647 1647
             }
1648 1648
 
1649
-            if (! $file instanceof UploadedFileInterface) {
1649
+            if (!$file instanceof UploadedFileInterface) {
1650 1650
                 throw new InvalidArgumentException("Invalid file at '{$path}{$key}'");
1651 1651
             }
1652 1652
         }
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
         }
1698 1698
 
1699 1699
         $host = $uri->getHost();
1700
-        if (! $host) {
1700
+        if (!$host) {
1701 1701
             return $new;
1702 1702
         }
1703 1703
         $port = $uri->getPort();
Please login to merge, or discard this patch.
src/Http/Cookie/CookieCollection.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     protected function checkCookies(array $cookies): void
182 182
     {
183 183
         foreach ($cookies as $index => $cookie) {
184
-            if (! $cookie instanceof CookieInterface) {
184
+            if (!$cookie instanceof CookieInterface) {
185 185
                 throw new InvalidArgumentException(
186 186
                     sprintf(
187 187
                         'Expected `%s[]` as $cookies but instead got `%s` at index %d',
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
             }
271 271
 
272 272
             $pattern = '/' . preg_quote($domain, '/') . '$/';
273
-            if (! preg_match($pattern, $host)) {
273
+            if (!preg_match($pattern, $host)) {
274 274
                 continue;
275 275
             }
276 276
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
         $hostPattern = '/' . preg_quote($host, '/') . '$/';
313 313
 
314 314
         foreach ($this->cookies as $i => $cookie) {
315
-            if (! $cookie->isExpired($time)) {
315
+            if (!$cookie->isExpired($time)) {
316 316
                 continue;
317 317
             }
318 318
             $pathMatches = strpos($path, $cookie->getPath()) === 0;
Please login to merge, or discard this patch.
src/Http/Cookie/Cookie.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
             return $expires->setTimezone(new DateTimeZone('GMT')); // @phpstan-ignore-line
240 240
         }
241 241
 
242
-        if (! is_string($expires) && ! is_int($expires)) {
242
+        if (!is_string($expires) && !is_int($expires)) {
243 243
             throw new InvalidArgumentException(sprintf(
244 244
                 'Invalid type `%s` for expires. Expected an string, integer or DateTime object.',
245 245
                 getTypeName($expires)
246 246
             ));
247 247
         }
248 248
 
249
-        if (! is_numeric($expires)) {
249
+        if (!is_numeric($expires)) {
250 250
             $expires = strtotime($expires) ?: null;
251 251
         }
252 252
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         if (isset($data['samesite'])) {
300 300
             // Ignorer la valeur non valide lors de l'analyse des en-têtes
301 301
             // https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1
302
-            if (! in_array($data['samesite'], CookieInterface::SAMESITE_VALUES, true)) {
302
+            if (!in_array($data['samesite'], CookieInterface::SAMESITE_VALUES, true)) {
303 303
                 unset($data['samesite']);
304 304
             }
305 305
         }
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
      */
543 543
     public function getExpiresTimestamp(): ?int
544 544
     {
545
-        if (! $this->expiresAt) {
545
+        if (!$this->expiresAt) {
546 546
             return null;
547 547
         }
548 548
 
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
      */
555 555
     public function getFormattedExpires(): string
556 556
     {
557
-        if (! $this->expiresAt) {
557
+        if (!$this->expiresAt) {
558 558
             return '';
559 559
         }
560 560
 
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
     public function isExpired($time = null): bool
568 568
     {
569 569
         $time = $time ?: new DateTimeImmutable('now', new DateTimeZone('UTC'));
570
-        if (! $this->expiresAt) {
570
+        if (!$this->expiresAt) {
571 571
             return false;
572 572
         }
573 573
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
      */
627 627
     protected static function validateSameSiteValue(string $sameSite)
628 628
     {
629
-        if (! in_array($sameSite, CookieInterface::SAMESITE_VALUES, true)) {
629
+        if (!in_array($sameSite, CookieInterface::SAMESITE_VALUES, true)) {
630 630
             throw new InvalidArgumentException(
631 631
                 'Samesite value must be either of: ' . implode(', ', CookieInterface::SAMESITE_VALUES)
632 632
             );
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 
781 781
         foreach (explode(',', $string) as $pair) {
782 782
             $key = explode('|', $pair);
783
-            if (! isset($key[1])) {
783
+            if (!isset($key[1])) {
784 784
                 return $key[0];
785 785
             }
786 786
             $array[$key[0]] = $key[1];
Please login to merge, or discard this patch.
src/Http/Negotiator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         }
207 207
 
208 208
         // Sort to get the highest results first
209
-        usort($results, static function ($a, $b) {
209
+        usort($results, static function($a, $b) {
210 210
             if ($a['q'] === $b['q']) {
211 211
                 $a_ast = substr_count($a['value'], '*');
212 212
                 $b_ast = substr_count($b['value'], '*');
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         }
277 277
 
278 278
         foreach ($supported['params'] as $label => $value) {
279
-            if (! isset($acceptable['params'][$label]) || $acceptable['params'][$label] !== $value) {
279
+            if (!isset($acceptable['params'][$label]) || $acceptable['params'][$label] !== $value) {
280 280
                 return false;
281 281
             }
282 282
         }
Please login to merge, or discard this patch.
src/Http/Uri.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 
173 173
         $authority = $this->host;
174 174
 
175
-        if (! empty($this->getUserInfo())) {
175
+        if (!empty($this->getUserInfo())) {
176 176
             $authority = $this->getUserInfo() . '@' . $authority;
177 177
         }
178 178
 
179
-        if (! empty($this->port) && ! $ignorePort) {
179
+        if (!empty($this->port) && !$ignorePort) {
180 180
             // N'ajoute pas de port s'il s'agit d'un port standard pour ce schéma
181 181
             if ($this->port !== $this->defaultPorts[$this->scheme]) {
182 182
                 $authority .= ':' . $this->port;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     {
196 196
         $userInfo = $this->user;
197 197
 
198
-        if ($this->showPassword === true && ! empty($this->password)) {
198
+        if ($this->showPassword === true && !empty($this->password)) {
199 199
             $userInfo .= ':' . $this->password;
200 200
         }
201 201
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         $vars = $this->query;
246 246
 
247 247
         if (array_key_exists('except', $options)) {
248
-            if (! is_array($options['except'])) {
248
+            if (!is_array($options['except'])) {
249 249
                 $options['except'] = [$options['except']];
250 250
             }
251 251
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         } elseif (array_key_exists('only', $options)) {
256 256
             $temp = [];
257 257
 
258
-            if (! is_array($options['only'])) {
258
+            if (!is_array($options['only'])) {
259 259
                 $options['only'] = [$options['only']];
260 260
             }
261 261
 
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
     public static function createURIString(?string $scheme = null, ?string $authority = null, ?string $path = null, ?string $query = null, ?string $fragment = null): string
357 357
     {
358 358
         $uri = '';
359
-        if (! empty($scheme)) {
359
+        if (!empty($scheme)) {
360 360
             $uri .= $scheme . '://';
361 361
         }
362 362
 
363
-        if (! empty($authority)) {
363
+        if (!empty($authority)) {
364 364
             $uri .= $authority;
365 365
         }
366 366
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     {
387 387
         $parts = parse_url($str);
388 388
 
389
-        if (empty($parts['host']) && ! empty($parts['path'])) {
389
+        if (empty($parts['host']) && !empty($parts['path'])) {
390 390
             $parts['host'] = $parts['path'];
391 391
             unset($parts['path']);
392 392
         }
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         }
532 532
 
533 533
         // Ne peut pas avoir de début ?
534
-        if (! empty($query) && strpos($query, '?') === 0) {
534
+        if (!empty($query) && strpos($query, '?') === 0) {
535 535
             $query = substr($query, 1);
536 536
         }
537 537
 
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
         $temp = [];
597 597
 
598 598
         foreach ($this->query as $key => $value) {
599
-            if (! in_array($key, $params, true)) {
599
+            if (!in_array($key, $params, true)) {
600 600
                 continue;
601 601
             }
602 602
 
@@ -667,19 +667,19 @@  discard block
 block discarded – undo
667 667
      */
668 668
     protected function applyParts(array $parts)
669 669
     {
670
-        if (! empty($parts['host'])) {
670
+        if (!empty($parts['host'])) {
671 671
             $this->host = $parts['host'];
672 672
         }
673
-        if (! empty($parts['user'])) {
673
+        if (!empty($parts['user'])) {
674 674
             $this->user = $parts['user'];
675 675
         }
676
-        if (! empty($parts['path'])) {
676
+        if (!empty($parts['path'])) {
677 677
             $this->path = $this->filterPath($parts['path']);
678 678
         }
679
-        if (! empty($parts['query'])) {
679
+        if (!empty($parts['query'])) {
680 680
             $this->setQuery($parts['query']);
681 681
         }
682
-        if (! empty($parts['fragment'])) {
682
+        if (!empty($parts['fragment'])) {
683 683
             $this->fragment = $parts['fragment'];
684 684
         }
685 685
 
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
             $this->password = $parts['pass'];
702 702
         }
703 703
 
704
-        if (! empty($parts['path'])) {
704
+        if (!empty($parts['path'])) {
705 705
             $this->segments = explode('/', trim($parts['path'], '/'));
706 706
         }
707 707
     }
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
         $transformed = clone $relative;
729 729
 
730 730
         // 5.2.2 Transformer les références dans une méthode non stricte (pas de schéma)
731
-        if (! empty($relative->getAuthority())) {
731
+        if (!empty($relative->getAuthority())) {
732 732
             $transformed->setAuthority($relative->getAuthority())
733 733
                 ->setPath($relative->getPath())
734 734
                 ->setQuery($relative->getQuery());
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
      */
769 769
     protected function mergePaths(self $base, self $reference): string
770 770
     {
771
-        if (! empty($base->getAuthority()) && empty($base->getPath())) {
771
+        if (!empty($base->getAuthority()) && empty($base->getPath())) {
772 772
             return '/' . ltrim($reference->getPath(), '/ ');
773 773
         }
774 774
 
Please login to merge, or discard this patch.
src/Http/Redirection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
     {
50 50
         $route = Services::routes()->reverseRoute($route, ...$params);
51 51
 
52
-        if (! $route) {
52
+        if (!$route) {
53 53
             throw HttpException::invalidRedirectRoute($route);
54 54
         }
55 55
 
Please login to merge, or discard this patch.