src/Http/Uri.php
public function withUserInfo($user, $password = null)
    {
        $uri = clone $this;
        $uri->user = $user;
        $uri->password = $password ?: '';

        return $uri;
    }
public function withUserInfo($user, $password = null)
    {
        $uri = clone $this;
        $uri->user = $user;
        $uri->password = $password ?: '';

        return $uri;
    }
Return an instance with the specified user information.
This method MUST retain the state of the current instance, and return
an instance that contains the specified user information.
Password is optional, but the user information MUST include the
user; an empty string for the user is equivalent to removing user
information.

@param string $user The user name to use for authority.
@param null|string $password The password associated with $user.
@return UriInterface A new instance with the specified user information.