@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | // Incluez le fichier routesFile s'il n'existe pas. |
264 | 264 | // Ne conserver que pour les fins BC pour l'instant. |
265 | 265 | $routeFiles = $this->routeFiles; |
266 | - if (! in_array($routesFile, $routeFiles, true)) { |
|
266 | + if (!in_array($routesFile, $routeFiles, true)) { |
|
267 | 267 | $routeFiles[] = $routesFile; |
268 | 268 | } |
269 | 269 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $routes = $this; |
272 | 272 | |
273 | 273 | foreach ($routeFiles as $routesFile) { |
274 | - if (! is_file($routesFile)) { |
|
274 | + if (!is_file($routesFile)) { |
|
275 | 275 | logger()->warning(sprintf('Fichier de route introuvable : "%s"', $routesFile)); |
276 | 276 | |
277 | 277 | continue; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function placeholder(array|string $placeholder, ?string $pattern = null): self |
322 | 322 | { |
323 | - if (! is_array($placeholder)) { |
|
323 | + if (!is_array($placeholder)) { |
|
324 | 324 | $placeholder = [$placeholder => $pattern]; |
325 | 325 | } |
326 | 326 | |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | * |
1024 | 1024 | * @param array|Closure|string $to |
1025 | 1025 | */ |
1026 | - public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self |
|
1026 | + public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self |
|
1027 | 1027 | { |
1028 | 1028 | if (empty($from) || empty($to)) { |
1029 | 1029 | throw new InvalidArgumentException('Vous devez fournir les paramètres : $from, $to.'); |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | $from = $route['from']; |
1213 | 1213 | |
1214 | 1214 | // on ignore les closures |
1215 | - if (! is_string($to)) { |
|
1215 | + if (!is_string($to)) { |
|
1216 | 1216 | continue; |
1217 | 1217 | } |
1218 | 1218 | |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | |
1224 | 1224 | // S'il y a une chance de correspondance, alors ce sera |
1225 | 1225 | // soit avec $search au début de la chaîne $to. |
1226 | - if (! str_starts_with($to, $search)) { |
|
1226 | + if (!str_starts_with($to, $search)) { |
|
1227 | 1227 | continue; |
1228 | 1228 | } |
1229 | 1229 | |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | |
1300 | 1300 | // Construisez notre chaîne résultante, en insérant les $params aux endroits appropriés. |
1301 | 1301 | foreach ($matches[0] as $index => $placeholder) { |
1302 | - if (! isset($params[$index])) { |
|
1302 | + if (!isset($params[$index])) { |
|
1303 | 1303 | throw new InvalidArgumentException( |
1304 | 1304 | 'Argument manquant pour "' . $placeholder . '" dans la route "' . $from . '".' |
1305 | 1305 | ); |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | // ou peut-être que $placeholder n'est pas un espace réservé, mais une regex. |
1311 | 1311 | $pattern = $this->placeholders[$placeholderName] ?? $placeholder; |
1312 | 1312 | |
1313 | - if (! preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
1313 | + if (!preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
1314 | 1314 | throw RouterException::invalidParameterType(); |
1315 | 1315 | } |
1316 | 1316 | |
@@ -1367,7 +1367,7 @@ discard block |
||
1367 | 1367 | $from = trim($from, '/'); |
1368 | 1368 | } |
1369 | 1369 | |
1370 | - if (is_string($to) && ! str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) { |
|
1370 | + if (is_string($to) && !str_contains($to, '::') && class_exists($to) && method_exists($to, '__invoke')) { |
|
1371 | 1371 | $to = [$to, '__invoke']; |
1372 | 1372 | } |
1373 | 1373 | |
@@ -1379,7 +1379,7 @@ discard block |
||
1379 | 1379 | $options = array_merge($this->currentOptions ?? [], $options ?? []); |
1380 | 1380 | |
1381 | 1381 | if (isset($options['middleware'])) { |
1382 | - if (! isset($options['middlewares'])) { |
|
1382 | + if (!isset($options['middlewares'])) { |
|
1383 | 1383 | $options['middlewares'] = (array) $options['middleware']; |
1384 | 1384 | } |
1385 | 1385 | unset($options['middleware']); |
@@ -1400,9 +1400,9 @@ discard block |
||
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | // Limitation du nom d'hôte ? |
1403 | - if (! empty($options['hostname'])) { |
|
1403 | + if (!empty($options['hostname'])) { |
|
1404 | 1404 | // @todo déterminer s'il existe un moyen de mettre les hôtes sur liste blanche ? |
1405 | - if (! $this->checkHostname($options['hostname'])) { |
|
1405 | + if (!$this->checkHostname($options['hostname'])) { |
|
1406 | 1406 | return; |
1407 | 1407 | } |
1408 | 1408 | |
@@ -1410,10 +1410,10 @@ discard block |
||
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | // Limitation du nom sous-domaine ? |
1413 | - elseif (! empty($options['subdomain'])) { |
|
1413 | + elseif (!empty($options['subdomain'])) { |
|
1414 | 1414 | // Si nous ne correspondons pas au sous-domaine actuel, alors |
1415 | 1415 | // nous n'avons pas besoin d'ajouter la route. |
1416 | - if (! $this->checkSubdomains($options['subdomain'])) { |
|
1416 | + if (!$this->checkSubdomains($options['subdomain'])) { |
|
1417 | 1417 | return; |
1418 | 1418 | } |
1419 | 1419 | |
@@ -1446,9 +1446,9 @@ discard block |
||
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | // S'il s'agit d'une redirection, aucun traitement |
1449 | - if (! isset($options['redirect']) && is_string($to)) { |
|
1449 | + if (!isset($options['redirect']) && is_string($to)) { |
|
1450 | 1450 | // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut |
1451 | - if (! str_contains($to, '\\') || strpos($to, '\\') > 0) { |
|
1451 | + if (!str_contains($to, '\\') || strpos($to, '\\') > 0) { |
|
1452 | 1452 | $namespace = $options['namespace'] ?? $this->defaultNamespace; |
1453 | 1453 | $to = trim($namespace, '\\') . '\\' . $to; |
1454 | 1454 | } |
@@ -1465,7 +1465,7 @@ discard block |
||
1465 | 1465 | // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant |
1466 | 1466 | // pour tenter de router la requête. |
1467 | 1467 | $routeKeyExists = isset($this->routes[$verb][$routeKey]); |
1468 | - if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && ! $overwrite) { |
|
1468 | + if ((isset($this->routesNames[$verb][$name]) || $routeKeyExists) && !$overwrite) { |
|
1469 | 1469 | return; |
1470 | 1470 | } |
1471 | 1471 | |
@@ -1491,7 +1491,7 @@ discard block |
||
1491 | 1491 | private function checkHostname(string $hostname): bool |
1492 | 1492 | { |
1493 | 1493 | // Les appels CLI ne peuvent pas être sur le nom d'hôte. |
1494 | - if (! isset($this->httpHost)) { |
|
1494 | + if (!isset($this->httpHost)) { |
|
1495 | 1495 | return false; |
1496 | 1496 | } |
1497 | 1497 | |
@@ -1507,7 +1507,7 @@ discard block |
||
1507 | 1507 | private function checkSubdomains($subdomains): bool |
1508 | 1508 | { |
1509 | 1509 | // Les appels CLI ne peuvent pas être sur le sous-domaine. |
1510 | - if (! isset($this->httpHost)) { |
|
1510 | + if (!isset($this->httpHost)) { |
|
1511 | 1511 | return false; |
1512 | 1512 | } |
1513 | 1513 | |
@@ -1515,13 +1515,13 @@ discard block |
||
1515 | 1515 | $this->currentSubdomain = $this->determineCurrentSubdomain(); |
1516 | 1516 | } |
1517 | 1517 | |
1518 | - if (! is_array($subdomains)) { |
|
1518 | + if (!is_array($subdomains)) { |
|
1519 | 1519 | $subdomains = [$subdomains]; |
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant, |
1523 | 1523 | // il nécessite la présence d'un sous-domaine. |
1524 | - if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1524 | + if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1525 | 1525 | return true; |
1526 | 1526 | } |
1527 | 1527 | |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | // sur l'URL sinon parse_url sera mal interprété |
1544 | 1544 | // 'hôte' comme 'chemin'. |
1545 | 1545 | $url = $this->httpHost; |
1546 | - if (! str_starts_with($url, 'http')) { |
|
1546 | + if (!str_starts_with($url, 'http')) { |
|
1547 | 1547 | $url = 'http://' . $url; |
1548 | 1548 | } |
1549 | 1549 | |
@@ -1584,7 +1584,7 @@ discard block |
||
1584 | 1584 | |
1585 | 1585 | private function getControllerName(Closure|string $handler): ?string |
1586 | 1586 | { |
1587 | - if (! is_string($handler)) { |
|
1587 | + if (!is_string($handler)) { |
|
1588 | 1588 | return null; |
1589 | 1589 | } |
1590 | 1590 | |
@@ -1643,13 +1643,13 @@ discard block |
||
1643 | 1643 | */ |
1644 | 1644 | private function replaceLocale(string $route, ?string $locale = null): string |
1645 | 1645 | { |
1646 | - if (! str_contains($route, '{locale}')) { |
|
1646 | + if (!str_contains($route, '{locale}')) { |
|
1647 | 1647 | return $route; |
1648 | 1648 | } |
1649 | 1649 | |
1650 | 1650 | // Vérifier les paramètres régionaux non valides |
1651 | 1651 | if ($locale !== null) { |
1652 | - if (! in_array($locale, config('app.supported_locales'), true)) { |
|
1652 | + if (!in_array($locale, config('app.supported_locales'), true)) { |
|
1653 | 1653 | $locale = null; |
1654 | 1654 | } |
1655 | 1655 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $this->cookies = $config['cookies']; |
235 | 235 | |
236 | 236 | if (isset($config['uri'])) { |
237 | - if (! $config['uri'] instanceof UriInterface) { |
|
237 | + if (!$config['uri'] instanceof UriInterface) { |
|
238 | 238 | throw new FrameworkException('The `uri` key must be an instance of ' . UriInterface::class); |
239 | 239 | } |
240 | 240 | $uri = $config['uri']; |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | } |
438 | 438 | |
439 | 439 | $type = strtolower($type); |
440 | - if (! isset(static::$_detectors[$type])) { |
|
440 | + if (!isset(static::$_detectors[$type])) { |
|
441 | 441 | return false; |
442 | 442 | } |
443 | 443 | if ($args) { |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | public function isAll(array $types): bool |
590 | 590 | { |
591 | 591 | foreach ($types as $type) { |
592 | - if (! $this->is($type)) { |
|
592 | + if (!$this->is($type)) { |
|
593 | 593 | return false; |
594 | 594 | } |
595 | 595 | } |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | protected function normalizeHeaderName(string $name): string |
694 | 694 | { |
695 | 695 | $name = str_replace('-', '_', strtoupper($name)); |
696 | - if (! in_array($name, ['CONTENT_LENGTH', 'CONTENT_TYPE'], true)) { |
|
696 | + if (!in_array($name, ['CONTENT_LENGTH', 'CONTENT_TYPE'], true)) { |
|
697 | 697 | $name = 'HTTP_' . $name; |
698 | 698 | } |
699 | 699 | |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | { |
872 | 872 | $new = clone $this; |
873 | 873 | |
874 | - if (! preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) { |
|
874 | + if (!preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) { |
|
875 | 875 | throw new InvalidArgumentException(sprintf( |
876 | 876 | 'Méthode HTTP non prise en charge "%s" fournie', |
877 | 877 | $method |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | } |
1115 | 1115 | } |
1116 | 1116 | |
1117 | - if (! isset($accept[$prefValue])) { |
|
1117 | + if (!isset($accept[$prefValue])) { |
|
1118 | 1118 | $accept[$prefValue] = []; |
1119 | 1119 | } |
1120 | 1120 | if ($prefValue) { |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | if ($name === null) { |
1193 | 1193 | return $this->data; |
1194 | 1194 | } |
1195 | - if (! is_array($this->data)) { |
|
1195 | + if (!is_array($this->data)) { |
|
1196 | 1196 | return $default; |
1197 | 1197 | } |
1198 | 1198 | |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | */ |
1333 | 1333 | public function withProtocolVersion(string $version): static |
1334 | 1334 | { |
1335 | - if (! preg_match('/^(1\.[01]|2(\.[0])?)$/', $version)) { |
|
1335 | + if (!preg_match('/^(1\.[01]|2(\.[0])?)$/', $version)) { |
|
1336 | 1336 | throw new InvalidArgumentException(sprintf('Version de protocole `%s` non prise en charge fournie.', $version)); |
1337 | 1337 | } |
1338 | 1338 | $new = clone $this; |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | public function getEnv(string $key, ?string $default = null): ?string |
1355 | 1355 | { |
1356 | 1356 | $key = strtoupper($key); |
1357 | - if (! array_key_exists($key, $this->_environment) || null === $this->_environment[$key]) { |
|
1357 | + if (!array_key_exists($key, $this->_environment) || null === $this->_environment[$key]) { |
|
1358 | 1358 | $this->_environment[$key] = env($key); |
1359 | 1359 | } |
1360 | 1360 | |
@@ -1571,7 +1571,7 @@ discard block |
||
1571 | 1571 | $file = Arr::get($this->uploadedFiles, $path); |
1572 | 1572 | if (is_array($file)) { |
1573 | 1573 | foreach ($file as $f) { |
1574 | - if (! ($f instanceof UploadedFile)) { |
|
1574 | + if (!($f instanceof UploadedFile)) { |
|
1575 | 1575 | return null; |
1576 | 1576 | } |
1577 | 1577 | } |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | return $file; |
1580 | 1580 | } |
1581 | 1581 | |
1582 | - if (! ($file instanceof UploadedFileInterface)) { |
|
1582 | + if (!($file instanceof UploadedFileInterface)) { |
|
1583 | 1583 | return null; |
1584 | 1584 | } |
1585 | 1585 | |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | continue; |
1628 | 1628 | } |
1629 | 1629 | |
1630 | - if (! $file instanceof UploadedFileInterface) { |
|
1630 | + if (!$file instanceof UploadedFileInterface) { |
|
1631 | 1631 | throw new InvalidArgumentException("Fichier invalide à '{$path}{$key}'"); |
1632 | 1632 | } |
1633 | 1633 | } |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | } |
1679 | 1679 | |
1680 | 1680 | $host = $uri->getHost(); |
1681 | - if (! $host) { |
|
1681 | + if (!$host) { |
|
1682 | 1682 | return $new; |
1683 | 1683 | } |
1684 | 1684 | $port = $uri->getPort(); |
@@ -1786,7 +1786,7 @@ discard block |
||
1786 | 1786 | $validLocales = config('app.supported_locales'); |
1787 | 1787 | // S'il ne s'agit pas d'un paramètre régional valide, définissez-le |
1788 | 1788 | // aux paramètres régionaux par défaut du site. |
1789 | - if (! in_array($locale, $validLocales, true)) { |
|
1789 | + if (!in_array($locale, $validLocales, true)) { |
|
1790 | 1790 | $locale = config('app.language'); |
1791 | 1791 | } |
1792 | 1792 | |
@@ -1886,7 +1886,7 @@ discard block |
||
1886 | 1886 | $override = true; |
1887 | 1887 | } |
1888 | 1888 | |
1889 | - if ($override && ! in_array($this->_environment['REQUEST_METHOD'], ['PUT', 'POST', 'DELETE', 'PATCH'], true)) { |
|
1889 | + if ($override && !in_array($this->_environment['REQUEST_METHOD'], ['PUT', 'POST', 'DELETE', 'PATCH'], true)) { |
|
1890 | 1890 | $data = []; |
1891 | 1891 | } |
1892 | 1892 | |
@@ -1936,7 +1936,7 @@ discard block |
||
1936 | 1936 | */ |
1937 | 1937 | protected function _processFiles(array $post, array $files): array |
1938 | 1938 | { |
1939 | - if (! is_array($files)) { |
|
1939 | + if (!is_array($files)) { |
|
1940 | 1940 | return $post; |
1941 | 1941 | } |
1942 | 1942 |