From cf57ec60e111745803a166b2423ba4041e070d49 Mon Sep 17 00:00:00 2001 From: ignace nyamagana butera Date: Mon, 8 Jul 2024 20:13:47 +0200 Subject: [PATCH] Improve type casting --- Uri.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Uri.php b/Uri.php index 6b0e4901..b406ff9f 100644 --- a/Uri.php +++ b/Uri.php @@ -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,