Passed
Push — main ( 1fe2cd...c1deb1 )
by Dimitri
04:10
created
src/Router/Dispatcher.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             $controller = $routes->getDefaultController();
178 178
         }
179 179
 
180
-        if (! $fullName && is_string($controller)) {
180
+        if (!$fullName && is_string($controller)) {
181 181
             $controller = str_replace($routes->getDefaultNamespace(), '', $controller);
182 182
         }
183 183
 
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
             return;
301 301
         }
302 302
 
303
-        if (is_cli() && ! on_test()) {
303
+        if (is_cli() && !on_test()) {
304 304
             // @codeCoverageIgnoreStart
305 305
             // $this->request = Services::clirequest($this->config);
306 306
             // @codeCoverageIgnoreEnd
307 307
         }
308 308
 
309 309
         $version = $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1';
310
-        if (! is_numeric($version)) {
310
+        if (!is_numeric($version)) {
311 311
             $version = substr($version, strpos($version, '/') + 1);
312 312
         }
313 313
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         // Supposons le succès jusqu'à preuve du contraire.
327 327
         $this->response = Services::response()->withStatus(200);
328 328
 
329
-        if (! is_cli() || on_test()) {
329
+        if (!is_cli() || on_test()) {
330 330
         }
331 331
 
332 332
         $this->response = $this->response->withProtocolVersion($this->request->getProtocolVersion());
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
         }
411 411
 
412 412
         // Essayez de charger automatiquement la classe
413
-        if (! class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) {
413
+        if (!class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) {
414 414
             throw PageNotFoundException::controllerNotFound($this->controller, $this->method);
415 415
         }
416 416
 
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 
502 502
         $this->outputBufferingEnd();
503 503
 
504
-        throw PageNotFoundException::pageNotFound(! on_prod() || is_cli() ? $e->getMessage() : '');
504
+        throw PageNotFoundException::pageNotFound(!on_prod() || is_cli() ? $e->getMessage() : '');
505 505
     }
506 506
 
507 507
     /**
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
     public function storePreviousURL($uri)
544 544
     {
545 545
         // Ignorer les requêtes CLI
546
-        if (is_cli() && ! on_test()) {
546
+        if (is_cli() && !on_test()) {
547 547
             return; // @codeCoverageIgnore
548 548
         }
549 549
 
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
         }
554 554
 
555 555
         // Ignorer les reponses non-HTML
556
-        if (! str_contains($this->response->getHeaderLine('Content-Type'), 'text/html')) {
556
+        if (!str_contains($this->response->getHeaderLine('Content-Type'), 'text/html')) {
557 557
             return;
558 558
         }
559 559
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
      */
578 578
     protected function sendResponse()
579 579
     {
580
-        if (! $this->isAjaxRequest()) {
580
+        if (!$this->isAjaxRequest()) {
581 581
             $this->response = Services::toolbar()->prepare(
582 582
                 $this->getPerformanceStats(),
583 583
                 $this->request,
@@ -670,11 +670,11 @@  discard block
 block discarded – undo
670 670
      */
671 671
     private function spoofRequestMethod(): callable
672 672
     {
673
-        return static function (ServerRequestInterface $request, ResponseInterface $response, callable $next) {
673
+        return static function(ServerRequestInterface $request, ResponseInterface $response, callable $next) {
674 674
             $post = $request->getParsedBody();
675 675
 
676 676
             // Ne fonctionne qu'avec les formulaires POST
677
-            if ($request->getMethod() === Method::POST && ! empty($post['_method'])) {
677
+            if ($request->getMethod() === Method::POST && !empty($post['_method'])) {
678 678
                 // Accepte seulement PUT, PATCH, DELETE
679 679
                 if (in_array($post['_method'], [Method::PUT, Method::PATCH, Method::DELETE], true)) {
680 680
                     $request = $request->withMethod($post['_method']);
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 
688 688
     private function bootApp(): callable
689 689
     {
690
-        return function (ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface {
690
+        return function(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface {
691 691
             Services::set(Request::class, $request);
692 692
             Services::set(Response::class, $response);
693 693
 
@@ -695,10 +695,10 @@  discard block
 block discarded – undo
695 695
                 $returned = $this->startController();
696 696
 
697 697
                 // Les controleur sous forme de Closure sont executes dans startController().
698
-                if (! is_callable($this->controller)) {
698
+                if (!is_callable($this->controller)) {
699 699
                     $controller = $this->createController($request, $response);
700 700
 
701
-                    if (! method_exists($controller, '_remap') && ! is_callable([$controller, $this->method], false)) {
701
+                    if (!method_exists($controller, '_remap') && !is_callable([$controller, $this->method], false)) {
702 702
                         throw PageNotFoundException::methodNotFound($this->method);
703 703
                     }
704 704
 
Please login to merge, or discard this patch.
src/Router/AutoRouter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             $class = $this->translateURIDashes(ucfirst($segment));
162 162
 
163 163
             // dès que nous rencontrons un segment qui n'est pas compatible PSR-4, arrêter la recherche
164
-            if (! $this->isValidSegment($class)) {
164
+            if (!$this->isValidSegment($class)) {
165 165
                 return false;
166 166
             }
167 167
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
             throw new MethodNotFoundException();
388 388
         }
389 389
 
390
-        if (! $refMethod->isPublic()) {
390
+        if (!$refMethod->isPublic()) {
391 391
             throw new MethodNotFoundException();
392 392
         }
393 393
 
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
             return;
450 450
         }
451 451
 
452
-        if (! in_array(ltrim($classname, '\\'), get_declared_classes(), true)) {
452
+        if (!in_array(ltrim($classname, '\\'), get_declared_classes(), true)) {
453 453
             throw new PageNotFoundException(
454 454
                 '"' . $classname . '" n\'a pas été trouvé.'
455 455
             );
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
             return;
469 469
         }
470 470
 
471
-        if (! in_array($method, get_class_methods($this->controller), true)) {
471
+        if (!in_array($method, get_class_methods($this->controller), true)) {
472 472
             throw new PageNotFoundException(
473 473
                 '"' . $this->controller . '::' . $method . '()" n\'a pas été trouvé.'
474 474
             );
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
      */
573 573
     public function directory(): string
574 574
     {
575
-        return ! empty($this->directory) ? $this->directory : '';
575
+        return !empty($this->directory) ? $this->directory : '';
576 576
     }
577 577
 
578 578
     /**
Please login to merge, or discard this patch.
src/Router/Router.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
         // Toujours là ? Ensuite, nous pouvons essayer de faire correspondre l'URI avec
176 176
         // Contrôleurs/répertoires, mais l'application peut ne pas
177 177
         // vouloir ceci, comme dans le cas des API.
178
-        if (! $this->collection->shouldAutoRoute()) {
178
+        if (!$this->collection->shouldAutoRoute()) {
179 179
             throw new PageNotFoundException("Impossible de trouver une route pour '{$this->collection->getHTTPVerb()}: {$uri}'.");
180 180
         }
181 181
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public function controllerName()
207 207
     {
208
-        if (! is_string($this->controller)) {
208
+        if (!is_string($this->controller)) {
209 209
             return $this->controller;
210 210
         }
211 211
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 
251 251
             return [
252 252
                 $routeArray[0], // Controller
253
-                $routeArray[1] ?? 'index',   // Method
253
+                $routeArray[1] ?? 'index', // Method
254 254
             ];
255 255
         }
256 256
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
                 // Cette route est-elle censée rediriger vers une autre ?
375 375
                 if ($this->collection->isRedirect($routeKey)) {
376 376
                     // remplacement des groupes de routes correspondants par des références : post/([0-9]+) -> post/$1
377
-                    $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function () {
377
+                    $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function() {
378 378
                         static $i = 1;
379 379
 
380 380
                         return '$' . $i++;
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
                     );
395 395
 
396 396
                     if ($this->collection->shouldUseSupportedLocalesOnly()
397
-                        && ! in_array($matched['locale'], config('app.supported_locales'), true)) {
397
+                        && !in_array($matched['locale'], config('app.supported_locales'), true)) {
398 398
                         // Lancer une exception pour empêcher l'autorouteur,
399 399
                         // si activé, essayer de trouver une route
400 400
                         throw PageNotFoundException::localeNotSupported($matched['locale']);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 
407 407
                 // Utilisons-nous Closures ? Si tel est le cas, nous devons collecter les paramètres dans un tableau
408 408
                 // afin qu'ils puissent être transmis ultérieurement à la méthode du contrôleur.
409
-                if (! is_string($handler) && is_callable($handler)) {
409
+                if (!is_string($handler) && is_callable($handler)) {
410 410
                     $this->controller = $handler;
411 411
 
412 412
                     // Supprime la chaîne d'origine du tableau matches
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 
484 484
         return preg_replace_callback(
485 485
             $pattern,
486
-            static function ($match) use ($matches) {
486
+            static function($match) use ($matches) {
487 487
                 $index = (int) $match[1];
488 488
 
489 489
                 return $matches[$index] ?? '';
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
         // $this->method contient déjà le nom de la méthode par défaut,
525 525
         // donc ne l'écrasez pas avec le vide.
526
-        if (! empty($method)) {
526
+        if (!empty($method)) {
527 527
             $this->setMethod($method);
528 528
         }
529 529
 
Please login to merge, or discard this patch.
src/Router/RouteCollection.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         // Incluez le fichier routesFile s'il n'existe pas.
259 259
         // Ne conserver que pour les fins BC pour l'instant.
260 260
         $routeFiles = $this->routeFiles;
261
-        if (! in_array($routesFile, $routeFiles, true)) {
261
+        if (!in_array($routesFile, $routeFiles, true)) {
262 262
             $routeFiles[] = $routesFile;
263 263
         }
264 264
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         $routes = $this;
267 267
 
268 268
         foreach ($routeFiles as $routesFile) {
269
-            if (! is_file($routesFile)) {
269
+            if (!is_file($routesFile)) {
270 270
                 logger()->warning(sprintf('Fichier de route introuvable : "%s"', $routesFile));
271 271
 
272 272
                 continue;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function placeholder(array|string $placeholder, ?string $pattern = null): self
317 317
     {
318
-        if (! is_array($placeholder)) {
318
+        if (!is_array($placeholder)) {
319 319
             $placeholder = [$placeholder => $pattern];
320 320
         }
321 321
 
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
      *
1032 1032
      * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to
1033 1033
      */
1034
-    public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self
1034
+    public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self
1035 1035
     {
1036 1036
         if (empty($from) || empty($to)) {
1037 1037
             throw new InvalidArgumentException('Vous devez fournir les paramètres : $from, $to.');
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
                 $from = $route['from'];
1223 1223
 
1224 1224
                 // on ignore les closures
1225
-                if (! is_string($to)) {
1225
+                if (!is_string($to)) {
1226 1226
                     continue;
1227 1227
                 }
1228 1228
 
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 
1234 1234
                 // S'il y a une chance de correspondance, alors ce sera
1235 1235
                 // soit avec $search au début de la chaîne $to.
1236
-                if (! str_starts_with($to, $search)) {
1236
+                if (!str_starts_with($to, $search)) {
1237 1237
                     continue;
1238 1238
                 }
1239 1239
 
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 
1310 1310
         // Construisez notre chaîne résultante, en insérant les $params aux endroits appropriés.
1311 1311
         foreach ($matches[0] as $index => $placeholder) {
1312
-            if (! isset($params[$index])) {
1312
+            if (!isset($params[$index])) {
1313 1313
                 throw new InvalidArgumentException(
1314 1314
                     'Argument manquant pour "' . $placeholder . '" dans la route "' . $from . '".'
1315 1315
                 );
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
             // ou peut-être que $placeholder n'est pas un espace réservé, mais une regex.
1321 1321
             $pattern = $this->placeholders[$placeholderName] ?? $placeholder;
1322 1322
 
1323
-            if (! preg_match('#^' . $pattern . '$#u', (string) $params[$index])) {
1323
+            if (!preg_match('#^' . $pattern . '$#u', (string) $params[$index])) {
1324 1324
                 throw RouterException::invalidParameterType();
1325 1325
             }
1326 1326
 
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
             $from = trim($from, '/');
1378 1378
         }
1379 1379
 
1380
-        if (is_string($to) && ! str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) {
1380
+        if (is_string($to) && !str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) {
1381 1381
             $to = [$to, '__invoke'];
1382 1382
         }
1383 1383
 
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
         $options = array_merge($this->currentOptions ?? [], $options ?? []);
1390 1390
 
1391 1391
         if (isset($options['middleware'])) {
1392
-            if (! isset($options['middlewares'])) {
1392
+            if (!isset($options['middlewares'])) {
1393 1393
                 $options['middlewares'] = (array) $options['middleware'];
1394 1394
             }
1395 1395
             unset($options['middleware']);
@@ -1410,9 +1410,9 @@  discard block
 block discarded – undo
1410 1410
         }
1411 1411
 
1412 1412
         // Limitation du nom d'hôte ?
1413
-        if (! empty($options['hostname'])) {
1413
+        if (!empty($options['hostname'])) {
1414 1414
             // @todo déterminer s'il existe un moyen de mettre les hôtes sur liste blanche ?
1415
-            if (! $this->checkHostname($options['hostname'])) {
1415
+            if (!$this->checkHostname($options['hostname'])) {
1416 1416
                 return;
1417 1417
             }
1418 1418
 
@@ -1420,10 +1420,10 @@  discard block
 block discarded – undo
1420 1420
         }
1421 1421
 
1422 1422
         // Limitation du nom sous-domaine ?
1423
-        elseif (! empty($options['subdomain'])) {
1423
+        elseif (!empty($options['subdomain'])) {
1424 1424
             // Si nous ne correspondons pas au sous-domaine actuel, alors
1425 1425
             // nous n'avons pas besoin d'ajouter la route.
1426
-            if (! $this->checkSubdomains($options['subdomain'])) {
1426
+            if (!$this->checkSubdomains($options['subdomain'])) {
1427 1427
                 return;
1428 1428
             }
1429 1429
 
@@ -1456,9 +1456,9 @@  discard block
 block discarded – undo
1456 1456
         }
1457 1457
 
1458 1458
         // S'il s'agit d'une redirection, aucun traitement
1459
-        if (! isset($options['redirect']) && is_string($to)) {
1459
+        if (!isset($options['redirect']) && is_string($to)) {
1460 1460
             // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut
1461
-            if (! str_contains($to, '\\') || strpos($to, '\\') > 0) {
1461
+            if (!str_contains($to, '\\') || strpos($to, '\\') > 0) {
1462 1462
                 $namespace = $options['namespace'] ?? $this->defaultNamespace;
1463 1463
                 $to        = trim($namespace, '\\') . '\\' . $to;
1464 1464
             }
@@ -1475,7 +1475,7 @@  discard block
 block discarded – undo
1475 1475
         // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant
1476 1476
         // pour tenter de router la requête.
1477 1477
         $routeKeyExists = isset($this->routes[$verb][$routeKey]);
1478
-        if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && ! $overwrite) {
1478
+        if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && !$overwrite) {
1479 1479
             return;
1480 1480
         }
1481 1481
 
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
     private function checkHostname(string $hostname): bool
1502 1502
     {
1503 1503
         // Les appels CLI ne peuvent pas être sur le nom d'hôte.
1504
-        if (! isset($this->httpHost)) {
1504
+        if (!isset($this->httpHost)) {
1505 1505
             return false;
1506 1506
         }
1507 1507
 
@@ -1517,7 +1517,7 @@  discard block
 block discarded – undo
1517 1517
     private function checkSubdomains($subdomains): bool
1518 1518
     {
1519 1519
         // Les appels CLI ne peuvent pas être sur le sous-domaine.
1520
-        if (! isset($this->httpHost)) {
1520
+        if (!isset($this->httpHost)) {
1521 1521
             return false;
1522 1522
         }
1523 1523
 
@@ -1525,13 +1525,13 @@  discard block
 block discarded – undo
1525 1525
             $this->currentSubdomain = $this->determineCurrentSubdomain();
1526 1526
         }
1527 1527
 
1528
-        if (! is_array($subdomains)) {
1528
+        if (!is_array($subdomains)) {
1529 1529
             $subdomains = [$subdomains];
1530 1530
         }
1531 1531
 
1532 1532
         // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant,
1533 1533
         // il nécessite la présence d'un sous-domaine.
1534
-        if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) {
1534
+        if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) {
1535 1535
             return true;
1536 1536
         }
1537 1537
 
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
         // sur l'URL sinon parse_url sera mal interprété
1554 1554
         // 'hôte' comme 'chemin'.
1555 1555
         $url = $this->httpHost;
1556
-        if (! str_starts_with($url, 'http')) {
1556
+        if (!str_starts_with($url, 'http')) {
1557 1557
             $url = 'http://' . $url;
1558 1558
         }
1559 1559
 
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
      */
1598 1598
     private function getControllerName(Closure|string $handler): ?string
1599 1599
     {
1600
-        if (! is_string($handler)) {
1600
+        if (!is_string($handler)) {
1601 1601
             return null;
1602 1602
         }
1603 1603
 
@@ -1656,13 +1656,13 @@  discard block
 block discarded – undo
1656 1656
      */
1657 1657
     private function replaceLocale(string $route, ?string $locale = null): string
1658 1658
     {
1659
-        if (! str_contains($route, '{locale}')) {
1659
+        if (!str_contains($route, '{locale}')) {
1660 1660
             return $route;
1661 1661
         }
1662 1662
 
1663 1663
         // Vérifier les paramètres régionaux non valides
1664 1664
         if ($locale !== null) {
1665
-            if (! in_array($locale, config('app.supported_locales'), true)) {
1665
+            if (!in_array($locale, config('app.supported_locales'), true)) {
1666 1666
                 $locale = null;
1667 1667
             }
1668 1668
         }
Please login to merge, or discard this patch.