diff --git a/system/CLI/CommandRunner.php b/system/CLI/CommandRunner.php index a6985d0db931..06d06863de2f 100644 --- a/system/CLI/CommandRunner.php +++ b/system/CLI/CommandRunner.php @@ -40,13 +40,13 @@ public function __construct() * so we have the chance to look for a Command first. * * @param string $method - * @param array ...$params + * @param array $params * * @throws ReflectionException * * @return mixed */ - public function _remap($method, ...$params) + public function _remap($method, $params) { // The first param is usually empty, so scrap it. if (empty($params[0])) { diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 86e70546dd41..093687254c77 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -884,14 +884,16 @@ protected function runController($class) /** @var CLIRequest $request */ $request = $this->request; $params = $request->getArgs(); + + $output = $class->_remap($this->method, $params); } else { // This is a Web request or PHP CLI request $params = $this->router->params(); - } - $output = method_exists($class, '_remap') - ? $class->_remap($this->method, ...$params) - : $class->{$this->method}(...$params); + $output = method_exists($class, '_remap') + ? $class->_remap($this->method, ...$params) + : $class->{$this->method}(...$params); + } $this->benchmark->stop('controller'); diff --git a/tests/system/CLI/CommandRunnerTest.php b/tests/system/CLI/CommandRunnerTest.php index 32ca71357e75..c9e3245b932c 100644 --- a/tests/system/CLI/CommandRunnerTest.php +++ b/tests/system/CLI/CommandRunnerTest.php @@ -123,7 +123,7 @@ public function testBadCommand() */ public function testRemapEmptyFirstParams() { - self::$runner->_remap('anyvalue', null, 'list'); + self::$runner->_remap('anyvalue', [null, 'list']); $result = CITestStreamFilter::$buffer; // make sure the result looks like a command list diff --git a/tests/system/SparkTest.php b/tests/system/SparkTest.php new file mode 100644 index 000000000000..3b5061fd5947 --- /dev/null +++ b/tests/system/SparkTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace CodeIgniter; + +use CodeIgniter\Test\CIUnitTestCase; + +/** + * @backupGlobals enabled + * + * @internal + */ +final class SparkTest extends CIUnitTestCase +{ + public function testCanUseOption() + { + ob_start(); + passthru('php spark list --simple'); + $output = ob_get_clean(); + + $this->assertStringContainsString('cache:clear', $output); + } +}