Skip to content

Commit 92db465

Browse files
authored
parse console command arguments w/o filename into super global (#17)
1 parent 03502e1 commit 92db465

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Nono/Request.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class Request
2323
public function __construct()
2424
{
2525
$_SERVER;
26-
if (!in_array($this->method(), ['GET', 'POST'])) {
26+
if (PHP_SAPI == 'cli') {
27+
parse_str(implode('&', array_slice($this->server('argv'), 1)), $GLOBALS['_QUERY']);
28+
} elseif (!in_array($this->method(), ['GET', 'POST'])) {
2729
parse_str($this->content(), $GLOBALS['_QUERY']);
2830
}
2931
}

tests/RequestTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public function testMethod()
4747
self::assertEquals('GET', $this->request->method());
4848
}
4949

50+
public function testContentProducesNoError()
51+
{
52+
self::assertNotFalse($this->request->content());
53+
self::assertNull(error_get_last());
54+
}
55+
5056
public function testRequestTimeFloat()
5157
{
5258
self::assertTrue(is_numeric($this->request->requestTimeFloat()));

0 commit comments

Comments
 (0)