@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function addPlaceholder($placeholder, ?string $pattern = null): self |
257 | 257 | { |
258 | - if (! is_array($placeholder)) { |
|
258 | + if (!is_array($placeholder)) { |
|
259 | 259 | $placeholder = [$placeholder => $pattern]; |
260 | 260 | } |
261 | 261 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | |
349 | 349 | $files = $this->locator->search('Config/routes.php'); |
350 | 350 | $excludes = [ |
351 | - APP_PATH . 'Config' . DS . 'routes.php', |
|
351 | + APP_PATH . 'Config' . DS . 'routes.php', |
|
352 | 352 | SYST_PATH . 'Config' . DS . 'routes.php', |
353 | 353 | ]; |
354 | 354 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | foreach ($collection as $name => $r) { |
508 | 508 | $key = key($r['route']); |
509 | 509 | |
510 | - if (! $withName) { |
|
510 | + if (!$withName) { |
|
511 | 511 | $routes[$key] = $r['route'][$key]; |
512 | 512 | } else { |
513 | 513 | $routes[$key] = [ |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | * |
889 | 889 | * @param array|Closure|string $to |
890 | 890 | */ |
891 | - public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): self |
|
891 | + public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null) : self |
|
892 | 892 | { |
893 | 893 | if (empty($from) || empty($to)) { |
894 | 894 | throw new InvalidArgumentException('Vous devez fournir les paramètres : $from, $to.'); |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | $to = $route['route'][$from]; |
1058 | 1058 | |
1059 | 1059 | // on ignore les closures |
1060 | - if (! is_string($to)) { |
|
1060 | + if (!is_string($to)) { |
|
1061 | 1061 | continue; |
1062 | 1062 | } |
1063 | 1063 | |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | |
1147 | 1147 | // Construisez notre chaîne résultante, en insérant les $params aux endroits appropriés. |
1148 | 1148 | foreach ($matches[0] as $index => $pattern) { |
1149 | - if (! preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
1149 | + if (!preg_match('#^' . $pattern . '$#u', $params[$index])) { |
|
1150 | 1150 | throw RouterException::invalidParameterType(); |
1151 | 1151 | } |
1152 | 1152 | |
@@ -1224,9 +1224,9 @@ discard block |
||
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | // Limitation du nom d'hôte ? |
1227 | - if (! empty($options['hostname'])) { |
|
1227 | + if (!empty($options['hostname'])) { |
|
1228 | 1228 | // @todo déterminer s'il existe un moyen de mettre les hôtes sur liste blanche ? |
1229 | - if (! $this->checkHostname($options['hostname'])) { |
|
1229 | + if (!$this->checkHostname($options['hostname'])) { |
|
1230 | 1230 | return; |
1231 | 1231 | } |
1232 | 1232 | |
@@ -1234,10 +1234,10 @@ discard block |
||
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | // Limitation du nom sous-domaine ? |
1237 | - elseif (! empty($options['subdomain'])) { |
|
1237 | + elseif (!empty($options['subdomain'])) { |
|
1238 | 1238 | // Si nous ne correspondons pas au sous-domaine actuel, alors |
1239 | 1239 | // nous n'avons pas besoin d'ajouter la route. |
1240 | - if (! $this->checkSubdomains($options['subdomain'])) { |
|
1240 | + if (!$this->checkSubdomains($options['subdomain'])) { |
|
1241 | 1241 | return; |
1242 | 1242 | } |
1243 | 1243 | |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | // S'il s'agit d'une redirection, aucun traitement |
1271 | - if (! isset($options['redirect']) && is_string($to)) { |
|
1271 | + if (!isset($options['redirect']) && is_string($to)) { |
|
1272 | 1272 | // Si aucun espace de noms n'est trouvé, ajouter l'espace de noms par défaut |
1273 | 1273 | if (strpos($to, '\\') === false || strpos($to, '\\') > 0) { |
1274 | 1274 | $namespace = $options['namespace'] ?? $this->defaultNamespace; |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | // les routes manuelement définies doivent toujours être la "source de vérité". |
1287 | 1287 | // cela ne fonctionne que parce que les routes découvertes sont ajoutées juste avant |
1288 | 1288 | // pour tenter de router la requête. |
1289 | - if (isset($this->routes[$verb][$name]) && ! $overwrite) { |
|
1289 | + if (isset($this->routes[$verb][$name]) && !$overwrite) { |
|
1290 | 1290 | return; |
1291 | 1291 | } |
1292 | 1292 | |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | private function checkHostname(string $hostname): bool |
1311 | 1311 | { |
1312 | 1312 | // Les appels CLI ne peuvent pas être sur le nom d'hôte. |
1313 | - if (! isset($this->httpHost) || is_cli()) { |
|
1313 | + if (!isset($this->httpHost) || is_cli()) { |
|
1314 | 1314 | return false; |
1315 | 1315 | } |
1316 | 1316 | |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | private function checkSubdomains($subdomains): bool |
1327 | 1327 | { |
1328 | 1328 | // Les appels CLI ne peuvent pas être sur le sous-domaine. |
1329 | - if (! isset($_SERVER['HTTP_HOST'])) { |
|
1329 | + if (!isset($_SERVER['HTTP_HOST'])) { |
|
1330 | 1330 | return false; |
1331 | 1331 | } |
1332 | 1332 | |
@@ -1334,13 +1334,13 @@ discard block |
||
1334 | 1334 | $this->currentSubdomain = $this->determineCurrentSubdomain(); |
1335 | 1335 | } |
1336 | 1336 | |
1337 | - if (! is_array($subdomains)) { |
|
1337 | + if (!is_array($subdomains)) { |
|
1338 | 1338 | $subdomains = [$subdomains]; |
1339 | 1339 | } |
1340 | 1340 | |
1341 | 1341 | // Les routes peuvent être limitées à n'importe quel sous-domaine. Dans ce cas, cependant, |
1342 | 1342 | // il nécessite la présence d'un sous-domaine. |
1343 | - if (! empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1343 | + if (!empty($this->currentSubdomain) && in_array('*', $subdomains, true)) { |
|
1344 | 1344 | return true; |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | // Débarrassez-vous de tous les domaines, qui seront les derniers |
1378 | - unset($host[count($host) -1]); |
|
1378 | + unset($host[count($host) - 1]); |
|
1379 | 1379 | |
1380 | 1380 | // Compte pour les domaines .co.uk, .co.nz, etc. |
1381 | 1381 | if (end($host) === 'co') { |
@@ -1396,7 +1396,7 @@ discard block |
||
1396 | 1396 | */ |
1397 | 1397 | private function getControllerName(Closure|string $handler): ?string |
1398 | 1398 | { |
1399 | - if (! is_string($handler)) { |
|
1399 | + if (!is_string($handler)) { |
|
1400 | 1400 | return null; |
1401 | 1401 | } |
1402 | 1402 | |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | |
1462 | 1462 | // Vérifier les paramètres régionaux non valides |
1463 | 1463 | if ($locale !== null) { |
1464 | - if (! in_array($locale, config('app.supported_locales'), true)) { |
|
1464 | + if (!in_array($locale, config('app.supported_locales'), true)) { |
|
1465 | 1465 | $locale = null; |
1466 | 1466 | } |
1467 | 1467 | } |
@@ -262,7 +262,7 @@ |
||
262 | 262 | */ |
263 | 263 | private function attribute(string $key, $value): self |
264 | 264 | { |
265 | - if (! in_array($key, $this->allowedAttributes)) { |
|
265 | + if (!in_array($key, $this->allowedAttributes)) { |
|
266 | 266 | throw new InvalidArgumentException("L'attribute [{$key}] n'existe pas."); |
267 | 267 | } |
268 | 268 |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | // Toujours là ? Ensuite, nous pouvons essayer de faire correspondre l'URI avec |
168 | 168 | // Contrôleurs/répertoires, mais l'application peut ne pas |
169 | 169 | // vouloir ceci, comme dans le cas des API. |
170 | - if (! $this->collection->shouldAutoRoute()) { |
|
170 | + if (!$this->collection->shouldAutoRoute()) { |
|
171 | 171 | $verb = strtolower($this->collection->getHTTPVerb()); |
172 | 172 | |
173 | 173 | throw new PageNotFoundException("Impossible de trouver une route pour '{$verb}: {$uri}'."); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function controllerName() |
197 | 197 | { |
198 | - if (! is_string($this->controller)) { |
|
198 | + if (!is_string($this->controller)) { |
|
199 | 199 | return $this->controller; |
200 | 200 | } |
201 | 201 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | return [ |
237 | 237 | $routeArray[0], // Controller |
238 | - $routeArray[1] ?? 'index', // Method |
|
238 | + $routeArray[1] ?? 'index', // Method |
|
239 | 239 | ]; |
240 | 240 | } |
241 | 241 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | // Cette route est-elle censée rediriger vers une autre ? |
360 | 360 | if ($this->collection->isRedirect($routeKey)) { |
361 | 361 | // remplacement des groupes de routes correspondants par des références : post/([0-9]+) -> post/$1 |
362 | - $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function () { |
|
362 | + $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function() { |
|
363 | 363 | static $i = 1; |
364 | 364 | |
365 | 365 | return '$' . $i++; |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | ); |
380 | 380 | |
381 | 381 | if ($this->collection->shouldUseSupportedLocalesOnly() |
382 | - && ! in_array($matched['locale'], config('App')->supportedLocales, true)) { |
|
382 | + && !in_array($matched['locale'], config('App')->supportedLocales, true)) { |
|
383 | 383 | // Lancer une exception pour empêcher l'autorouteur, |
384 | 384 | // si activé, essayer de trouver une route |
385 | 385 | throw PageNotFoundException::localeNotSupported($matched['locale']); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // Utilisons-nous Closures ? Si tel est le cas, nous devons collecter les paramètres dans un tableau |
393 | 393 | // afin qu'ils puissent être transmis ultérieurement à la méthode du contrôleur. |
394 | - if (! is_string($handler) && is_callable($handler)) { |
|
394 | + if (!is_string($handler) && is_callable($handler)) { |
|
395 | 395 | $this->controller = $handler; |
396 | 396 | |
397 | 397 | // Supprime la chaîne d'origine du tableau matches |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | |
490 | 490 | // $this->method contient déjà le nom de la méthode par défaut, |
491 | 491 | // donc ne l'écrasez pas avec le vide. |
492 | - if (! empty($method)) { |
|
492 | + if (!empty($method)) { |
|
493 | 493 | $this->setMethod($method); |
494 | 494 | } |
495 | 495 | |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | $this->method = $this->collection->getDefaultMethod(); |
513 | 513 | } |
514 | 514 | |
515 | - if (! is_file(CONTROLLER_PATH . $this->directory . $this->makeController($class) . '.php')) { |
|
515 | + if (!is_file(CONTROLLER_PATH . $this->directory . $this->makeController($class) . '.php')) { |
|
516 | 516 | return; |
517 | 517 | } |
518 | 518 |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $controller = $routes->getDefaultController(); |
172 | 172 | } |
173 | 173 | |
174 | - if (! $fullName && is_string($controller)) { |
|
174 | + if (!$fullName && is_string($controller)) { |
|
175 | 175 | $controller = str_replace($routes->getDefaultNamespace(), '', $controller); |
176 | 176 | } |
177 | 177 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | */ |
281 | 281 | $this->gatherOutput($this->middleware->handle($this->request)); |
282 | 282 | |
283 | - if (! $this->returnResponse) { |
|
283 | + if (!$this->returnResponse) { |
|
284 | 284 | $this->sendResponse(); |
285 | 285 | } |
286 | 286 | |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | return; |
329 | 329 | } |
330 | 330 | |
331 | - if (is_cli() && ! on_test()) { |
|
331 | + if (is_cli() && !on_test()) { |
|
332 | 332 | // @codeCoverageIgnoreStart |
333 | 333 | // $this->request = Services::clirequest($this->config); |
334 | 334 | // @codeCoverageIgnoreEnd |
335 | 335 | } |
336 | 336 | |
337 | 337 | $version = $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1'; |
338 | - if (! is_numeric($version)) { |
|
338 | + if (!is_numeric($version)) { |
|
339 | 339 | $version = substr($version, strpos($version, '/') + 1); |
340 | 340 | } |
341 | 341 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | // Supposons le succès jusqu'à preuve du contraire. |
355 | 355 | $this->response = Services::response()->withStatus(200); |
356 | 356 | |
357 | - if (! is_cli() || on_test()) { |
|
357 | + if (!is_cli() || on_test()) { |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | $this->response = $this->response->withProtocolVersion($this->request->getProtocolVersion()); |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | { |
391 | 391 | if ($cachedResponse = Services::cache()->read($this->generateCacheName())) { |
392 | 392 | $cachedResponse = unserialize($cachedResponse); |
393 | - if (! is_array($cachedResponse) || ! isset($cachedResponse['output']) || ! isset($cachedResponse['headers'])) { |
|
393 | + if (!is_array($cachedResponse) || !isset($cachedResponse['output']) || !isset($cachedResponse['headers'])) { |
|
394 | 394 | throw new FrameworkException('Erreur lors de la désérialisation du cache de page'); |
395 | 395 | } |
396 | 396 | |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | */ |
524 | 524 | protected function determinePath(): string |
525 | 525 | { |
526 | - if (! empty($this->path)) { |
|
526 | + if (!empty($this->path)) { |
|
527 | 527 | return $this->path; |
528 | 528 | } |
529 | 529 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | } |
578 | 578 | |
579 | 579 | // Essayez de charger automatiquement la classe |
580 | - if (! class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) { |
|
580 | + if (!class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) { |
|
581 | 581 | throw PageNotFoundException::controllerNotFound($this->controller, $this->method); |
582 | 582 | } |
583 | 583 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | // Affiche l'erreur 404 |
672 | 672 | $this->response = $this->response->withStatus($e->getCode()); |
673 | 673 | |
674 | - if (! on_test()) { |
|
674 | + if (!on_test()) { |
|
675 | 675 | // @codeCoverageIgnoreStart |
676 | 676 | if (ob_get_level() > 0) { |
677 | 677 | ob_end_flush(); |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | ob_end_flush(); // @codeCoverageIgnore |
684 | 684 | } |
685 | 685 | |
686 | - throw PageNotFoundException::pageNotFound(! on_prod() || is_cli() ? $e->getMessage() : ''); |
|
686 | + throw PageNotFoundException::pageNotFound(!on_prod() || is_cli() ? $e->getMessage() : ''); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | public function storePreviousURL($uri) |
739 | 739 | { |
740 | 740 | // Ignorer les requêtes CLI |
741 | - if (is_cli() && ! on_test()) { |
|
741 | + if (is_cli() && !on_test()) { |
|
742 | 742 | return; // @codeCoverageIgnore |
743 | 743 | } |
744 | 744 | |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | ]); |
846 | 846 | |
847 | 847 | $middlewaresFile = CONFIG_PATH . 'middlewares.php'; |
848 | - if (file_exists($middlewaresFile) && ! in_array($middlewaresFile, get_included_files(), true)) { |
|
848 | + if (file_exists($middlewaresFile) && !in_array($middlewaresFile, get_included_files(), true)) { |
|
849 | 849 | $middleware = require $middlewaresFile; |
850 | 850 | if (is_callable($middleware)) { |
851 | 851 | $middleware($this->middleware, $this->request); |
@@ -861,11 +861,11 @@ discard block |
||
861 | 861 | */ |
862 | 862 | private function spoofRequestMethod(): callable |
863 | 863 | { |
864 | - return static function (ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
864 | + return static function(ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
865 | 865 | $post = $request->getParsedBody(); |
866 | 866 | |
867 | 867 | // Ne fonctionne qu'avec les formulaires POST |
868 | - if (strtoupper($request->getMethod()) === 'POST' && ! empty($post['_method'])) { |
|
868 | + if (strtoupper($request->getMethod()) === 'POST' && !empty($post['_method'])) { |
|
869 | 869 | // Accepte seulement PUT, PATCH, DELETE |
870 | 870 | if (in_array(strtoupper($post['_method']), ['PUT', 'PATCH', 'DELETE'], true)) { |
871 | 871 | $request = $request->withMethod($post['_method']); |
@@ -880,15 +880,15 @@ discard block |
||
880 | 880 | { |
881 | 881 | $_this = $this; |
882 | 882 | |
883 | - return static function (ServerRequestInterface $request, ResponseInterface $response, callable $next) use ($_this): ResponseInterface { |
|
883 | + return static function(ServerRequestInterface $request, ResponseInterface $response, callable $next) use ($_this): ResponseInterface { |
|
884 | 884 | try { |
885 | 885 | $returned = $_this->startController($request, $response); |
886 | 886 | |
887 | 887 | // Closure controller has run in startController(). |
888 | - if (! is_callable($_this->controller)) { |
|
888 | + if (!is_callable($_this->controller)) { |
|
889 | 889 | $controller = $_this->createController($request, $response); |
890 | 890 | |
891 | - if (! method_exists($controller, '_remap') && ! is_callable([$controller, $_this->method], false)) { |
|
891 | + if (!method_exists($controller, '_remap') && !is_callable([$controller, $_this->method], false)) { |
|
892 | 892 | throw PageNotFoundException::methodNotFound($_this->method); |
893 | 893 | } |
894 | 894 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | public function __construct(?Router $router = null) |
25 | 25 | { |
26 | - $this->router = $router ?? Services::router(); |
|
26 | + $this->router = $router ?? Services::router(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | public function __construct(private string $namespace) |
28 | 28 | { |
29 | - $this->locator = Services::locator(); |
|
29 | + $this->locator = Services::locator(); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -53,15 +53,15 @@ |
||
53 | 53 | |
54 | 54 | $viewer->setData($data)->setOptions($options); |
55 | 55 | |
56 | - if (! empty($this->layout) && is_string($this->layout)) { |
|
56 | + if (!empty($this->layout) && is_string($this->layout)) { |
|
57 | 57 | $viewer->setLayout($this->layout); |
58 | 58 | } |
59 | 59 | |
60 | - if (! empty($this->viewDatas) && is_array($this->viewDatas)) { |
|
60 | + if (!empty($this->viewDatas) && is_array($this->viewDatas)) { |
|
61 | 61 | $viewer->addData($this->viewDatas); |
62 | 62 | } |
63 | 63 | |
64 | - if (! is_string($controllerName = Dispatcher::getController(false))) { |
|
64 | + if (!is_string($controllerName = Dispatcher::getController(false))) { |
|
65 | 65 | $controllerName = static::class; |
66 | 66 | } |
67 | 67 |