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