Skip to content

Commit

Permalink
Improve type casting
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jul 8, 2024
1 parent 51ebee1 commit cf57ec6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -1121,16 +1121,17 @@ public function withUserInfo(
Stringable|string|null $user,
#[SensitiveParameter] Stringable|string|null $password = null
): UriInterface {
$user = Encoder::encodeUser($this->filterString($user));
$password = Encoder::encodePassword($this->filterString($password));
$userInfo = ('' !== $user) ? $this->formatUserInfo($user, $password) : null;
$userInfo = ('' !== $user) ? $this->formatUserInfo(
Encoder::encodeUser($this->filterString($user)),
Encoder::encodePassword($this->filterString($password))
) : null;

return match ($userInfo) {
$this->userInfo => $this,
default => new self(
$this->scheme,
$user,
$password,
$user instanceof Stringable ? $user->__toString() : $user,
$password instanceof Stringable ? $password->__toString() : $password,
$this->host,
$this->port,
$this->path,
Expand Down

0 comments on commit cf57ec6

Please sign in to comment.