@@ -147,9 +147,8 @@ class CodeIgniter
147
147
* Context
148
148
* web: Invoked by HTTP request
149
149
* php-cli: Invoked by CLI via `php public/index.php`
150
- * spark: Invoked by CLI via the `spark` command
151
150
*
152
- * @phpstan-var 'php-cli'|'spark'|' web'
151
+ * @phpstan-var 'php-cli'|'web'
153
152
*/
154
153
protected ?string $ context = null ;
155
154
@@ -307,7 +306,10 @@ protected function initializeKint()
307
306
public function run (?RouteCollectionInterface $ routes = null , bool $ returnResponse = false )
308
307
{
309
308
if ($ this ->context === null ) {
310
- throw new LogicException ('Context must be set before run() is called. If you are upgrading from 4.1.x, you need to merge `public/index.php` and `spark` file from `vendor/codeigniter4/framework`. ' );
309
+ throw new LogicException (
310
+ 'Context must be set before run() is called. If you are upgrading from 4.1.x, '
311
+ . 'you need to merge `public/index.php` and `spark` file from `vendor/codeigniter4/framework`. '
312
+ );
311
313
}
312
314
313
315
$ this ->startBenchmark ();
@@ -342,11 +344,6 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
342
344
return ;
343
345
}
344
346
345
- // spark command has nothing to do with HTTP redirect and 404
346
- if ($ this ->isSparked ()) {
347
- return $ this ->handleRequest ($ routes , $ cacheConfig , $ returnResponse );
348
- }
349
-
350
347
try {
351
348
return $ this ->handleRequest ($ routes , $ cacheConfig , $ returnResponse );
352
349
} catch (RedirectException $ e ) {
@@ -380,14 +377,6 @@ public function useSafeOutput(bool $safe = true)
380
377
return $ this ;
381
378
}
382
379
383
- /**
384
- * Invoked via spark command?
385
- */
386
- private function isSparked (): bool
387
- {
388
- return $ this ->context === 'spark ' ;
389
- }
390
-
391
380
/**
392
381
* Invoked via php-cli command?
393
382
*/
@@ -435,21 +424,18 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
435
424
}
436
425
}
437
426
438
- // Never run filters when running through Spark cli
439
- if (! $ this ->isSparked ()) {
440
- // Run "before" filters
441
- $ this ->benchmark ->start ('before_filters ' );
442
- $ possibleResponse = $ filters ->run ($ uri , 'before ' );
443
- $ this ->benchmark ->stop ('before_filters ' );
427
+ // Run "before" filters
428
+ $ this ->benchmark ->start ('before_filters ' );
429
+ $ possibleResponse = $ filters ->run ($ uri , 'before ' );
430
+ $ this ->benchmark ->stop ('before_filters ' );
444
431
445
- // If a ResponseInterface instance is returned then send it back to the client and stop
446
- if ($ possibleResponse instanceof ResponseInterface) {
447
- return $ returnResponse ? $ possibleResponse : $ possibleResponse ->pretend ($ this ->useSafeOutput )->send ();
448
- }
432
+ // If a ResponseInterface instance is returned then send it back to the client and stop
433
+ if ($ possibleResponse instanceof ResponseInterface) {
434
+ return $ returnResponse ? $ possibleResponse : $ possibleResponse ->pretend ($ this ->useSafeOutput )->send ();
435
+ }
449
436
450
- if ($ possibleResponse instanceof Request) {
451
- $ this ->request = $ possibleResponse ;
452
- }
437
+ if ($ possibleResponse instanceof Request) {
438
+ $ this ->request = $ possibleResponse ;
453
439
}
454
440
455
441
$ returned = $ this ->startController ();
@@ -476,22 +462,12 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
476
462
// so it can be used with the output.
477
463
$ this ->gatherOutput ($ cacheConfig , $ returned );
478
464
479
- // Never run filters when running through Spark cli
480
- if (! $ this ->isSparked ()) {
481
- $ filters ->setResponse ($ this ->response );
465
+ $ filters ->setResponse ($ this ->response );
482
466
483
- // Run "after" filters
484
- $ this ->benchmark ->start ('after_filters ' );
485
- $ response = $ filters ->run ($ uri , 'after ' );
486
- $ this ->benchmark ->stop ('after_filters ' );
487
- } else {
488
- $ response = $ this ->response ;
489
-
490
- // Set response code for CLI command failures
491
- if (is_numeric ($ returned ) || $ returned === false ) {
492
- $ response ->setStatusCode (400 );
493
- }
494
- }
467
+ // Run "after" filters
468
+ $ this ->benchmark ->start ('after_filters ' );
469
+ $ response = $ filters ->run ($ uri , 'after ' );
470
+ $ this ->benchmark ->stop ('after_filters ' );
495
471
496
472
if ($ response instanceof ResponseInterface) {
497
473
$ this ->response = $ response ;
@@ -595,7 +571,7 @@ protected function getRequestObject()
595
571
return ;
596
572
}
597
573
598
- if ($ this ->isSparked () || $ this -> isPhpCli ()) {
574
+ if ($ this ->isPhpCli ()) {
599
575
$ this ->request = Services::clirequest ($ this ->config );
600
576
} else {
601
577
$ this ->request = Services::request ($ this ->config );
@@ -871,9 +847,7 @@ protected function createController()
871
847
* CI4 supports three types of requests:
872
848
* 1. Web: URI segments become parameters, sent to Controllers via Routes,
873
849
* output controlled by Headers to browser
874
- * 2. Spark: accessed by CLI via the spark command, arguments are Command arguments,
875
- * sent to Commands by CommandRunner, output controlled by CLI class
876
- * 3. PHP CLI: accessed by CLI via php public/index.php, arguments become URI segments,
850
+ * 2. PHP CLI: accessed by CLI via php public/index.php, arguments become URI segments,
877
851
* sent to Controllers via Routes, output varies
878
852
*
879
853
* @param mixed $class
@@ -882,21 +856,12 @@ protected function createController()
882
856
*/
883
857
protected function runController ($ class )
884
858
{
885
- if ($ this ->isSparked ()) {
886
- // This is a Spark request
887
- /** @var CLIRequest $request */
888
- $ request = $ this ->request ;
889
- $ params = $ request ->getArgs ();
890
-
891
- $ output = $ class ->_remap ($ this ->method , $ params );
892
- } else {
893
- // This is a Web request or PHP CLI request
894
- $ params = $ this ->router ->params ();
859
+ // This is a Web request or PHP CLI request
860
+ $ params = $ this ->router ->params ();
895
861
896
- $ output = method_exists ($ class , '_remap ' )
897
- ? $ class ->_remap ($ this ->method , ...$ params )
898
- : $ class ->{$ this ->method }(...$ params );
899
- }
862
+ $ output = method_exists ($ class , '_remap ' )
863
+ ? $ class ->_remap ($ this ->method , ...$ params )
864
+ : $ class ->{$ this ->method }(...$ params );
900
865
901
866
$ this ->benchmark ->stop ('controller ' );
902
867
@@ -1095,7 +1060,7 @@ protected function callExit($code)
1095
1060
/**
1096
1061
* Sets the app context.
1097
1062
*
1098
- * @phpstan-param 'php-cli'|'spark'|' web' $context
1063
+ * @phpstan-param 'php-cli'|'web' $context
1099
1064
*
1100
1065
* @return $this
1101
1066
*/
0 commit comments