Passed
Push — main ( 20cf55...34042d )
by Dimitri
11:48
created
src/Router/RouteCollection.php 1 patch
Spacing   +22 added lines, -22 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;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      */
305 305
     public function addPlaceholder($placeholder, ?string $pattern = null): self
306 306
     {
307
-        if (! is_array($placeholder)) {
307
+        if (!is_array($placeholder)) {
308 308
             $placeholder = [$placeholder => $pattern];
309 309
         }
310 310
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         // Nous avons besoin de cette variable dans la portée locale pour que les fichiers de route puissent y accéder.
396 396
         $routes = $this;
397 397
 
398
-        $files    = $this->locator->search('Config/routes.php');
398
+        $files = $this->locator->search('Config/routes.php');
399 399
         
400 400
         foreach ($files as $file) {
401 401
             // N'incluez plus notre fichier principal...
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
         // que nous pourrions avoir besoin de faire.
540 540
         $this->discoverRoutes();
541 541
 
542
-        $routes     = [];
542
+        $routes = [];
543 543
         if (isset($this->routes[$verb])) {
544 544
             // Conserve les itinéraires du verbe actuel au début afin qu'ils soient
545 545
             // mis en correspondance avant l'un des itinéraires génériques "add".
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
     {
633 633
         // Utilisez le modèle de la route nommée s'il s'agit d'une route nommée.
634 634
         if (array_key_exists($to, $this->routesNames['*'])) {
635
-			$routeName  = $to;
635
+			$routeName = $to;
636 636
             $routeKey   = $this->routesNames['*'][$routeName];
637 637
             $redirectTo = [$routeKey => $this->routes['*'][$routeKey]['handler']];
638 638
 
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
      *
968 968
      * @param array|Closure|string $to
969 969
      */
970
-    public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self
970
+    public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self
971 971
     {
972 972
         if (empty($from) || empty($to)) {
973 973
             throw new InvalidArgumentException('Vous devez fournir les paramètres : $from, $to.');
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
                 $from = $route['from'];
1155 1155
 
1156 1156
                 // on ignore les closures
1157
-                if (! is_string($to)) {
1157
+                if (!is_string($to)) {
1158 1158
                     continue;
1159 1159
                 }
1160 1160
 
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
 
1244 1244
         // Construisez notre chaîne résultante, en insérant les $params aux endroits appropriés.
1245 1245
         foreach ($matches[0] as $index => $placeholder) {
1246
-            if (! isset($params[$index])) {
1246
+            if (!isset($params[$index])) {
1247 1247
                 throw new InvalidArgumentException(
1248 1248
                     'Argument manquant pour "' . $placeholder . '" dans la route "' . $from . '".'
1249 1249
                 );
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
             // ou peut-être que $placeholder n'est pas un espace réservé, mais une regex.
1255 1255
             $pattern = $this->placeholders[$placeholderName] ?? $placeholder;
1256 1256
 
1257
-            if (! preg_match('#^' . $pattern . '$#u', $params[$index])) {
1257
+            if (!preg_match('#^' . $pattern . '$#u', $params[$index])) {
1258 1258
                 throw RouterException::invalidParameterType();
1259 1259
             }
1260 1260
 
@@ -1332,9 +1332,9 @@  discard block
 block discarded – undo
1332 1332
         }
1333 1333
 
1334 1334
         // Limitation du nom d'hôte ?
1335
-        if (! empty($options['hostname'])) {
1335
+        if (!empty($options['hostname'])) {
1336 1336
             // @todo déterminer s'il existe un moyen de mettre les hôtes sur liste blanche ?
1337
-            if (! $this->checkHostname($options['hostname'])) {
1337
+            if (!$this->checkHostname($options['hostname'])) {
1338 1338
                 return;
1339 1339
             }
1340 1340
 
@@ -1342,10 +1342,10 @@  discard block
 block discarded – undo
1342 1342
         }
1343 1343
 
1344 1344
         // Limitation du nom sous-domaine ?
1345
-        elseif (! empty($options['subdomain'])) {
1345
+        elseif (!empty($options['subdomain'])) {
1346 1346
             // Si nous ne correspondons pas au sous-domaine actuel, alors
1347 1347
             // nous n'avons pas besoin d'ajouter la route.
1348
-            if (! $this->checkSubdomains($options['subdomain'])) {
1348
+            if (!$this->checkSubdomains($options['subdomain'])) {
1349 1349
                 return;
1350 1350
             }
1351 1351
 
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
         }
1379 1379
        
1380 1380
         // S'il s'agit d'une redirection, aucun traitement
1381
-        if (! isset($options['redirect']) && is_string($to)) {
1381
+        if (!isset($options['redirect']) && is_string($to)) {
1382 1382
             // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut
1383 1383
             if (strpos($to, '\\') === false || strpos($to, '\\') > 0) {
1384 1384
                 $namespace = $options['namespace'] ?? $this->defaultNamespace;
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
         // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant
1398 1398
         // pour tenter de router la requête.
1399 1399
         $routeKeyExists = isset($this->routes[$verb][$routeKey]);
1400
-        if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && ! $overwrite) {
1400
+        if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && !$overwrite) {
1401 1401
             return;
1402 1402
         }
1403 1403
 
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
     private function checkHostname(string $hostname): bool
1424 1424
     {
1425 1425
         // Les appels CLI ne peuvent pas être sur le nom d'hôte.
1426
-        if (! isset($this->httpHost) || is_cli()) {
1426
+        if (!isset($this->httpHost) || is_cli()) {
1427 1427
             return false;
1428 1428
         }
1429 1429
 
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
     private function checkSubdomains($subdomains): bool
1440 1440
     {
1441 1441
         // Les appels CLI ne peuvent pas être sur le sous-domaine.
1442
-        if (! isset($this->httpHost)) {
1442
+        if (!isset($this->httpHost)) {
1443 1443
             return false;
1444 1444
         }
1445 1445
 
@@ -1447,13 +1447,13 @@  discard block
 block discarded – undo
1447 1447
             $this->currentSubdomain = $this->determineCurrentSubdomain();
1448 1448
         }
1449 1449
 
1450
-        if (! is_array($subdomains)) {
1450
+        if (!is_array($subdomains)) {
1451 1451
             $subdomains = [$subdomains];
1452 1452
         }
1453 1453
 
1454 1454
         // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant,
1455 1455
         // il nécessite la présence d'un sous-domaine.
1456
-        if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) {
1456
+        if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) {
1457 1457
             return true;
1458 1458
         }
1459 1459
 
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 
1517 1517
     private function getControllerName(Closure|string $handler): ?string
1518 1518
     {
1519
-        if (! is_string($handler)) {
1519
+        if (!is_string($handler)) {
1520 1520
             return null;
1521 1521
         }
1522 1522
 
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
 
1582 1582
         // Vérifier les paramètres régionaux non valides
1583 1583
         if ($locale !== null) {
1584
-            if (! in_array($locale, config('app.supported_locales'), true)) {
1584
+            if (!in_array($locale, config('app.supported_locales'), true)) {
1585 1585
                 $locale = null;
1586 1586
             }
1587 1587
         }
Please login to merge, or discard this patch.