diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index fec178149bee..af4b2bf6f021 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -175,7 +175,7 @@ public function __construct(App $config) $this->startTime = microtime(true); $this->config = $config; - $this->pageCache = Services::responsecache(); + $this->pageCache = service('responsecache'); } /** @@ -341,8 +341,12 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon $this->benchmark->stop('bootstrap'); $this->benchmark->start('required_before_filters'); - // Start up the filters - $filters = Services::filters(); + /** + * Start up the filters + * + * @var Filters $filters + */ + $filters = service('filters'); // Run required before filters $possibleResponse = $this->runRequiredBeforeFilters($filters); @@ -351,7 +355,7 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon $this->response = $possibleResponse; } else { try { - $this->response = $this->handleRequest($routes, config(Cache::class), $returnResponse); + $this->response = $this->handleRequest($routes, config(Cache::class), $filters); } catch (ResponsableInterface $e) { $this->outputBufferingEnd(); @@ -443,10 +447,8 @@ public function disableFilters(): void * * @throws PageNotFoundException * @throws RedirectException - * - * @deprecated $returnResponse is deprecated. */ - protected function handleRequest(?RouteCollectionInterface $routes, Cache $cacheConfig, bool $returnResponse = false) + protected function handleRequest(?RouteCollectionInterface $routes, Cache $cacheConfig, Filters $filters) { if ($this->request instanceof IncomingRequest && $this->request->getMethod() === 'CLI') { return $this->response->setStatusCode(405)->setBody('Method Not Allowed'); @@ -458,9 +460,6 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache $uri = $this->request->getPath(); if ($this->enableFilters) { - /** @var Filters $filters */ - $filters = service('filters'); - // If any filters were specified within the routes file, // we need to ensure it's active for the current request if ($routeFilters !== null) { @@ -516,8 +515,6 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache $this->gatherOutput($cacheConfig, $returned); if ($this->enableFilters) { - /** @var Filters $filters */ - $filters = service('filters'); $filters->setResponse($this->response); // Run "after" filters @@ -608,7 +605,7 @@ protected function startBenchmark() $this->startTime = microtime(true); } - $this->benchmark = Services::timer(); + $this->benchmark = service('timer'); $this->benchmark->start('total_execution', $this->startTime); $this->benchmark->start('bootstrap'); } @@ -901,7 +898,7 @@ protected function createController() assert(is_string($this->controller)); $class = new $this->controller(); - $class->initController($this->request, $this->response, Services::logger()); + $class->initController($this->request, $this->response, service('logger')); $this->benchmark->stop('controller_constructor');