Skip to content

Commit

Permalink
refactor: fix PHPStan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Nov 12, 2023
1 parent 6b3ed28 commit a1f8ae6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 5,
'count' => 3,
'path' => __DIR__ . '/system/HTTP/IncomingRequest.php',
];
$ignoreErrors[] = [
Expand Down
23 changes: 16 additions & 7 deletions system/HTTP/IncomingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ class IncomingRequest extends Request
*/
public function __construct($config, ?URI $uri = null, $body = 'php://input', ?UserAgent $userAgent = null)
{
if (empty($uri) || empty($userAgent)) {
if ($uri === null || $userAgent === null) {
throw new InvalidArgumentException('You must supply the parameters: uri, userAgent.');
}

assert($uri instanceof SiteURI);

$this->populateHeaders();

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

parent::__construct($config);

if ($uri instanceof SiteURI) {
$this->setPath($uri->getRoutePath());
} else {
$this->setPath($uri->getPath());
}

$this->setPath($uri->getRoutePath());
$this->detectLocale($config);
}

/**
* Retrieves the URI instance.
*
* @return SiteURI
*/
public function getUri()
{
assert($this->uri instanceof SiteURI);

return $this->uri;
}

private function getPostMaxSize(): int
{
$postMaxSize = ini_get('post_max_size');
Expand Down

0 comments on commit a1f8ae6

Please sign in to comment.