Skip to content

Commit 3682ec0

Browse files
committed
fix warning about uri
1 parent e8c5d9c commit 3682ec0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea

src/MiladRahimi/PHPRouter/Request.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ private function __construct(Router $router)
128128
{
129129
$this->router = $router;
130130
$u = $_SERVER["REQUEST_URI"];
131-
$this->uri = urldecode($u);
132-
$q = $this->query_string = $_SERVER["QUERY_STRING"];
131+
$this->uri = $u ? urldecode($u) : null;
132+
$q = $this->query_string = $_SERVER["QUERY_STRING"] ?: null;
133133
$this->page = trim(substr($u, 0, strlen($u) - strlen($q)), '?');
134134
$this->method = $_SERVER["REQUEST_METHOD"];
135135
$this->protocol = $_SERVER["SERVER_PROTOCOL"];
@@ -204,7 +204,7 @@ public function post($name = null)
204204
{
205205
if (is_null($name))
206206
return $this->post;
207-
if(!is_scalar($name))
207+
if (!is_scalar($name))
208208
throw new InvalidArgumentException("Name must be a string value");
209209
return isset($this->post[$name]) ? $this->post[$name] : null;
210210
}
@@ -291,7 +291,7 @@ public function cookie($name = null)
291291
{
292292
if (is_null($name))
293293
return $_COOKIE;
294-
if(!is_scalar($name))
294+
if (!is_scalar($name))
295295
throw new InvalidArgumentException("Name must be a string value");
296296
return isset($_COOKIE[$name]) ? $_COOKIE[$name] : null;
297297
}

0 commit comments

Comments
 (0)