@@ -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 |
@@ -799,9 +799,9 @@ |
||
799 | 799 | return $returned; |
800 | 800 | } |
801 | 801 | |
802 | - if ($returned instanceof Responsable) { |
|
803 | - return $returned->toResponse($this->request); |
|
804 | - } |
|
802 | + if ($returned instanceof Responsable) { |
|
803 | + return $returned->toResponse($this->request); |
|
804 | + } |
|
805 | 805 | |
806 | 806 | if (is_object($returned)) { |
807 | 807 | if (method_exists($returned, '__toString')) { |
@@ -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 |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | return $models; |
74 | 74 | } |
75 | 75 | |
76 | - if (! self::isLoaded('models', $model)) { |
|
76 | + if (!self::isLoaded('models', $model)) { |
|
77 | 77 | self::loaded('models', $model, FileLocator::model($model, $connection)); |
78 | 78 | } |
79 | 79 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | private static function isLoaded(string $module, $element): bool |
89 | 89 | { |
90 | - if (! isset(self::$loads[$module]) || ! is_array(self::$loads[$module])) { |
|
90 | + if (!isset(self::$loads[$module]) || !is_array(self::$loads[$module])) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public static function init() |
38 | 38 | { |
39 | - if (! class_exists('Whoops\Run')) { |
|
39 | + if (!class_exists('Whoops\Run')) { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $whoops = new Run(); |
44 | 44 | |
45 | - if (! is_online()) { |
|
45 | + if (!is_online()) { |
|
46 | 46 | if (Misc::isCommandLine()) { |
47 | 47 | $whoops->pushHandler(new PlainTextHandler()); |
48 | 48 | } elseif (Misc::isAjaxRequest()) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * On log toutes les erreurs |
57 | 57 | */ |
58 | - $whoops->pushHandler(static function (Throwable $exception, Inspector $inspector, RunInterface $run) { |
|
58 | + $whoops->pushHandler(static function(Throwable $exception, Inspector $inspector, RunInterface $run) { |
|
59 | 59 | Services::logger()->error($exception); |
60 | 60 | |
61 | 61 | return Handler::DONE; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | // ================================= ================================= // |
26 | 26 | |
27 | -if (! function_exists('site_url')) { |
|
27 | +if (!function_exists('site_url')) { |
|
28 | 28 | /** |
29 | 29 | * Renvoie une URL de site telle que définie par la configuration de l'application. |
30 | 30 | * |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | -if (! function_exists('base_url')) { |
|
51 | +if (!function_exists('base_url')) { |
|
52 | 52 | /** |
53 | 53 | * Renvoie l'URL de base telle que définie par la configuration de l'application. |
54 | 54 | * Les URL de base sont des URL de site coupées sans la page d'index. |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | -if (! function_exists('current_url')) { |
|
70 | +if (!function_exists('current_url')) { |
|
71 | 71 | /** |
72 | 72 | * Renvoie l'URL complète (y compris les segments) de la page où cette fonction est placée |
73 | 73 | * |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -if (! function_exists('previous_url')) { |
|
97 | +if (!function_exists('previous_url')) { |
|
98 | 98 | /** |
99 | 99 | * Renvoie l'URL précédente sur laquelle se trouvait le visiteur actuel. Pour des raisons de sécurité |
100 | 100 | * nous vérifions d'abord une variable de session enregistrée, si elle existe, et l'utilisons. |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | -if (! function_exists('uri_string')) { |
|
122 | +if (!function_exists('uri_string')) { |
|
123 | 123 | /** |
124 | 124 | * Renvoie la partie chemin de l'URL actuelle |
125 | 125 | * |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | -if (! function_exists('index_page')) { |
|
136 | +if (!function_exists('index_page')) { |
|
137 | 137 | /** |
138 | 138 | * Renvoie la "index_page" de votre fichier de configuration |
139 | 139 | */ |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | -if (! function_exists('anchor')) { |
|
146 | +if (!function_exists('anchor')) { |
|
147 | 147 | /** |
148 | 148 | * Crée une ancre basée sur l'URL locale. |
149 | 149 | * |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | -if (! function_exists('anchor_popup')) { |
|
171 | +if (!function_exists('anchor_popup')) { |
|
172 | 172 | /** |
173 | 173 | * Lien d'ancrage - Version contextuelle |
174 | 174 | * |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | return '<a href="' . $siteUrl . '" onclick="window.open(\'' . $siteUrl . "', '_blank'); return false;\">" . $title . '</a>'; |
192 | 192 | } |
193 | 193 | |
194 | - if (! is_array($attributes)) { |
|
194 | + if (!is_array($attributes)) { |
|
195 | 195 | $attributes = [$attributes]; |
196 | 196 | |
197 | 197 | // Ref: http://www.w3schools.com/jsref/met_win_open.asp |
198 | 198 | $windowName = '_blank'; |
199 | - } elseif (! empty($attributes['window_name'])) { |
|
199 | + } elseif (!empty($attributes['window_name'])) { |
|
200 | 200 | $windowName = $attributes['window_name']; |
201 | 201 | unset($attributes['window_name']); |
202 | 202 | } else { |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | -if (! function_exists('mailto')) { |
|
219 | +if (!function_exists('mailto')) { |
|
220 | 220 | /** |
221 | 221 | * Lien Mailto |
222 | 222 | * |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | -if (! function_exists('safe_mailto')) { |
|
236 | +if (!function_exists('safe_mailto')) { |
|
237 | 237 | /** |
238 | 238 | * Lien Mailto codé |
239 | 239 | * |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | -if (! function_exists('auto_link')) { |
|
325 | +if (!function_exists('auto_link')) { |
|
326 | 326 | /** |
327 | 327 | * Lien automatique |
328 | 328 | * |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | function auto_link(string $str, string $type = 'both', bool $popup = false): string |
338 | 338 | { |
339 | 339 | // Recherche et remplace tous les URLs. |
340 | - if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
340 | + if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE|PREG_SET_ORDER)) { |
|
341 | 341 | // Définissez notre HTML cible si vous utilisez des liens contextuels. |
342 | 342 | $target = ($popup) ? ' target="_blank"' : ''; |
343 | 343 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
371 | -if (! function_exists('prep_url')) { |
|
371 | +if (!function_exists('prep_url')) { |
|
372 | 372 | /** |
373 | 373 | * Ajoute simplement la partie http:// ou https:// si aucun schéma n'est inclus. |
374 | 374 | * |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | -if (! function_exists('url_title')) { |
|
396 | +if (!function_exists('url_title')) { |
|
397 | 397 | /** |
398 | 398 | * Créer un titre d'URL |
399 | 399 | * |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | -if (! function_exists('mb_url_title')) { |
|
432 | +if (!function_exists('mb_url_title')) { |
|
433 | 433 | /** |
434 | 434 | * Créer un titre d'URL qui prend en compte les caractères accentués |
435 | 435 | * |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | -if (! function_exists('url_to')) { |
|
451 | +if (!function_exists('url_to')) { |
|
452 | 452 | /** |
453 | 453 | * Obtenir l'URL complète et absolue d'une méthode de contrôleur |
454 | 454 | * (avec arguments supplémentaires) |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | */ |
462 | 462 | function url_to(string $controller, ...$args): string |
463 | 463 | { |
464 | - if (! $route = link_to($controller, ...$args)) { |
|
464 | + if (!$route = link_to($controller, ...$args)) { |
|
465 | 465 | $explode = explode('::', $controller); |
466 | 466 | |
467 | 467 | if (isset($explode[1])) { |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | } |
476 | 476 | } |
477 | 477 | |
478 | -if (! function_exists('url_is')) { |
|
478 | +if (!function_exists('url_is')) { |
|
479 | 479 | /** |
480 | 480 | * Détermine si le chemin d'URL actuel contient le chemin donné. |
481 | 481 | * Il peut contenir un caractère générique (*) qui autorisera tout caractère valide. |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | } |
494 | 494 | } |
495 | 495 | |
496 | -if (! function_exists('link_active')) { |
|
496 | +if (!function_exists('link_active')) { |
|
497 | 497 | /** |
498 | 498 | * Lien actif dans la navbar |
499 | 499 | * Un peut comme le router-active-link de vuejs |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | return $active_class; |
509 | 509 | } |
510 | 510 | |
511 | - if (! $exact && preg_match('#^' . $path . '/?#i', $current_section)) { |
|
511 | + if (!$exact && preg_match('#^' . $path . '/?#i', $current_section)) { |
|
512 | 512 | return $active_class; |
513 | 513 | } |
514 | 514 | |
@@ -520,14 +520,14 @@ discard block |
||
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | -if (! function_exists('clean_url')) { |
|
523 | +if (!function_exists('clean_url')) { |
|
524 | 524 | function clean_url(string $url): string |
525 | 525 | { |
526 | 526 | return Helpers::cleanUrl($url); |
527 | 527 | } |
528 | 528 | } |
529 | 529 | |
530 | -if (! function_exists('is_absolute_link')) { |
|
530 | +if (!function_exists('is_absolute_link')) { |
|
531 | 531 | /** |
532 | 532 | * Verifies si un chemin donnée est une url absolue ou relative |
533 | 533 | */ |
@@ -477,7 +477,7 @@ |
||
477 | 477 | $name = array_shift($arguments); |
478 | 478 | |
479 | 479 | if (empty(static::$instances[$name])) { |
480 | - if (! empty($arguments)) { |
|
480 | + if (!empty($arguments)) { |
|
481 | 481 | static::$instances[$name] = static::factory($name, $arguments); |
482 | 482 | } else { |
483 | 483 | static::$instances[$name] = static::injector()->get($name); |
@@ -125,17 +125,17 @@ |
||
125 | 125 | return static::$instances[Cache::class] = static::factory(Cache::class, compact('config')); |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * La clase Config offre une api fluide por gerer les configurations de l'application |
|
130 | - */ |
|
131 | - public static function config(bool $shared = true): Config |
|
132 | - { |
|
133 | - if (true === $shared && isset(static::$instances[Config::class])) { |
|
128 | + /** |
|
129 | + * La clase Config offre une api fluide por gerer les configurations de l'application |
|
130 | + */ |
|
131 | + public static function config(bool $shared = true): Config |
|
132 | + { |
|
133 | + if (true === $shared && isset(static::$instances[Config::class])) { |
|
134 | 134 | return static::$instances[Config::class]; |
135 | 135 | } |
136 | 136 | |
137 | - return static::$instances[Config::class] = new Config(); |
|
138 | - } |
|
137 | + return static::$instances[Config::class] = new Config(); |
|
138 | + } |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Émetteur de réponse au client |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | } |
198 | 198 | |
199 | 199 | // Les providers par défaut du système doivent être ajouté en premier pour que les autres puisse les surcharger |
200 | - if (! empty($systemProvider)) { |
|
200 | + if (!empty($systemProvider)) { |
|
201 | 201 | $providers[] = $systemProvider; |
202 | 202 | } |
203 | 203 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $providers = [...$providers, ...$localIncludes]; |
206 | 206 | |
207 | 207 | // Enfin ceux de l'application doivent remplacer tous les autres |
208 | - if (! empty($appProvider)) { |
|
208 | + if (!empty($appProvider)) { |
|
209 | 209 | $providers[] = $appProvider; |
210 | 210 | } |
211 | 211 |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | // Essayez plusieurs fois en cas de mèches persistantes |
128 | 128 | $attempts = 10; |
129 | 129 | |
130 | - while ((bool) $attempts && ! delete_files($directory, true, false, true)) { |
|
130 | + while ((bool) $attempts && !delete_files($directory, true, false, true)) { |
|
131 | 131 | // @codeCoverageIgnoreStart |
132 | 132 | $attempts--; |
133 | 133 | usleep(100000); // .1s |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | // Rechercher un fichier existant |
468 | 468 | if (file_exists($to)) { |
469 | 469 | // S'il n'est pas remplacé ou si les fichiers sont identiques, envisagez de réussir |
470 | - if (! $replace || same_file($from, $to)) { |
|
470 | + if (!$replace || same_file($from, $to)) { |
|
471 | 471 | return; |
472 | 472 | } |
473 | 473 | |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | } |
482 | 482 | |
483 | 483 | // Assurez-vous que le répertoire existe |
484 | - if (! is_dir($directory = pathinfo($to, PATHINFO_DIRNAME))) { |
|
484 | + if (!is_dir($directory = pathinfo($to, PATHINFO_DIRNAME))) { |
|
485 | 485 | mkdir($directory, 0775, true); |
486 | 486 | } |
487 | 487 |
@@ -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 | |
@@ -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 | |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | |
1394 | 1394 | private function getControllerName(Closure|string $handler): ?string |
1395 | 1395 | { |
1396 | - if (! is_string($handler)) { |
|
1396 | + if (!is_string($handler)) { |
|
1397 | 1397 | return null; |
1398 | 1398 | } |
1399 | 1399 | |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | |
1459 | 1459 | // Vérifier les paramètres régionaux non valides |
1460 | 1460 | if ($locale !== null) { |
1461 | - if (! in_array($locale, config('app.supported_locales'), true)) { |
|
1461 | + if (!in_array($locale, config('app.supported_locales'), true)) { |
|
1462 | 1462 | $locale = null; |
1463 | 1463 | } |
1464 | 1464 | } |
@@ -754,51 +754,51 @@ discard block |
||
754 | 754 | |
755 | 755 | if (in_array('index', $methods, true)) { |
756 | 756 | $this->get($name, $newName . '::index', $options + [ |
757 | - 'as' => $name . '.index', |
|
758 | - ]); |
|
757 | + 'as' => $name . '.index', |
|
758 | + ]); |
|
759 | 759 | } |
760 | 760 | if (in_array('new', $methods, true)) { |
761 | 761 | $this->get($name . '/new', $newName . '::new', $options + [ |
762 | - 'as' => $name . '.new', |
|
763 | - ]); |
|
762 | + 'as' => $name . '.new', |
|
763 | + ]); |
|
764 | 764 | } |
765 | 765 | if (in_array('edit', $methods, true)) { |
766 | 766 | $this->get($name . '/' . $id . '/edit', $newName . '::edit/$1', $options + [ |
767 | - 'as' => $name . '.edit', |
|
768 | - ]); |
|
767 | + 'as' => $name . '.edit', |
|
768 | + ]); |
|
769 | 769 | } |
770 | 770 | if (in_array('show', $methods, true)) { |
771 | 771 | $this->get($name . '/' . $id, $newName . '::show/$1', $options + [ |
772 | - 'as' => $name . '.show', |
|
773 | - ]); |
|
772 | + 'as' => $name . '.show', |
|
773 | + ]); |
|
774 | 774 | } |
775 | 775 | if (in_array('create', $methods, true)) { |
776 | 776 | $this->post($name, $newName . '::create', $options + [ |
777 | - 'as' => $name . '.create', |
|
778 | - ]); |
|
777 | + 'as' => $name . '.create', |
|
778 | + ]); |
|
779 | 779 | } |
780 | 780 | if (in_array('update', $methods, true)) { |
781 | - $this->match(['put', 'patch'], $name . '/' . $id, $newName . '::update/$1', $options + [ |
|
782 | - 'as' => $name . '.update', |
|
783 | - ]); |
|
781 | + $this->match(['put', 'patch'], $name . '/' . $id, $newName . '::update/$1', $options + [ |
|
782 | + 'as' => $name . '.update', |
|
783 | + ]); |
|
784 | 784 | } |
785 | 785 | if (in_array('delete', $methods, true)) { |
786 | 786 | $this->delete($name . '/' . $id, $newName . '::delete/$1', $options + [ |
787 | - 'as' => $name . '.delete', |
|
788 | - ]); |
|
787 | + 'as' => $name . '.delete', |
|
788 | + ]); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | // Websafe ? la suppression doit être vérifiée avant la mise à jour en raison du nom de la méthode |
792 | 792 | if (isset($options['websafe'])) { |
793 | 793 | if (in_array('delete', $methods, true)) { |
794 | 794 | $this->post($name . '/' . $id . '/delete', $newName . '::delete/$1', $options + [ |
795 | - 'as' => $name . '.websafe.delete', |
|
796 | - ]); |
|
795 | + 'as' => $name . '.websafe.delete', |
|
796 | + ]); |
|
797 | 797 | } |
798 | 798 | if (in_array('update', $methods, true)) { |
799 | 799 | $this->post($name . '/' . $id, $newName . '::update/$1', $options + [ |
800 | - 'as' => $name . '.websafe.update', |
|
801 | - ]); |
|
800 | + 'as' => $name . '.websafe.update', |
|
801 | + ]); |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
@@ -865,49 +865,49 @@ discard block |
||
865 | 865 | |
866 | 866 | if (in_array('index', $methods, true)) { |
867 | 867 | $this->get($name, $newName . '::index', $options + [ |
868 | - 'as' => $name . '.index', |
|
869 | - ]); |
|
868 | + 'as' => $name . '.index', |
|
869 | + ]); |
|
870 | 870 | } |
871 | 871 | if (in_array('show', $methods, true)) { |
872 | 872 | $this->get($name . '/show/' . $id, $newName . '::show/$1', $options + [ |
873 | - 'as' => $name . '.view' |
|
874 | - ]); |
|
875 | - $this->get($name . '/' . $id, $newName . '::show/$1', $options + [ |
|
876 | - 'as' => $name . '.show' |
|
877 | - ]); |
|
873 | + 'as' => $name . '.view' |
|
874 | + ]); |
|
875 | + $this->get($name . '/' . $id, $newName . '::show/$1', $options + [ |
|
876 | + 'as' => $name . '.show' |
|
877 | + ]); |
|
878 | 878 | } |
879 | 879 | if (in_array('new', $methods, true)) { |
880 | 880 | $this->get($name . '/new', $newName . '::new', $options + [ |
881 | - 'as' => $name . '.new' |
|
882 | - ]); |
|
881 | + 'as' => $name . '.new' |
|
882 | + ]); |
|
883 | 883 | } |
884 | 884 | if (in_array('create', $methods, true)) { |
885 | 885 | $this->post($name . '/create', $newName . '::create', $options + [ |
886 | - 'as' => $name . '.create' |
|
887 | - ]); |
|
888 | - $this->post($name, $newName . '::create', $options + [ |
|
889 | - 'as' => $name . '.store' |
|
890 | - ]); |
|
886 | + 'as' => $name . '.create' |
|
887 | + ]); |
|
888 | + $this->post($name, $newName . '::create', $options + [ |
|
889 | + 'as' => $name . '.store' |
|
890 | + ]); |
|
891 | 891 | } |
892 | 892 | if (in_array('edit', $methods, true)) { |
893 | 893 | $this->get($name . '/edit/' . $id, $newName . '::edit/$1', $options + [ |
894 | - 'as' => $name . '.edit' |
|
895 | - ]); |
|
894 | + 'as' => $name . '.edit' |
|
895 | + ]); |
|
896 | 896 | } |
897 | 897 | if (in_array('update', $methods, true)) { |
898 | 898 | $this->post($name . '/update/' . $id, $newName . '::update/$1', $options + [ |
899 | - 'as' => $name . '.update', |
|
900 | - ]); |
|
899 | + 'as' => $name . '.update', |
|
900 | + ]); |
|
901 | 901 | } |
902 | 902 | if (in_array('remove', $methods, true)) { |
903 | 903 | $this->get($name . '/remove/' . $id, $newName . '::remove/$1', $options + [ |
904 | - 'as' => $name . '.remove', |
|
905 | - ]); |
|
904 | + 'as' => $name . '.remove', |
|
905 | + ]); |
|
906 | 906 | } |
907 | 907 | if (in_array('delete', $methods, true)) { |
908 | 908 | $this->post($name . '/delete/' . $id, $newName . '::delete/$1', $options + [ |
909 | - 'as' => $name . '.delete', |
|
910 | - ]); |
|
909 | + 'as' => $name . '.delete', |
|
910 | + ]); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | return $this; |
@@ -1424,15 +1424,15 @@ discard block |
||
1424 | 1424 | return array_shift($host); |
1425 | 1425 | } |
1426 | 1426 | |
1427 | - /** |
|
1428 | - * Formate le nom des routes |
|
1429 | - */ |
|
1430 | - private function formatRouteName(string $name): string |
|
1431 | - { |
|
1432 | - $name = trim($name, '/'); |
|
1427 | + /** |
|
1428 | + * Formate le nom des routes |
|
1429 | + */ |
|
1430 | + private function formatRouteName(string $name): string |
|
1431 | + { |
|
1432 | + $name = trim($name, '/'); |
|
1433 | 1433 | |
1434 | - return strtolower(str_replace(['/', '\\', '_', '.', ' '], '.', $name)); |
|
1435 | - } |
|
1434 | + return strtolower(str_replace(['/', '\\', '_', '.', ' '], '.', $name)); |
|
1435 | + } |
|
1436 | 1436 | |
1437 | 1437 | private function getControllerName(Closure|string $handler): ?string |
1438 | 1438 | { |