Passed
Push — main ( addcf0...74f3ac )
by
unknown
17:18 queued 12:06
created
src/Router/RouteCollection.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         // Incluez le fichier routesFile s'il n'existe pas.
257 257
         // Ne conserver que pour les fins BC pour l'instant.
258 258
         $routeFiles = $this->routeFiles;
259
-        if (! in_array($routesFile, $routeFiles, true)) {
259
+        if (!in_array($routesFile, $routeFiles, true)) {
260 260
             $routeFiles[] = $routesFile;
261 261
         }
262 262
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         $routes = $this;
265 265
 
266 266
         foreach ($routeFiles as $routesFile) {
267
-            if (! is_file($routesFile)) {
267
+            if (!is_file($routesFile)) {
268 268
                 logger()->warning(sprintf('Fichier de route introuvable : "%s"', $routesFile));
269 269
 
270 270
                 continue;
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
      */
314 314
     public function placeholder(array|string $placeholder, ?string $pattern = null): self
315 315
     {
316
-        if (! is_array($placeholder)) {
316
+        if (!is_array($placeholder)) {
317 317
             $placeholder = [$placeholder => $pattern];
318 318
         }
319 319
 
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
      *
1026 1026
      * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to
1027 1027
      */
1028
-    public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self
1028
+    public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self
1029 1029
     {
1030 1030
         if ($from === '' || empty($to)) {
1031 1031
             throw new InvalidArgumentException('Vous devez fournir les paramètres : $from, $to.');
@@ -1210,8 +1210,8 @@  discard block
 block discarded – undo
1210 1210
         // Ajoutez l'espace de noms par défaut si nécessaire.
1211 1211
         $namespace = trim($this->defaultNamespace, '\\') . '\\';
1212 1212
         if (
1213
-            ! str_starts_with($search, '\\')
1214
-            && ! str_starts_with($search, $namespace)
1213
+            !str_starts_with($search, '\\')
1214
+            && !str_starts_with($search, $namespace)
1215 1215
         ) {
1216 1216
             $search = $namespace . $search;
1217 1217
         }
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
                 $from = $route['from'];
1225 1225
 
1226 1226
                 // on ignore les closures
1227
-                if (! is_string($to)) {
1227
+                if (!is_string($to)) {
1228 1228
                     continue;
1229 1229
                 }
1230 1230
 
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 
1236 1236
                 // S'il y a une chance de correspondance, alors ce sera
1237 1237
                 // soit avec $search au début de la chaîne $to.
1238
-                if (! str_starts_with($to, $search)) {
1238
+                if (!str_starts_with($to, $search)) {
1239 1239
                     continue;
1240 1240
                 }
1241 1241
 
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
 
1316 1316
         // Construisez notre chaîne résultante, en insérant les $params aux endroits appropriés.
1317 1317
         foreach ($matches[0] as $index => $placeholder) {
1318
-            if (! isset($params[$index])) {
1318
+            if (!isset($params[$index])) {
1319 1319
                 throw new InvalidArgumentException(
1320 1320
                     'Argument manquant pour "' . $placeholder . '" dans la route "' . $from . '".'
1321 1321
                 );
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
             // ou peut-être que $placeholder n'est pas un espace réservé, mais une regex.
1327 1327
             $pattern = $this->placeholders[$placeholderName] ?? $placeholder;
1328 1328
 
1329
-            if (! preg_match('#^' . $pattern . '$#u', (string) $params[$index])) {
1329
+            if (!preg_match('#^' . $pattern . '$#u', (string) $params[$index])) {
1330 1330
                 throw RouterException::invalidParameterType();
1331 1331
             }
1332 1332
 
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
             $from = trim($from, '/');
1388 1388
         }
1389 1389
 
1390
-        if (is_string($to) && ! str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) {
1390
+        if (is_string($to) && !str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) {
1391 1391
             $to = [$to, '__invoke'];
1392 1392
         }
1393 1393
 
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
         if (isset($options['middleware'])) {
1402 1402
             $options['middleware'] = (array) $options['middleware'];
1403 1403
 
1404
-            if (! isset($options['middlewares'])) {
1404
+            if (!isset($options['middlewares'])) {
1405 1405
                 $options['middlewares'] = $options['middleware'];
1406 1406
             } else {
1407 1407
                 $options['middlewares'] = array_merge($options['middlewares'], $options['middleware']);
@@ -1429,9 +1429,9 @@  discard block
 block discarded – undo
1429 1429
         }
1430 1430
 
1431 1431
         // Limitation du nom d'hôte ?
1432
-        if (! empty($options['hostname'])) {
1432
+        if (!empty($options['hostname'])) {
1433 1433
             // @todo déterminer s'il existe un moyen de mettre les hôtes sur liste blanche ?
1434
-            if (! $this->checkHostname($options['hostname'])) {
1434
+            if (!$this->checkHostname($options['hostname'])) {
1435 1435
                 return;
1436 1436
             }
1437 1437
 
@@ -1439,10 +1439,10 @@  discard block
 block discarded – undo
1439 1439
         }
1440 1440
 
1441 1441
         // Limitation du nom sous-domaine ?
1442
-        elseif (! empty($options['subdomain'])) {
1442
+        elseif (!empty($options['subdomain'])) {
1443 1443
             // Si nous ne correspondons pas au sous-domaine actuel, alors
1444 1444
             // nous n'avons pas besoin d'ajouter la route.
1445
-            if (! $this->checkSubdomains($options['subdomain'])) {
1445
+            if (!$this->checkSubdomains($options['subdomain'])) {
1446 1446
                 return;
1447 1447
             }
1448 1448
 
@@ -1475,9 +1475,9 @@  discard block
 block discarded – undo
1475 1475
         }
1476 1476
 
1477 1477
         // S'il s'agit d'une redirection, aucun traitement
1478
-        if (! isset($options['redirect']) && is_string($to)) {
1478
+        if (!isset($options['redirect']) && is_string($to)) {
1479 1479
             // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut
1480
-            if (! str_contains($to, '\\') || strpos($to, '\\') > 0) {
1480
+            if (!str_contains($to, '\\') || strpos($to, '\\') > 0) {
1481 1481
                 $namespace = $options['namespace'] ?? $this->defaultNamespace;
1482 1482
                 $to        = trim($namespace, '\\') . '\\' . $to;
1483 1483
             }
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
         // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant
1495 1495
         // pour tenter de router la requête.
1496 1496
         $routeKeyExists = isset($this->routes[$verb][$routeKey]);
1497
-        if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && ! $overwrite) {
1497
+        if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && !$overwrite) {
1498 1498
             return;
1499 1499
         }
1500 1500
 
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
     private function checkHostname(string $hostname): bool
1521 1521
     {
1522 1522
         // Les appels CLI ne peuvent pas être sur le nom d'hôte.
1523
-        if (! isset($this->httpHost)) {
1523
+        if (!isset($this->httpHost)) {
1524 1524
             return false;
1525 1525
         }
1526 1526
 
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
     private function checkSubdomains($subdomains): bool
1537 1537
     {
1538 1538
         // Les appels CLI ne peuvent pas être sur le sous-domaine.
1539
-        if (! isset($this->httpHost)) {
1539
+        if (!isset($this->httpHost)) {
1540 1540
             return false;
1541 1541
         }
1542 1542
 
@@ -1544,13 +1544,13 @@  discard block
 block discarded – undo
1544 1544
             $this->currentSubdomain = $this->determineCurrentSubdomain();
1545 1545
         }
1546 1546
 
1547
-        if (! is_array($subdomains)) {
1547
+        if (!is_array($subdomains)) {
1548 1548
             $subdomains = [$subdomains];
1549 1549
         }
1550 1550
 
1551 1551
         // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant,
1552 1552
         // il nécessite la présence d'un sous-domaine.
1553
-        if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) {
1553
+        if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) {
1554 1554
             return true;
1555 1555
         }
1556 1556
 
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
         // sur l'URL sinon parse_url sera mal interprété
1573 1573
         // 'hôte' comme 'chemin'.
1574 1574
         $url = $this->httpHost;
1575
-        if (! str_starts_with($url, 'http')) {
1575
+        if (!str_starts_with($url, 'http')) {
1576 1576
             $url = 'http://' . $url;
1577 1577
         }
1578 1578
 
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
      */
1617 1617
     private function getControllerName(Closure|string $handler): ?string
1618 1618
     {
1619
-        if (! is_string($handler)) {
1619
+        if (!is_string($handler)) {
1620 1620
             return null;
1621 1621
         }
1622 1622
 
@@ -1675,12 +1675,12 @@  discard block
 block discarded – undo
1675 1675
      */
1676 1676
     private function replaceLocale(string $route, ?string $locale = null): string
1677 1677
     {
1678
-        if (! str_contains($route, '{locale}')) {
1678
+        if (!str_contains($route, '{locale}')) {
1679 1679
             return $route;
1680 1680
         }
1681 1681
 
1682 1682
         // Vérifier les paramètres régionaux non valides
1683
-        if ($locale !== null && ! in_array($locale, config('app.supported_locales'), true)) {
1683
+        if ($locale !== null && !in_array($locale, config('app.supported_locales'), true)) {
1684 1684
             $locale = null;
1685 1685
         }
1686 1686
 
Please login to merge, or discard this patch.