@@ -120,17 +120,17 @@ discard block |
||
| 120 | 120 | return static::$instances[Cache::class] = new Cache($config); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * La clase Config offre une api fluide por gerer les configurations de l'application |
|
| 125 | - */ |
|
| 126 | - public static function config(bool $shared = true): Config |
|
| 127 | - { |
|
| 128 | - if (true === $shared && isset(static::$instances[Config::class])) { |
|
| 123 | + /** |
|
| 124 | + * La clase Config offre une api fluide por gerer les configurations de l'application |
|
| 125 | + */ |
|
| 126 | + public static function config(bool $shared = true): Config |
|
| 127 | + { |
|
| 128 | + if (true === $shared && isset(static::$instances[Config::class])) { |
|
| 129 | 129 | return static::$instances[Config::class]; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - return static::$instances[Config::class] = new Config(); |
|
| 133 | - } |
|
| 132 | + return static::$instances[Config::class] = new Config(); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | 136 | * Conteneur d'injection de dependances |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | return static::$instances[Container::class]; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - return static::$instances[Container::class] = new Container(); |
|
| 144 | + return static::$instances[Container::class] = new Container(); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | protected static function cacheServices(): void |
| 506 | 506 | { |
| 507 | - if (! static::$discovered) { |
|
| 507 | + if (!static::$discovered) { |
|
| 508 | 508 | $locator = static::locator(); |
| 509 | 509 | $files = $locator->search('Config/Services'); |
| 510 | 510 | |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | $name = array_shift($arguments); |
| 532 | 532 | |
| 533 | 533 | if (empty(static::$instances[$name])) { |
| 534 | - if (! empty($arguments)) { |
|
| 534 | + if (!empty($arguments)) { |
|
| 535 | 535 | static::$instances[$name] = static::factory($name, $arguments); |
| 536 | 536 | } else { |
| 537 | 537 | static::$instances[$name] = static::container()->get($name); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public static function providers(): array |
| 130 | 130 | { |
| 131 | - if (! empty(static::$providers)) { |
|
| 131 | + if (!empty(static::$providers)) { |
|
| 132 | 132 | return static::$providers; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Les providers par défaut du système doivent être ajouté en premier pour que les autres puisse les surcharger |
| 160 | - if (! empty($systemProvider)) { |
|
| 160 | + if (!empty($systemProvider)) { |
|
| 161 | 161 | $providers[] = $systemProvider; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $providers = [...$providers, ...$localIncludes]; |
| 166 | 166 | |
| 167 | 167 | // Enfin ceux de l'application doivent remplacer tous les autres |
| 168 | - if (! empty($appProvider)) { |
|
| 168 | + if (!empty($appProvider)) { |
|
| 169 | 169 | $providers[] = $appProvider; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * Chemin de requête à utiliser. |
| 126 | 126 | * |
| 127 | 127 | * @var string |
| 128 | - * |
|
| 129 | - * @deprecated No longer used. |
|
| 128 | + * |
|
| 129 | + * @deprecated No longer used. |
|
| 130 | 130 | */ |
| 131 | 131 | protected $path; |
| 132 | 132 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | protected int $bufferLevel = 0; |
| 137 | 137 | |
| 138 | - /** |
|
| 138 | + /** |
|
| 139 | 139 | * Mise en cache des pages Web |
| 140 | 140 | */ |
| 141 | 141 | protected ResponseCache $pageCache; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $this->startTime = microtime(true); |
| 149 | 149 | $this->config = (object) config('app'); |
| 150 | 150 | |
| 151 | - $this->pageCache = Services::responsecache(); |
|
| 151 | + $this->pageCache = Services::responsecache(); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $controller = $routes->getDefaultController(); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if (! $fullName && is_string($controller)) { |
|
| 181 | + if (! $fullName && is_string($controller)) { |
|
| 182 | 182 | $controller = str_replace($routes->getDefaultNamespace(), '', $controller); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | $this->initMiddlewareQueue(); |
| 212 | 212 | |
| 213 | - try { |
|
| 213 | + try { |
|
| 214 | 214 | $this->response = $this->handleRequest($routes, config('cache')); |
| 215 | 215 | } catch (ResponsableInterface|RedirectException $e) { |
| 216 | 216 | $this->outputBufferingEnd(); |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | protected function handleRequest(?RouteCollectionInterface $routes = null, ?array $cacheConfig = null): ResponseInterface |
| 244 | 244 | { |
| 245 | - $this->forceSecureAccess(); |
|
| 245 | + $this->forceSecureAccess(); |
|
| 246 | 246 | |
| 247 | - /** |
|
| 247 | + /** |
|
| 248 | 248 | * Init event manager |
| 249 | 249 | */ |
| 250 | - Services::singleton(EventDiscover::class)->discove(); |
|
| 250 | + Services::singleton(EventDiscover::class)->discove(); |
|
| 251 | 251 | |
| 252 | - $this->event->trigger('pre_system'); |
|
| 252 | + $this->event->trigger('pre_system'); |
|
| 253 | 253 | |
| 254 | - // Check for a cached page. |
|
| 255 | - // Execution will stop if the page has been cached. |
|
| 254 | + // Check for a cached page. |
|
| 255 | + // Execution will stop if the page has been cached. |
|
| 256 | 256 | if (($response = $this->displayCache($cacheConfig)) instanceof ResponseInterface) { |
| 257 | 257 | return $response; |
| 258 | 258 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | $routeMiddlewares = (array) $this->dispatchRoutes($routes); |
| 261 | 261 | |
| 262 | 262 | // Le bootstrap dans un middleware |
| 263 | - $this->middleware->alias('blitz', $this->bootApp()); |
|
| 263 | + $this->middleware->alias('blitz', $this->bootApp()); |
|
| 264 | 264 | $this->middleware->append('blitz'); |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -383,13 +383,13 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | public function displayCache(?array $config = null) |
| 385 | 385 | { |
| 386 | - if ($cachedResponse = $this->pageCache->get($this->request, $this->response)) { |
|
| 386 | + if ($cachedResponse = $this->pageCache->get($this->request, $this->response)) { |
|
| 387 | 387 | $this->response = $cachedResponse; |
| 388 | 388 | |
| 389 | 389 | $this->totalTime = $this->timer->getElapsedTime('total_execution'); |
| 390 | 390 | $output = $this->displayPerformanceMetrics($cachedResponse->getBody()); |
| 391 | 391 | |
| 392 | - return $this->response->withBody(to_stream($output)); |
|
| 392 | + return $this->response->withBody(to_stream($output)); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | return false; |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | $this->gatherOutput($returned); |
| 590 | 590 | |
| 591 | - return $this->response; |
|
| 591 | + return $this->response; |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | // Affiche l'erreur 404 |
@@ -658,13 +658,13 @@ discard block |
||
| 658 | 658 | $uri = Services::uri($uri, false); |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - Services::session()->setPreviousUrl(Uri::createURIString( |
|
| 662 | - $uri->getScheme(), |
|
| 663 | - $uri->getAuthority(), |
|
| 664 | - $uri->getPath(), |
|
| 665 | - $uri->getQuery(), |
|
| 666 | - $uri->getFragment() |
|
| 667 | - )); |
|
| 661 | + Services::session()->setPreviousUrl(Uri::createURIString( |
|
| 662 | + $uri->getScheme(), |
|
| 663 | + $uri->getAuthority(), |
|
| 664 | + $uri->getPath(), |
|
| 665 | + $uri->getQuery(), |
|
| 666 | + $uri->getFragment() |
|
| 667 | + )); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | /** |
@@ -696,9 +696,9 @@ discard block |
||
| 696 | 696 | return $returned; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - if ($returned instanceof Responsable) { |
|
| 700 | - return $returned->toResponse($this->request); |
|
| 701 | - } |
|
| 699 | + if ($returned instanceof Responsable) { |
|
| 700 | + return $returned->toResponse($this->request); |
|
| 701 | + } |
|
| 702 | 702 | |
| 703 | 703 | if (is_object($returned)) { |
| 704 | 704 | if (method_exists($returned, '__toString')) { |
@@ -743,11 +743,11 @@ discard block |
||
| 743 | 743 | $this->middleware->prepend($this->spoofRequestMethod()); |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - protected function outputBufferingStart(): void |
|
| 746 | + protected function outputBufferingStart(): void |
|
| 747 | 747 | { |
| 748 | 748 | $this->bufferLevel = ob_get_level(); |
| 749 | 749 | |
| 750 | - ob_start(); |
|
| 750 | + ob_start(); |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | protected function outputBufferingEnd(): string |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | if (is_string($this->controller)) { |
| 820 | - if (strtoupper($request->getMethod()) === 'POST') { |
|
| 820 | + if (strtoupper($request->getMethod()) === 'POST') { |
|
| 821 | 821 | if (is_subclass_of($this->controller, RestController::class)) { |
| 822 | 822 | return $this->formatResponse($response->withStatus($code), [ |
| 823 | 823 | 'success' => false, |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | 'errors' => $errors, |
| 826 | 826 | ]); |
| 827 | 827 | } |
| 828 | - if (is_subclass_of($this->controller, BaseController::class)) { |
|
| 828 | + if (is_subclass_of($this->controller, BaseController::class)) { |
|
| 829 | 829 | return Services::redirection()->back()->withInput()->withErrors($errors)->withStatus($code); |
| 830 | 830 | } |
| 831 | 831 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $controller = $routes->getDefaultController(); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if (! $fullName && is_string($controller)) { |
|
| 181 | + if (!$fullName && is_string($controller)) { |
|
| 182 | 182 | $controller = str_replace($routes->getDefaultNamespace(), '', $controller); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -323,14 +323,14 @@ discard block |
||
| 323 | 323 | return; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if (is_cli() && ! on_test()) { |
|
| 326 | + if (is_cli() && !on_test()) { |
|
| 327 | 327 | // @codeCoverageIgnoreStart |
| 328 | 328 | // $this->request = Services::clirequest($this->config); |
| 329 | 329 | // @codeCoverageIgnoreEnd |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | $version = $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1'; |
| 333 | - if (! is_numeric($version)) { |
|
| 333 | + if (!is_numeric($version)) { |
|
| 334 | 334 | $version = substr($version, strpos($version, '/') + 1); |
| 335 | 335 | } |
| 336 | 336 | |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | // Supposons le succès jusqu'à preuve du contraire. |
| 350 | 350 | $this->response = Services::response()->withStatus(200); |
| 351 | 351 | |
| 352 | - if (! is_cli() || on_test()) { |
|
| 352 | + if (!is_cli() || on_test()) { |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | $this->response = $this->response->withProtocolVersion($this->request->getProtocolVersion()); |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | */ |
| 464 | 464 | protected function determinePath(): string |
| 465 | 465 | { |
| 466 | - if (! empty($this->path)) { |
|
| 466 | + if (!empty($this->path)) { |
|
| 467 | 467 | return $this->path; |
| 468 | 468 | } |
| 469 | 469 | |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | // Essayez de charger automatiquement la classe |
| 507 | - if (! class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) { |
|
| 507 | + if (!class_exists($this->controller, true) || ($this->method[0] === '_' && $this->method !== '__invoke')) { |
|
| 508 | 508 | throw PageNotFoundException::controllerNotFound($this->controller, $this->method); |
| 509 | 509 | } |
| 510 | 510 | |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | echo $this->outputBufferingEnd(); |
| 598 | 598 | flush(); |
| 599 | 599 | |
| 600 | - throw PageNotFoundException::pageNotFound(! on_prod() || is_cli() ? $e->getMessage() : ''); |
|
| 600 | + throw PageNotFoundException::pageNotFound(!on_prod() || is_cli() ? $e->getMessage() : ''); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /** |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | public function storePreviousURL($uri) |
| 640 | 640 | { |
| 641 | 641 | // Ignorer les requêtes CLI |
| 642 | - if (is_cli() && ! on_test()) { |
|
| 642 | + if (is_cli() && !on_test()) { |
|
| 643 | 643 | return; // @codeCoverageIgnore |
| 644 | 644 | } |
| 645 | 645 | |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | $this->middleware = new Middleware($this->response, $this->determinePath()); |
| 734 | 734 | |
| 735 | 735 | $middlewaresFile = CONFIG_PATH . 'middlewares.php'; |
| 736 | - if (file_exists($middlewaresFile) && ! in_array($middlewaresFile, get_included_files(), true)) { |
|
| 736 | + if (file_exists($middlewaresFile) && !in_array($middlewaresFile, get_included_files(), true)) { |
|
| 737 | 737 | $middleware = require $middlewaresFile; |
| 738 | 738 | if (is_callable($middleware)) { |
| 739 | 739 | $middleware($this->middleware, $this->request); |
@@ -768,11 +768,11 @@ discard block |
||
| 768 | 768 | */ |
| 769 | 769 | private function spoofRequestMethod(): callable |
| 770 | 770 | { |
| 771 | - return static function (ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
| 771 | + return static function(ServerRequestInterface $request, ResponseInterface $response, callable $next) { |
|
| 772 | 772 | $post = $request->getParsedBody(); |
| 773 | 773 | |
| 774 | 774 | // Ne fonctionne qu'avec les formulaires POST |
| 775 | - if (strtoupper($request->getMethod()) === 'POST' && ! empty($post['_method'])) { |
|
| 775 | + if (strtoupper($request->getMethod()) === 'POST' && !empty($post['_method'])) { |
|
| 776 | 776 | // Accepte seulement PUT, PATCH, DELETE |
| 777 | 777 | if (in_array(strtoupper($post['_method']), ['PUT', 'PATCH', 'DELETE'], true)) { |
| 778 | 778 | $request = $request->withMethod($post['_method']); |
@@ -785,15 +785,15 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | private function bootApp(): callable |
| 787 | 787 | { |
| 788 | - return function (ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface { |
|
| 788 | + return function(ServerRequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface { |
|
| 789 | 789 | try { |
| 790 | 790 | $returned = $this->startController($request, $response); |
| 791 | 791 | |
| 792 | 792 | // Closure controller has run in startController(). |
| 793 | - if (! is_callable($this->controller)) { |
|
| 793 | + if (!is_callable($this->controller)) { |
|
| 794 | 794 | $controller = $this->createController($request, $response); |
| 795 | 795 | |
| 796 | - if (! method_exists($controller, '_remap') && ! is_callable([$controller, $this->method], false)) { |
|
| 796 | + if (!method_exists($controller, '_remap') && !is_callable([$controller, $this->method], false)) { |
|
| 797 | 797 | throw PageNotFoundException::methodNotFound($this->method); |
| 798 | 798 | } |
| 799 | 799 | |