@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | $this->collection->presenter($name, $this->attributes + $options); |
| 205 | 205 | |
| 206 | - $this->attributes = []; |
|
| 206 | + $this->attributes = []; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | { |
| 242 | 242 | $this->collection->resource($name, $this->attributes + $options); |
| 243 | 243 | |
| 244 | - $this->attributes = []; |
|
| 244 | + $this->attributes = []; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | $this->collection->{$method}($from, $to, $this->attributes + $options); |
| 291 | 291 | |
| 292 | - $this->attributes = []; |
|
| 292 | + $this->attributes = []; |
|
| 293 | 293 | |
| 294 | 294 | return $this; |
| 295 | 295 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | if (is_string($to)) { |
| 164 | 164 | $parts = explode('::', $to); |
| 165 | - } else if(is_array($to)) { |
|
| 165 | + } else if (is_array($to)) { |
|
| 166 | 166 | $parts = $to; |
| 167 | 167 | } else { |
| 168 | 168 | $parts = []; |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | private function attribute(string $key, $value): self |
| 315 | 315 | { |
| 316 | - if (! in_array($key, $this->allowedAttributes, true)) { |
|
| 316 | + if (!in_array($key, $this->allowedAttributes, true)) { |
|
| 317 | 317 | throw new InvalidArgumentException("L'attribute [{$key}] n'existe pas."); |
| 318 | 318 | } |
| 319 | 319 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | class UrlGenerator |
| 27 | 27 | { |
| 28 | - use Macroable; |
|
| 28 | + use Macroable; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * The forced URL root. |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function __construct(protected RouteCollectionInterface $routes, protected Request $request, protected ?string $assetRoot = null) |
| 92 | 92 | { |
| 93 | - $this->setRequest($request); |
|
| 93 | + $this->setRequest($request); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -241,18 +241,18 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | 243 | * Get the URL to a named route. |
| 244 | - * |
|
| 244 | + * |
|
| 245 | 245 | * @return string|false |
| 246 | 246 | */ |
| 247 | 247 | public function route(string $name, array $parameters = [], bool $absolute = true) |
| 248 | 248 | { |
| 249 | - $route = $this->routes->reverseRoute($name, ...$parameters); |
|
| 249 | + $route = $this->routes->reverseRoute($name, ...$parameters); |
|
| 250 | 250 | |
| 251 | 251 | if (! $route) { |
| 252 | 252 | throw HttpException::invalidRedirectRoute($route); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - return $absolute ? site_url($route) : $route; |
|
| 255 | + return $absolute ? site_url($route) : $route; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $this->cachedRoot = null; |
| 411 | 411 | $this->cachedScheme = null; |
| 412 | 412 | |
| 413 | - return $this; |
|
| 413 | + return $this; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | return call_user_func($this->sessionResolver); |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - return Services::session(); |
|
| 435 | + return Services::session(); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | [$path, $query] = $this->extractQueryString($path); |
| 164 | 164 | |
| 165 | 165 | return $this->format( |
| 166 | - $root, '/'.trim($path.'/'.$tail, '/') |
|
| 167 | - ).$query; |
|
| 166 | + $root, '/' . trim($path . '/' . $tail, '/') |
|
| 167 | + ) . $query; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | // for asset paths, but only for routes to endpoints in the application. |
| 190 | 190 | $root = $this->assetRoot ?: $this->formatRoot($this->formatScheme($secure)); |
| 191 | 191 | |
| 192 | - return $this->removeIndex($root).'/'.trim($path, '/'); |
|
| 192 | + return $this->removeIndex($root) . '/' . trim($path, '/'); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | // for asset paths, but only for routes to endpoints in the application. |
| 211 | 211 | $root = $this->formatRoot($this->formatScheme($secure), $root); |
| 212 | 212 | |
| 213 | - return $this->removeIndex($root).'/'.trim($path, '/'); |
|
| 213 | + return $this->removeIndex($root) . '/' . trim($path, '/'); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | $i = 'index.php'; |
| 222 | 222 | |
| 223 | - return Text::contains($root, $i) ? str_replace('/'.$i, '', $root) : $root; |
|
| 223 | + return Text::contains($root, $i) ? str_replace('/' . $i, '', $root) : $root; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | if (null === $this->cachedScheme) { |
| 236 | - $this->cachedScheme = $this->forceScheme ?: $this->request->getScheme().'://'; |
|
| 236 | + $this->cachedScheme = $this->forceScheme ?: $this->request->getScheme() . '://'; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | return $this->cachedScheme; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | { |
| 249 | 249 | $route = $this->routes->reverseRoute($name, ...$parameters); |
| 250 | 250 | |
| 251 | - if (! $route) { |
|
| 251 | + if (!$route) { |
|
| 252 | 252 | throw HttpException::invalidRedirectRoute($route); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | $start = Text::startsWith($root, 'http://') ? 'http://' : 'https://'; |
| 298 | 298 | |
| 299 | - return preg_replace('~'.$start.'~', $scheme, $root, 1); |
|
| 299 | + return preg_replace('~' . $start . '~', $scheme, $root, 1); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | public function format($root, $path, $route = null) |
| 311 | 311 | { |
| 312 | - $path = '/'.trim($path, '/'); |
|
| 312 | + $path = '/' . trim($path, '/'); |
|
| 313 | 313 | |
| 314 | 314 | if ($this->formatHostUsing) { |
| 315 | 315 | $root = call_user_func($this->formatHostUsing, $root, $route); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $path = call_user_func($this->formatPathUsing, $path, $route); |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - return trim($root.$path, '/'); |
|
| 322 | + return trim($root . $path, '/'); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | */ |
| 328 | 328 | public function isValidUrl(string $path): bool |
| 329 | 329 | { |
| 330 | - if (! preg_match('~^(#|//|https?://|(mailto|tel|sms):)~', $path)) { |
|
| 330 | + if (!preg_match('~^(#|//|https?://|(mailto|tel|sms):)~', $path)) { |
|
| 331 | 331 | return filter_var($path, FILTER_VALIDATE_URL) !== false; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | { |
| 342 | 342 | $this->cachedScheme = null; |
| 343 | 343 | |
| 344 | - $this->forceScheme = $scheme ? $scheme.'://' : null; |
|
| 344 | + $this->forceScheme = $scheme ? $scheme . '://' : null; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | public function pathFormatter() |
| 389 | 389 | { |
| 390 | - return $this->formatPathUsing ?: function ($path) { |
|
| 390 | + return $this->formatPathUsing ?: function($path) { |
|
| 391 | 391 | return $path; |
| 392 | 392 | }; |
| 393 | 393 | } |
@@ -21,25 +21,25 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class EventDiscover |
| 23 | 23 | { |
| 24 | - protected Locator $locator; |
|
| 24 | + protected Locator $locator; |
|
| 25 | 25 | |
| 26 | - public function __construct(protected EventManagerInterface $event) |
|
| 27 | - { |
|
| 28 | - $this->locator = Services::locator(); |
|
| 29 | - } |
|
| 26 | + public function __construct(protected EventManagerInterface $event) |
|
| 27 | + { |
|
| 28 | + $this->locator = Services::locator(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public function discove() |
|
| 32 | - { |
|
| 33 | - $files = $this->locator->listFiles('Events/'); |
|
| 31 | + public function discove() |
|
| 32 | + { |
|
| 33 | + $files = $this->locator->listFiles('Events/'); |
|
| 34 | 34 | |
| 35 | - foreach ($files as $file) { |
|
| 35 | + foreach ($files as $file) { |
|
| 36 | 36 | $className = $this->locator->getClassname($file); |
| 37 | 37 | |
| 38 | 38 | if ($className === '' || ! class_exists($className) || ! is_a($className, EventListenerInterface::class, true)) { |
| 39 | 39 | continue; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - Services::factory($className)->listen($this->event); |
|
| 42 | + Services::factory($className)->listen($this->event); |
|
| 43 | 43 | } |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | \ No newline at end of file |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | foreach ($files as $file) { |
| 36 | 36 | $className = $this->locator->getClassname($file); |
| 37 | 37 | |
| 38 | - if ($className === '' || ! class_exists($className) || ! is_a($className, EventListenerInterface::class, true)) { |
|
| 38 | + if ($className === '' || !class_exists($className) || !is_a($className, EventListenerInterface::class, true)) { |
|
| 39 | 39 | continue; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $debugger = new Run(); |
| 54 | 54 | |
| 55 | - if (! is_online()) { |
|
| 55 | + if (!is_online()) { |
|
| 56 | 56 | if (Misc::isCommandLine()) { |
| 57 | 57 | $debugger->pushHandler(new PlainTextHandler()); |
| 58 | 58 | } elseif (Misc::isAjaxRequest()) { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * On log toutes les erreurs |
| 67 | 67 | */ |
| 68 | - $debugger->pushHandler(static function (Throwable $exception, Inspector $inspector, RunInterface $run) { |
|
| 68 | + $debugger->pushHandler(static function(Throwable $exception, Inspector $inspector, RunInterface $run) { |
|
| 69 | 69 | Services::logger()->error($exception); |
| 70 | 70 | |
| 71 | 71 | return Handler::DONE; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $debugger = Ignition::make(); |
| 85 | 85 | |
| 86 | 86 | $debugger->applicationPath(ROOTPATH) |
| 87 | - ->shouldDisplayException(! on_prod()) |
|
| 87 | + ->shouldDisplayException(!on_prod()) |
|
| 88 | 88 | ->register(); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | private RouteCollection $routeCollection; |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Routes deja collectees (pour eviter de faire la meme chose plusieurs fois) |
|
| 25 | - */ |
|
| 26 | - private array $cachedRoutes = []; |
|
| 23 | + /** |
|
| 24 | + * Routes deja collectees (pour eviter de faire la meme chose plusieurs fois) |
|
| 25 | + */ |
|
| 26 | + private array $cachedRoutes = []; |
|
| 27 | 27 | |
| 28 | 28 | public function __construct(RouteCollection $routes) |
| 29 | 29 | { |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function collect(bool $reset = true): array |
| 37 | 37 | { |
| 38 | - if (! $reset && $this->cachedRoutes !== []) { |
|
| 39 | - return $this->cachedRoutes; |
|
| 40 | - } |
|
| 38 | + if (! $reset && $this->cachedRoutes !== []) { |
|
| 39 | + return $this->cachedRoutes; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | $methods = [ |
| 43 | 43 | 'get', |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | 'cli', |
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | - $definedRoutes = []; |
|
| 55 | + $definedRoutes = []; |
|
| 56 | 56 | |
| 57 | 57 | foreach ($methods as $method) { |
| 58 | 58 | $routes = $this->routeCollection->getRoutes($method); |
| 59 | 59 | |
| 60 | - foreach ($routes as $route => $handler) { |
|
| 60 | + foreach ($routes as $route => $handler) { |
|
| 61 | 61 | if (is_string($handler) || $handler instanceof Closure) { |
| 62 | 62 | if ($handler instanceof Closure) { |
| 63 | 63 | $view = $this->routeCollection->getRoutesOptions($route, $method)['view'] ?? false; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | $routeName = $this->routeCollection->getRoutesOptions($route, $method)['as'] ?? $route; |
| 69 | 69 | |
| 70 | - $definedRoutes[] = [ |
|
| 70 | + $definedRoutes[] = [ |
|
| 71 | 71 | 'method' => $method, |
| 72 | 72 | 'route' => $route, |
| 73 | 73 | 'name' => $routeName, |
@@ -77,6 +77,6 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - return $this->cachedRoutes = $definedRoutes; |
|
| 80 | + return $this->cachedRoutes = $definedRoutes; |
|
| 81 | 81 | } |
| 82 | 82 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function collect(bool $reset = true): array |
| 37 | 37 | { |
| 38 | - if (! $reset && $this->cachedRoutes !== []) { |
|
| 38 | + if (!$reset && $this->cachedRoutes !== []) { |
|
| 39 | 39 | return $this->cachedRoutes; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | $this->middlewaresInfo = $this->collection->getFiltersForRoute($this->matchedRoute[0]); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - // met a jour le routeur dans le conteneur car permet notament de recupere les bonnes |
|
| 151 | - // info du routing (route actuelle, controleur et methode mappés) |
|
| 152 | - Services::set(static::class, $this); |
|
| 150 | + // met a jour le routeur dans le conteneur car permet notament de recupere les bonnes |
|
| 151 | + // info du routing (route actuelle, controleur et methode mappés) |
|
| 152 | + Services::set(static::class, $this); |
|
| 153 | 153 | |
| 154 | - return $this->controllerName(); |
|
| 154 | + return $this->controllerName(); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Toujours là ? Ensuite, nous pouvons essayer de faire correspondre l'URI avec |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $this->autoRoute($uri); |
| 165 | 165 | |
| 166 | - // met a jour le routeur dans le conteneur car permet notament de recupere les bonnes |
|
| 167 | - // info du routing (route actuelle, controleur et methode mappés) |
|
| 168 | - Services::set(static::class, $this); |
|
| 166 | + // met a jour le routeur dans le conteneur car permet notament de recupere les bonnes |
|
| 167 | + // info du routing (route actuelle, controleur et methode mappés) |
|
| 168 | + Services::set(static::class, $this); |
|
| 169 | 169 | |
| 170 | 170 | return $this->controllerName(); |
| 171 | 171 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | // Toujours là ? Ensuite, nous pouvons essayer de faire correspondre l'URI avec |
| 158 | 158 | // Contrôleurs/répertoires, mais l'application peut ne pas |
| 159 | 159 | // vouloir ceci, comme dans le cas des API. |
| 160 | - if (! $this->collection->shouldAutoRoute()) { |
|
| 160 | + if (!$this->collection->shouldAutoRoute()) { |
|
| 161 | 161 | throw new PageNotFoundException("Impossible de trouver une route pour '{$this->collection->getHTTPVerb()}: {$uri}'."); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -187,11 +187,11 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function controllerName() |
| 189 | 189 | { |
| 190 | - if (! is_string($this->controller)) { |
|
| 190 | + if (!is_string($this->controller)) { |
|
| 191 | 191 | return $this->controller; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $controller = str_contains($this->controller, '\\') |
|
| 194 | + $controller = str_contains($this->controller, '\\') |
|
| 195 | 195 | ? $this->controller |
| 196 | 196 | : trim($this->collection->getDefaultNamespace(), '\\') . '\\' . $this->controller; |
| 197 | 197 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | return [ |
| 233 | 233 | $routeArray[0], // Controller |
| 234 | - $routeArray[1] ?? 'index', // Method |
|
| 234 | + $routeArray[1] ?? 'index', // Method |
|
| 235 | 235 | ]; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | // Cette route est-elle censée rediriger vers une autre ? |
| 356 | 356 | if ($this->collection->isRedirect($routeKey)) { |
| 357 | 357 | // remplacement des groupes de routes correspondants par des références : post/([0-9]+) -> post/$1 |
| 358 | - $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function () { |
|
| 358 | + $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function() { |
|
| 359 | 359 | static $i = 1; |
| 360 | 360 | |
| 361 | 361 | return '$' . $i++; |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | ); |
| 376 | 376 | |
| 377 | 377 | if ($this->collection->shouldUseSupportedLocalesOnly() |
| 378 | - && ! in_array($matched['locale'], config('App')->supportedLocales, true)) { |
|
| 378 | + && !in_array($matched['locale'], config('App')->supportedLocales, true)) { |
|
| 379 | 379 | // Lancer une exception pour empêcher l'autorouteur, |
| 380 | 380 | // si activé, essayer de trouver une route |
| 381 | 381 | throw PageNotFoundException::localeNotSupported($matched['locale']); |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | // Utilisons-nous Closures ? Si tel est le cas, nous devons collecter les paramètres dans un tableau |
| 389 | 389 | // afin qu'ils puissent être transmis ultérieurement à la méthode du contrôleur. |
| 390 | - if (! is_string($handler) && is_callable($handler)) { |
|
| 390 | + if (!is_string($handler) && is_callable($handler)) { |
|
| 391 | 391 | $this->controller = $handler; |
| 392 | 392 | |
| 393 | 393 | // Supprime la chaîne d'origine du tableau matches |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | |
| 464 | 464 | // $this->method contient déjà le nom de la méthode par défaut, |
| 465 | 465 | // donc ne l'écrasez pas avec le vide. |
| 466 | - if (! empty($method)) { |
|
| 466 | + if (!empty($method)) { |
|
| 467 | 467 | $this->setMethod($method); |
| 468 | 468 | } |
| 469 | 469 | |
@@ -63,19 +63,19 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Position du contrôleur dans les segments URI. |
| 66 | - * Null pour le contrôleur par défaut. |
|
| 66 | + * Null pour le contrôleur par défaut. |
|
| 67 | 67 | */ |
| 68 | 68 | private ?int $controllerPos = null; |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Position de la méthode dans les segments URI. |
| 72 | - * Null pour la méthode par défaut. |
|
| 72 | + * Null pour la méthode par défaut. |
|
| 73 | 73 | */ |
| 74 | 74 | private ?int $methodPos = null; |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Position du premier Paramètre dans les segments URI. |
| 78 | - * Null pour les paramètres non definis. |
|
| 78 | + * Null pour les paramètres non definis. |
|
| 79 | 79 | */ |
| 80 | 80 | private ?int $paramPos = null; |
| 81 | 81 | |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | private string $defaultMethod, |
| 96 | 96 | private bool $translateURIDashes |
| 97 | 97 | ) { |
| 98 | - $this->namespace = rtrim($namespace, '\\'); |
|
| 98 | + $this->namespace = rtrim($namespace, '\\'); |
|
| 99 | 99 | |
| 100 | - // Definir les valeurs par defaut |
|
| 100 | + // Definir les valeurs par defaut |
|
| 101 | 101 | $this->controller = $this->defaultController; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | * Recherchez le premier contrôleur correspondant au segment URI. |
| 115 | 115 | * |
| 116 | 116 | * S'il y a un contrôleur correspondant au premier segment, la recherche s'arrête là. |
| 117 | - * Les segments restants sont des paramètres du contrôleur. |
|
| 118 | - * |
|
| 117 | + * Les segments restants sont des paramètres du contrôleur. |
|
| 118 | + * |
|
| 119 | 119 | * @return bool true si une classe de contrôleur est trouvée. |
| 120 | 120 | */ |
| 121 | 121 | private function searchFirstController(): bool |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | return false; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - /** |
|
| 159 | + /** |
|
| 160 | 160 | * Recherchez le dernier contrôleur par défaut correspondant aux segments URI. |
| 161 | 161 | * |
| 162 | 162 | * @return bool true si une classe de contrôleur est trouvée. |
@@ -216,16 +216,16 @@ discard block |
||
| 216 | 216 | return false; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - /** |
|
| 219 | + /** |
|
| 220 | 220 | * Recherche contrôleur, méthode et params dans l'URI. |
| 221 | 221 | * |
| 222 | 222 | * @return array [directory_name, controller_name, controller_method, params] |
| 223 | 223 | */ |
| 224 | 224 | public function getRoute(string $uri, string $httpVerb): array |
| 225 | 225 | { |
| 226 | - $httpVerb = strtolower($httpVerb); |
|
| 226 | + $httpVerb = strtolower($httpVerb); |
|
| 227 | 227 | |
| 228 | - // Reinitialise les parametres de la methode du controleur. |
|
| 228 | + // Reinitialise les parametres de la methode du controleur. |
|
| 229 | 229 | $this->params = []; |
| 230 | 230 | |
| 231 | 231 | $defaultMethod = $httpVerb . ucfirst($this->defaultMethod); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | $this->segments = $this->createSegments($uri); |
| 235 | 235 | |
| 236 | - //Verifier les routes de modules |
|
| 236 | + //Verifier les routes de modules |
|
| 237 | 237 | if ( |
| 238 | 238 | $this->segments !== [] |
| 239 | 239 | && ($routingConfig = (object) config('routing')) |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $this->namespace = rtrim($routingConfig->module_routes[$uriSegment], '\\'); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ($this->searchFirstController()) { |
|
| 246 | + if ($this->searchFirstController()) { |
|
| 247 | 247 | // Le contrôleur a ete trouvé. |
| 248 | 248 | $baseControllerName = Helpers::classBasename($this->controller); |
| 249 | 249 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | throw new PageNotFoundException('Aucun contrôleur trouvé pour: ' . $uri); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - // Le premier élément peut être un nom de méthode. |
|
| 264 | + // Le premier élément peut être un nom de méthode. |
|
| 265 | 265 | /** @var string[] $params */ |
| 266 | 266 | $params = $this->params; |
| 267 | 267 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $method = $httpVerb . ucfirst($this->translateURIDashes($methodParam)); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - if ($methodParam !== null && method_exists($this->controller, $method)) { |
|
| 275 | + if ($methodParam !== null && method_exists($this->controller, $method)) { |
|
| 276 | 276 | // Methode trouvee. |
| 277 | 277 | $this->method = $method; |
| 278 | 278 | $this->params = $params; |
@@ -307,14 +307,14 @@ discard block |
||
| 307 | 307 | throw PageNotFoundException::controllerNotFound($this->controller, $method); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - // Vérifiez le contrôleur n'est pas défini dans les routes. |
|
| 310 | + // Vérifiez le contrôleur n'est pas défini dans les routes. |
|
| 311 | 311 | $this->protectDefinedRoutes(); |
| 312 | 312 | |
| 313 | 313 | // Assurez-vous que le contrôleur n'a pas la méthode _remap(). |
| 314 | 314 | $this->checkRemap(); |
| 315 | 315 | |
| 316 | 316 | // Assurez-vous que les segments URI pour le contrôleur et la méthode |
| 317 | - // ne contiennent pas de soulignement lorsque $translateURIDashes est true. |
|
| 317 | + // ne contiennent pas de soulignement lorsque $translateURIDashes est true. |
|
| 318 | 318 | $this->checkUnderscore($uri); |
| 319 | 319 | |
| 320 | 320 | // Verifier le nombre de parametres |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | $this->setDirectory(); |
| 328 | 328 | |
| 329 | - return [$this->directory, $this->controllerName(), $this->methodName(), $this->params]; |
|
| 329 | + return [$this->directory, $this->controllerName(), $this->methodName(), $this->params]; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | private function checkParameters(string $uri): void |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - private function protectDefinedRoutes(): void |
|
| 437 | + private function protectDefinedRoutes(): void |
|
| 438 | 438 | { |
| 439 | 439 | $controller = strtolower($this->controller); |
| 440 | 440 | |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | /** |
| 453 | 453 | * Renvoie le nom du sous-répertoire dans lequel se trouve le contrôleur. |
| 454 | 454 | * Relatif à CONTROLLER_PATH |
| 455 | - * |
|
| 456 | - * @deprecated 1.0 |
|
| 455 | + * |
|
| 456 | + * @deprecated 1.0 |
|
| 457 | 457 | */ |
| 458 | 458 | public function directory(): string |
| 459 | 459 | { |
@@ -488,8 +488,8 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | /** |
| 490 | 490 | * Construit un nom de contrôleur valide |
| 491 | - * |
|
| 492 | - * @deprecated 1.0 |
|
| 491 | + * |
|
| 492 | + * @deprecated 1.0 |
|
| 493 | 493 | */ |
| 494 | 494 | public function makeController(string $name): string |
| 495 | 495 | { |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $class = $this->translateURIDashes(ucfirst($segment)); |
| 134 | 134 | |
| 135 | 135 | // dès que nous rencontrons un segment qui n'est pas compatible PSR-4, arrêter la recherche |
| 136 | - if (! $this->isValidSegment($class)) { |
|
| 136 | + if (!$this->isValidSegment($class)) { |
|
| 137 | 137 | return false; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | throw new MethodNotFoundException(); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if (! $refMethod->isPublic()) { |
|
| 347 | + if (!$refMethod->isPublic()) { |
|
| 348 | 348 | throw new MethodNotFoundException(); |
| 349 | 349 | } |
| 350 | 350 | |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | public function directory(): string |
| 459 | 459 | { |
| 460 | - return ! empty($this->directory) ? $this->directory : ''; |
|
| 460 | + return !empty($this->directory) ? $this->directory : ''; |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | /** |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | private function controllerName() |
| 469 | 469 | { |
| 470 | - if (! is_string($this->controller)) { |
|
| 470 | + if (!is_string($this->controller)) { |
|
| 471 | 471 | return $this->controller; |
| 472 | 472 | } |
| 473 | 473 | |
@@ -20,17 +20,17 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | 22 | * @param string $namespace Namespace dans lequel on recherche |
| 23 | - * @param array<class-string> $protectedControllers Liste des contrôleurs dans les routes définis qui ne doivent pas être consultés via Auto-Routing. |
|
| 24 | - * @param string $prefix Préfixe URI pour Module Routing |
|
| 23 | + * @param array<class-string> $protectedControllers Liste des contrôleurs dans les routes définis qui ne doivent pas être consultés via Auto-Routing. |
|
| 24 | + * @param string $prefix Préfixe URI pour Module Routing |
|
| 25 | 25 | */ |
| 26 | 26 | public function __construct( |
| 27 | - private string $namespace, |
|
| 28 | - private string $defaultController, |
|
| 29 | - private string $defaultMethod, |
|
| 30 | - private array $httpMethods, |
|
| 27 | + private string $namespace, |
|
| 28 | + private string $defaultController, |
|
| 29 | + private string $defaultMethod, |
|
| 30 | + private array $httpMethods, |
|
| 31 | 31 | private array $protectedControllers, |
| 32 | 32 | private string $prefix = '' |
| 33 | - ) |
|
| 33 | + ) |
|
| 34 | 34 | { |
| 35 | 35 | } |
| 36 | 36 | |
@@ -51,17 +51,17 @@ discard block |
||
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $routes = $reader->read( |
|
| 54 | + $routes = $reader->read( |
|
| 55 | 55 | $class, |
| 56 | 56 | $this->defaultController, |
| 57 | 57 | $this->defaultMethod |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - if ($routes === []) { |
|
| 60 | + if ($routes === []) { |
|
| 61 | 61 | continue; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $routes = $this->addMiddlewares($routes); |
|
| 64 | + $routes = $this->addMiddlewares($routes); |
|
| 65 | 65 | |
| 66 | 66 | foreach ($routes as $item) { |
| 67 | 67 | $route = $item['route'] . $item['route_params']; |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | $route = $this->prefix . '/' . $route; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $tbody[] = [ |
|
| 76 | + $tbody[] = [ |
|
| 77 | 77 | strtoupper($item['method']) . '(auto)', |
| 78 | 78 | $route, |
| 79 | 79 | '', |
| 80 | 80 | $item['handler'], |
| 81 | - '', |
|
| 81 | + '', |
|
| 82 | 82 | ]; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -125,7 +125,7 @@ |
||
| 125 | 125 | $i = 1; |
| 126 | 126 | |
| 127 | 127 | foreach ($route['params'] as $required) { |
| 128 | - if ($longest && ! $required) { |
|
| 128 | + if ($longest && !$required) { |
|
| 129 | 129 | $sampleUri .= '/' . $i++; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { |
| 50 | 50 | $methodName = $method->getName(); |
| 51 | 51 | |
| 52 | - foreach ($this->httpMethods as $httpVerb) { |
|
| 52 | + foreach ($this->httpMethods as $httpVerb) { |
|
| 53 | 53 | if (strpos($methodName, $httpVerb) === 0) { |
| 54 | 54 | // Enleve le prefixe des verbes HTTP |
| 55 | 55 | $methodInUri = lcfirst(substr($methodName, strlen($httpVerb))); |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | if ($routeForDefaultController !== []) { |
| 70 | 70 | // Le contrôleur est le contrôleur par défaut. |
| 71 | - // Il n'a qu'un itinéraire pour la méthode par défaut. |
|
| 72 | - // Les autres méthodes ne seront pas routées même si elles existent. |
|
| 71 | + // Il n'a qu'un itinéraire pour la méthode par défaut. |
|
| 72 | + // Les autres méthodes ne seront pas routées même si elles existent. |
|
| 73 | 73 | $output = [...$output, ...$routeForDefaultController]; |
| 74 | 74 | |
| 75 | 75 | continue; |