@@ -135,25 +135,6 @@ class CodeIgniter
135135 */
136136 protected static $ cacheTTL = 0 ;
137137
138- /**
139- * Request path to use.
140- *
141- * @var string
142- *
143- * @deprecated No longer used.
144- */
145- protected $ path ;
146-
147- /**
148- * Should the Response instance "pretend"
149- * to keep from setting headers/cookies/etc
150- *
151- * @var bool
152- *
153- * @deprecated No longer used.
154- */
155- protected $ useSafeOutput = false ;
156-
157138 /**
158139 * Context
159140 * web: Invoked by HTTP request
@@ -171,7 +152,7 @@ class CodeIgniter
171152 /**
172153 * Whether to return Response object or send response.
173154 *
174- * @deprecated No longer used.
155+ * @deprecated 4.4.0 No longer used.
175156 */
176157 protected bool $ returnResponse = false ;
177158
@@ -336,6 +317,8 @@ private function configureKint(): void
336317 * tries to route the response, loads the controller and generally
337318 * makes all the pieces work together.
338319 *
320+ * @param bool $returnResponse Used for testing purposes only.
321+ *
339322 * @return ResponseInterface|void
340323 */
341324 public function run (?RouteCollectionInterface $ routes = null , bool $ returnResponse = false )
@@ -355,9 +338,9 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
355338 $ this ->getRequestObject ();
356339 $ this ->getResponseObject ();
357340
358- $ this ->spoofRequestMethod ();
359-
360341 try {
342+ $ this ->forceSecureAccess ();
343+
361344 $ this ->response = $ this ->handleRequest ($ routes , config (Cache::class), $ returnResponse );
362345 } catch (ResponsableInterface |DeprecatedRedirectException $ e ) {
363346 $ this ->outputBufferingEnd ();
@@ -381,22 +364,6 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
381364 $ this ->sendResponse ();
382365 }
383366
384- /**
385- * Set our Response instance to "pretend" mode so that things like
386- * cookies and headers are not actually sent, allowing PHP 7.2+ to
387- * not complain when ini_set() function is used.
388- *
389- * @return $this
390- *
391- * @deprecated No longer used.
392- */
393- public function useSafeOutput (bool $ safe = true )
394- {
395- $ this ->useSafeOutput = $ safe ;
396-
397- return $ this ;
398- }
399-
400367 /**
401368 * Invoked via php-cli command?
402369 */
@@ -433,8 +400,6 @@ public function disableFilters(): void
433400 */
434401 protected function handleRequest (?RouteCollectionInterface $ routes , Cache $ cacheConfig , bool $ returnResponse = false )
435402 {
436- $ this ->forceSecureAccess ();
437-
438403 if ($ this ->request instanceof IncomingRequest && strtolower ($ this ->request ->getMethod ()) === 'cli ' ) {
439404 return $ this ->response ->setStatusCode (405 )->setBody ('Method Not Allowed ' );
440405 }
@@ -449,7 +414,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
449414
450415 $ routeFilters = $ this ->tryToRouteIt ($ routes );
451416
452- $ uri = $ this ->determinePath ();
417+ $ uri = $ this ->request -> getPath ();
453418
454419 if ($ this ->enableFilters ) {
455420 // Start up the filters
@@ -621,6 +586,9 @@ protected function startBenchmark()
621586 * @param CLIRequest|IncomingRequest $request
622587 *
623588 * @return $this
589+ *
590+ * @internal Used for testing purposes only.
591+ * @testTag
624592 */
625593 public function setRequest ($ request )
626594 {
@@ -637,6 +605,8 @@ public function setRequest($request)
637605 protected function getRequestObject ()
638606 {
639607 if ($ this ->request instanceof Request) {
608+ $ this ->spoofRequestMethod ();
609+
640610 return ;
641611 }
642612
@@ -647,6 +617,8 @@ protected function getRequestObject()
647617 }
648618
649619 $ this ->request = Services::request ();
620+
621+ $ this ->spoofRequestMethod ();
650622 }
651623
652624 /**
@@ -808,14 +780,14 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null)
808780 // $routes is defined in Config/Routes.php
809781 $ this ->router = Services::router ($ routes , $ this ->request );
810782
811- $ path = $ this ->determinePath ();
783+ $ uri = $ this ->request -> getPath ();
812784
813785 $ this ->benchmark ->stop ('bootstrap ' );
814786 $ this ->benchmark ->start ('routing ' );
815787
816788 $ this ->outputBufferingStart ();
817789
818- $ this ->controller = $ this ->router ->handle ($ path );
790+ $ this ->controller = $ this ->router ->handle ($ uri );
819791 $ this ->method = $ this ->router ->methodName ();
820792
821793 // If a {locale} segment was matched in the final route,
@@ -834,31 +806,12 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null)
834806 * on the CLI/IncomingRequest path.
835807 *
836808 * @return string
837- */
838- protected function determinePath ()
839- {
840- if (! empty ($ this ->path )) {
841- return $ this ->path ;
842- }
843-
844- return method_exists ($ this ->request , 'getPath ' ) ? $ this ->request ->getPath () : $ this ->request ->getUri ()->getPath ();
845- }
846-
847- /**
848- * Allows the request path to be set from outside the class,
849- * instead of relying on CLIRequest or IncomingRequest for the path.
850- *
851- * This is not used now.
852809 *
853- * @return $this
854- *
855- * @deprecated No longer used.
810+ * @deprecated 4.5.0 No longer used.
856811 */
857- public function setPath ( string $ path )
812+ protected function determinePath ( )
858813 {
859- $ this ->path = $ path ;
860-
861- return $ this ;
814+ return $ this ->request ->getPath ();
862815 }
863816
864817 /**
0 commit comments