Skip to content

Commit 3b86b0a

Browse files
committed
Fix CLIRequest parseCommand TypeError when argv is missing
1 parent b635434 commit 3b86b0a

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎system/HTTP/CLIRequest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function getOptionString(bool $useLongOpts = false): string
185185
*/
186186
protected function parseCommand()
187187
{
188-
$args = $this->getServer('argv');
188+
$args = $this->getServer('argv') ?? [];
189189
array_shift($args); // Scrap index.php
190190

191191
$optionValue = false;

‎tests/system/HTTP/CLIRequestTest.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,4 +574,15 @@ public function testIs(): void
574574
{
575575
$this->assertFalse($this->request->is('get'));
576576
}
577+
578+
public function testParseCommandWithMissingArgv(): void
579+
{
580+
Services::injectMock('superglobals', new Superglobals([], [], [], [], []));
581+
582+
$request = new CLIRequest(new App());
583+
584+
$this->assertSame('', $request->getPath());
585+
$this->assertSame([], $request->getSegments());
586+
$this->assertSame('', $request->getOptionString());
587+
}
577588
}

0 commit comments

Comments
 (0)