Skip to content

refactor: fix phpstan errors in URI and SiteURI #9525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions system/HTTP/SiteURI.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SiteURI extends URI
* 0 => 'test',
* ];
*
* @var array
* @var array<int, string>
*
* @deprecated This property will be private.
*/
Expand Down Expand Up @@ -331,35 +331,48 @@ public function refreshPath()

/**
* Saves our parts from a parse_url() call.
*
* @param array{
* host?: string,
* user?: string,
* path?: string,
* query?: string,
* fragment?: string,
* scheme?: string,
* port?: int,
* pass?: string,
* } $parts
*/
protected function applyParts(array $parts): void
{
if (! empty($parts['host'])) {
if (isset($parts['host']) && $parts['host'] !== '') {
$this->host = $parts['host'];
}
if (! empty($parts['user'])) {

if (isset($parts['user']) && $parts['user'] !== '') {
$this->user = $parts['user'];
}

if (isset($parts['path']) && $parts['path'] !== '') {
$this->path = $this->filterPath($parts['path']);
}
if (! empty($parts['query'])) {

if (isset($parts['query']) && $parts['query'] !== '') {
$this->setQuery($parts['query']);
}
if (! empty($parts['fragment'])) {

if (isset($parts['fragment']) && $parts['fragment'] !== '') {
$this->fragment = $parts['fragment'];
}

// Scheme
if (isset($parts['scheme'])) {
$this->setScheme(rtrim($parts['scheme'], ':/'));
} else {
$this->setScheme('http');
}

// Port
if (isset($parts['port']) && $parts['port'] !== null) {
// Valid port numbers are enforced by earlier parse_url() or setPort()
if (isset($parts['port'])) {
// Valid port numbers are enforced by earlier parse_url or setPort()
$this->port = $parts['port'];
}

Expand Down
Loading
Loading