@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | defined('DS') || define('DS', DIRECTORY_SEPARATOR); |
17 | 17 | |
18 | 18 | // Se rassurer que le dossier courant pointe sur le dossier du front controller |
19 | -if (! defined('TEST_PATH')) { |
|
19 | +if (!defined('TEST_PATH')) { |
|
20 | 20 | // On doit aussi verifier qu'on n'est pas en phase de test, sinon khalan ne trouvera pas le dossier des specs |
21 | 21 | chdir(WEBROOT); |
22 | 22 | } |
23 | 23 | |
24 | -return function (array $paths, string $paths_config_file, bool $is_cli) { |
|
24 | +return function(array $paths, string $paths_config_file, bool $is_cli) { |
|
25 | 25 | // Le chemin d'accès vers le dossier de l'application |
26 | 26 | if (is_dir($paths['app'])) { |
27 | 27 | if (($_temp = realpath($paths['app'])) !== false) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $app = new Application(); |
105 | 105 | $app->init(); |
106 | 106 | |
107 | - if (! $is_cli) { |
|
107 | + if (!$is_cli) { |
|
108 | 108 | $app->run(); |
109 | 109 | } |
110 | 110 | }; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | // ================================= ================================= // |
27 | 27 | |
28 | -if (! function_exists('site_url')) { |
|
28 | +if (!function_exists('site_url')) { |
|
29 | 29 | /** |
30 | 30 | * Renvoie une URL de site telle que définie par la configuration de l'application. |
31 | 31 | * |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | -if (! function_exists('base_url')) { |
|
52 | +if (!function_exists('base_url')) { |
|
53 | 53 | /** |
54 | 54 | * Renvoie l'URL de base telle que définie par la configuration de l'application. |
55 | 55 | * Les URL de base sont des URL de site coupées sans la page d'index. |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | -if (! function_exists('current_url')) { |
|
71 | +if (!function_exists('current_url')) { |
|
72 | 72 | /** |
73 | 73 | * Renvoie l'URL complète (y compris les segments) de la page où cette fonction est placée |
74 | 74 | * |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | -if (! function_exists('previous_url')) { |
|
98 | +if (!function_exists('previous_url')) { |
|
99 | 99 | /** |
100 | 100 | * Renvoie l'URL précédente sur laquelle se trouvait le visiteur actuel. Pour des raisons de sécurité |
101 | 101 | * nous vérifions d'abord une variable de session enregistrée, si elle existe, et l'utilisons. |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | -if (! function_exists('uri_string')) { |
|
118 | +if (!function_exists('uri_string')) { |
|
119 | 119 | /** |
120 | 120 | * Renvoie la partie chemin de l'URL actuelle |
121 | 121 | * |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | -if (! function_exists('index_page')) { |
|
132 | +if (!function_exists('index_page')) { |
|
133 | 133 | /** |
134 | 134 | * Renvoie la "index_page" de votre fichier de configuration |
135 | 135 | */ |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | -if (! function_exists('anchor')) { |
|
142 | +if (!function_exists('anchor')) { |
|
143 | 143 | /** |
144 | 144 | * Crée une ancre basée sur l'URL locale. |
145 | 145 | * |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | -if (! function_exists('anchor_popup')) { |
|
167 | +if (!function_exists('anchor_popup')) { |
|
168 | 168 | /** |
169 | 169 | * Lien d'ancrage - Version contextuelle |
170 | 170 | * |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | return '<a href="' . $siteUrl . '" onclick="window.open(\'' . $siteUrl . "', '_blank'); return false;\">" . $title . '</a>'; |
188 | 188 | } |
189 | 189 | |
190 | - if (! is_array($attributes)) { |
|
190 | + if (!is_array($attributes)) { |
|
191 | 191 | $attributes = [$attributes]; |
192 | 192 | |
193 | 193 | // Ref: http://www.w3schools.com/jsref/met_win_open.asp |
194 | 194 | $windowName = '_blank'; |
195 | - } elseif (! empty($attributes['window_name'])) { |
|
195 | + } elseif (!empty($attributes['window_name'])) { |
|
196 | 196 | $windowName = $attributes['window_name']; |
197 | 197 | unset($attributes['window_name']); |
198 | 198 | } else { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | -if (! function_exists('mailto')) { |
|
215 | +if (!function_exists('mailto')) { |
|
216 | 216 | /** |
217 | 217 | * Lien Mailto |
218 | 218 | * |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | -if (! function_exists('safe_mailto')) { |
|
232 | +if (!function_exists('safe_mailto')) { |
|
233 | 233 | /** |
234 | 234 | * Lien Mailto codé |
235 | 235 | * |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | -if (! function_exists('auto_link')) { |
|
323 | +if (!function_exists('auto_link')) { |
|
324 | 324 | /** |
325 | 325 | * Lien automatique |
326 | 326 | * |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | function auto_link(string $str, string $type = 'both', bool $popup = false): string |
336 | 336 | { |
337 | 337 | // Recherche et remplace tous les URLs. |
338 | - if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
338 | + if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE|PREG_SET_ORDER)) { |
|
339 | 339 | // Définissez notre HTML cible si vous utilisez des liens contextuels. |
340 | 340 | $target = ($popup) ? ' target="_blank"' : ''; |
341 | 341 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | -if (! function_exists('prep_url')) { |
|
369 | +if (!function_exists('prep_url')) { |
|
370 | 370 | /** |
371 | 371 | * Ajoute simplement la partie http:// ou https:// si aucun schéma n'est inclus. |
372 | 372 | * |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | -if (! function_exists('url_title')) { |
|
394 | +if (!function_exists('url_title')) { |
|
395 | 395 | /** |
396 | 396 | * Créer un titre d'URL |
397 | 397 | * |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | -if (! function_exists('mb_url_title')) { |
|
430 | +if (!function_exists('mb_url_title')) { |
|
431 | 431 | /** |
432 | 432 | * Créer un titre d'URL qui prend en compte les caractères accentués |
433 | 433 | * |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | } |
447 | 447 | } |
448 | 448 | |
449 | -if (! function_exists('url_to')) { |
|
449 | +if (!function_exists('url_to')) { |
|
450 | 450 | /** |
451 | 451 | * Obtenir l'URL complète et absolue d'une méthode de contrôleur |
452 | 452 | * (avec arguments supplémentaires) |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | */ |
460 | 460 | function url_to(string $controller, ...$args): string |
461 | 461 | { |
462 | - if (! $route = route($controller, ...$args)) { |
|
462 | + if (!$route = route($controller, ...$args)) { |
|
463 | 463 | $explode = explode('::', $controller); |
464 | 464 | |
465 | 465 | if (isset($explode[1])) { |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | -if (! function_exists('route')) { |
|
476 | +if (!function_exists('route')) { |
|
477 | 477 | /** |
478 | 478 | * Tente de rechercher une route en fonction de sa destination. |
479 | 479 | * |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
488 | -if (! function_exists('url_is')) { |
|
488 | +if (!function_exists('url_is')) { |
|
489 | 489 | /** |
490 | 490 | * Détermine si le chemin d'URL actuel contient le chemin donné. |
491 | 491 | * Il peut contenir un caractère générique (*) qui autorisera tout caractère valide. |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | -if (! function_exists('link_active')) { |
|
506 | +if (!function_exists('link_active')) { |
|
507 | 507 | /** |
508 | 508 | * Lien actif dans la navbar |
509 | 509 | * Un peut comme le router-active-link de vuejs |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | return $active_class; |
528 | 528 | } |
529 | 529 | |
530 | - if (! $exact && preg_match('#^' . $path . '/?#i', $current_section)) { |
|
530 | + if (!$exact && preg_match('#^' . $path . '/?#i', $current_section)) { |
|
531 | 531 | return $active_class; |
532 | 532 | } |
533 | 533 | |
@@ -539,14 +539,14 @@ discard block |
||
539 | 539 | } |
540 | 540 | } |
541 | 541 | |
542 | -if (! function_exists('clean_url')) { |
|
542 | +if (!function_exists('clean_url')) { |
|
543 | 543 | function clean_url(string $url): string |
544 | 544 | { |
545 | 545 | return Helpers::cleanUrl($url); |
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
549 | -if (! function_exists('is_absolute_link')) { |
|
549 | +if (!function_exists('is_absolute_link')) { |
|
550 | 550 | /** |
551 | 551 | * Verifies si un chemin donnée est une url absolue ou relative |
552 | 552 | */ |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $this->adapter->addData($data, $context); |
158 | 158 | |
159 | - if (! array_key_exists('errors', $this->getData())) { |
|
159 | + if (!array_key_exists('errors', $this->getData())) { |
|
160 | 160 | $this->setValidationErrors(); |
161 | 161 | } |
162 | 162 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | if (is_string($errors)) { |
186 | 186 | $errors = ['default' => $errors]; |
187 | 187 | } |
188 | - if (! ($errors instanceof ErrorBag)) { |
|
188 | + if (!($errors instanceof ErrorBag)) { |
|
189 | 189 | $errors = new ErrorBag($errors); |
190 | 190 | } |
191 | 191 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | $this->adapter->setData($data, $context); |
227 | 227 | |
228 | - if (! array_key_exists('errors', $this->getData())) { |
|
228 | + if (!array_key_exists('errors', $this->getData())) { |
|
229 | 229 | $this->setValidationErrors(); |
230 | 230 | } |
231 | 231 | |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function setAdapter(string $adapter, array $config = []): self |
267 | 267 | { |
268 | - if (! array_key_exists($adapter, self::$validAdapters)) { |
|
268 | + if (!array_key_exists($adapter, self::$validAdapters)) { |
|
269 | 269 | $adapter = 'native'; |
270 | 270 | } |
271 | - if (empty($this->config['adapters']) || ! is_array($this->config['adapters'])) { |
|
271 | + if (empty($this->config['adapters']) || !is_array($this->config['adapters'])) { |
|
272 | 272 | $this->config['adapters'] = []; |
273 | 273 | } |
274 | 274 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | protected function decorate(string $output): string |
326 | 326 | { |
327 | 327 | foreach ($this->config['decorators'] as $decorator) { |
328 | - if (! is_subclass_of($decorator, ViewDecoratorInterface::class)) { |
|
328 | + if (!is_subclass_of($decorator, ViewDecoratorInterface::class)) { |
|
329 | 329 | throw ViewException::invalidDecorator($decorator); |
330 | 330 | } |
331 | 331 |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class {class} extends {extends} |
8 | 8 | { |
9 | -<?php if (! empty($invokable)): ?> |
|
9 | +<?php if (!empty($invokable)): ?> |
|
10 | 10 | /** |
11 | 11 | * Traitement |
12 | 12 | * |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | return trim(config()->get('app.base_url'), '/'); |
83 | 83 | } |
84 | 84 | |
85 | - /** |
|
85 | + /** |
|
86 | 86 | * Obtient le schéma et l'hôte HTTP. |
87 | 87 | * |
88 | 88 | * Si l'URL a été appelée avec une authentification de base, l'utilisateur et |
89 | - * le mot de passe ne sont pas ajoutés à la chaîne générée. |
|
89 | + * le mot de passe ne sont pas ajoutés à la chaîne générée. |
|
90 | 90 | */ |
91 | 91 | public function getSchemeAndHttpHost(): string |
92 | 92 | { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | return collect($patterns)->contains(fn ($pattern) => Text::is($pattern, $path)); |
199 | 199 | } |
200 | 200 | |
201 | - /** |
|
201 | + /** |
|
202 | 202 | * Déterminez si le nom de la route correspond à un modèle donné. |
203 | 203 | * |
204 | 204 | * @param mixed ...$patterns |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function isMethod(array|string $methods): bool |
216 | 216 | { |
217 | - foreach ((array) $methods as $method) { |
|
218 | - if (strtolower($method) === strtolower($this->method())) { |
|
219 | - return true; |
|
220 | - } |
|
221 | - } |
|
217 | + foreach ((array) $methods as $method) { |
|
218 | + if (strtolower($method) === strtolower($this->method())) { |
|
219 | + return true; |
|
220 | + } |
|
221 | + } |
|
222 | 222 | |
223 | 223 | return false; |
224 | 224 | } |
@@ -349,15 +349,15 @@ discard block |
||
349 | 349 | return $this->getUri()->getScheme(); |
350 | 350 | } |
351 | 351 | |
352 | - public function getHost(): string |
|
353 | - { |
|
354 | - return $this->getUri()->getHost(); |
|
355 | - } |
|
352 | + public function getHost(): string |
|
353 | + { |
|
354 | + return $this->getUri()->getHost(); |
|
355 | + } |
|
356 | 356 | |
357 | - public function getPort(): int |
|
358 | - { |
|
359 | - return $this->getUri()->getPort() ?? 80; |
|
360 | - } |
|
357 | + public function getPort(): int |
|
358 | + { |
|
359 | + return $this->getUri()->getPort() ?? 80; |
|
360 | + } |
|
361 | 361 | |
362 | 362 | /** |
363 | 363 | * {@inheritDoc} |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function getSchemeAndHttpHost(): string |
92 | 92 | { |
93 | - return $this->getScheme().'://'.$this->getHttpHost(); |
|
93 | + return $this->getScheme() . '://' . $this->getHttpHost(); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | return $this->getHost(); |
108 | 108 | } |
109 | 109 | |
110 | - return $this->getHost().':'.$port; |
|
110 | + return $this->getHost() . ':' . $port; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function fullUrl(): string |
125 | 125 | { |
126 | - if (! empty($query = $this->getEnv('QUERY_STRING'))) { |
|
126 | + if (!empty($query = $this->getEnv('QUERY_STRING'))) { |
|
127 | 127 | return $this->url() . '?' . $query; |
128 | 128 | } |
129 | 129 |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | */ |
41 | 41 | protected function view(string $view, ?array $data = [], ?array $options = []): View |
42 | 42 | { |
43 | - $path = ''; |
|
44 | - $data = (array) $data; |
|
45 | - $options = (array) $options; |
|
43 | + $path = ''; |
|
44 | + $data = (array) $data; |
|
45 | + $options = (array) $options; |
|
46 | 46 | |
47 | 47 | // N'est-il pas namespaced ? on cherche le dossier en fonction du controleur |
48 | 48 | if (! str_contains($view, '\\')) { |
@@ -65,17 +65,17 @@ discard block |
||
65 | 65 | $viewer->addData($this->viewDatas); |
66 | 66 | } |
67 | 67 | |
68 | - if (empty($data['title'])) { |
|
69 | - if (! is_string($controllerName = Dispatcher::getController(false))) { |
|
70 | - $controllerName = static::class; |
|
71 | - } |
|
72 | - $controllerName = str_ireplace(['App\Controllers', 'Controller'], '', $controllerName); |
|
68 | + if (empty($data['title'])) { |
|
69 | + if (! is_string($controllerName = Dispatcher::getController(false))) { |
|
70 | + $controllerName = static::class; |
|
71 | + } |
|
72 | + $controllerName = str_ireplace(['App\Controllers', 'Controller'], '', $controllerName); |
|
73 | 73 | |
74 | - $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); |
|
75 | - $func = isset($dbt[1]['function']) ? $dbt[1]['function'] : Dispatcher::getMethod(); |
|
74 | + $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); |
|
75 | + $func = isset($dbt[1]['function']) ? $dbt[1]['function'] : Dispatcher::getMethod(); |
|
76 | 76 | |
77 | - $viewer->setVar('title', $controllerName . ' - ' . $func); |
|
78 | - } |
|
77 | + $viewer->setVar('title', $controllerName . ' - ' . $func); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | return $viewer->display($path . $view); |
81 | 81 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | final protected function render(array|string $view = '', ?array $data = [], ?array $options = []): ResponseInterface |
87 | 87 | { |
88 | 88 | if (is_array($view)) { |
89 | - $data = $view; |
|
90 | - $options = $data; |
|
89 | + $data = $view; |
|
90 | + $options = $data; |
|
91 | 91 | |
92 | 92 | $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); |
93 | 93 | $view = isset($dbt[1]['function']) ? $dbt[1]['function'] : ''; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $options = (array) $options; |
46 | 46 | |
47 | 47 | // N'est-il pas namespaced ? on cherche le dossier en fonction du controleur |
48 | - if (! str_contains($view, '\\')) { |
|
48 | + if (!str_contains($view, '\\')) { |
|
49 | 49 | $reflection = new ReflectionClass(static::class); |
50 | 50 | ['dirname' => $dirname, 'filename' => $filename] = pathinfo($reflection->getFileName()); |
51 | 51 | $dirname = str_ireplace('Controllers', 'Views', $dirname); |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | |
58 | 58 | $viewer->setData($data)->setOptions($options); |
59 | 59 | |
60 | - if (! empty($this->layout) && is_string($this->layout)) { |
|
60 | + if (!empty($this->layout) && is_string($this->layout)) { |
|
61 | 61 | $viewer->setLayout($this->layout); |
62 | 62 | } |
63 | 63 | |
64 | - if (! empty($this->viewDatas) && is_array($this->viewDatas)) { |
|
64 | + if (!empty($this->viewDatas) && is_array($this->viewDatas)) { |
|
65 | 65 | $viewer->addData($this->viewDatas); |
66 | 66 | } |
67 | 67 | |
68 | 68 | if (empty($data['title'])) { |
69 | - if (! is_string($controllerName = Dispatcher::getController(false))) { |
|
69 | + if (!is_string($controllerName = Dispatcher::getController(false))) { |
|
70 | 70 | $controllerName = static::class; |
71 | 71 | } |
72 | 72 | $controllerName = str_ireplace(['App\Controllers', 'Controller'], '', $controllerName); |