Skip to content

Commit a1f8ae6

Browse files
committed
refactor: fix PHPStan errors
1 parent 6b3ed28 commit a1f8ae6

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

phpstan-baseline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@
21482148
];
21492149
$ignoreErrors[] = [
21502150
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2151-
'count' => 5,
2151+
'count' => 3,
21522152
'path' => __DIR__ . '/system/HTTP/IncomingRequest.php',
21532153
];
21542154
$ignoreErrors[] = [

system/HTTP/IncomingRequest.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ class IncomingRequest extends Request
152152
*/
153153
public function __construct($config, ?URI $uri = null, $body = 'php://input', ?UserAgent $userAgent = null)
154154
{
155-
if (empty($uri) || empty($userAgent)) {
155+
if ($uri === null || $userAgent === null) {
156156
throw new InvalidArgumentException('You must supply the parameters: uri, userAgent.');
157157
}
158158

159+
assert($uri instanceof SiteURI);
160+
159161
$this->populateHeaders();
160162

161163
if (
@@ -182,15 +184,22 @@ public function __construct($config, ?URI $uri = null, $body = 'php://input', ?U
182184

183185
parent::__construct($config);
184186

185-
if ($uri instanceof SiteURI) {
186-
$this->setPath($uri->getRoutePath());
187-
} else {
188-
$this->setPath($uri->getPath());
189-
}
190-
187+
$this->setPath($uri->getRoutePath());
191188
$this->detectLocale($config);
192189
}
193190

191+
/**
192+
* Retrieves the URI instance.
193+
*
194+
* @return SiteURI
195+
*/
196+
public function getUri()
197+
{
198+
assert($this->uri instanceof SiteURI);
199+
200+
return $this->uri;
201+
}
202+
194203
private function getPostMaxSize(): int
195204
{
196205
$postMaxSize = ini_get('post_max_size');

0 commit comments

Comments
 (0)