Uri::withUserInfo( $user,  $password = null ): static

In this article

Return

static

Source

public function withUserInfo($user, $password = null): UriInterface
{
    if (!\is_string($user)) {
        throw new \InvalidArgumentException('User must be a string');
    }
    $info = \preg_replace_callback('/[' . self::CHAR_GEN_DELIMS . self::CHAR_SUB_DELIMS . ']++/', [__CLASS__, 'rawurlencodeMatchZero'], $user);
    if (null !== $password && '' !== $password) {
        if (!\is_string($password)) {
            throw new \InvalidArgumentException('Password must be a string');
        }
        $info .= ':' . \preg_replace_callback('/[' . self::CHAR_GEN_DELIMS . self::CHAR_SUB_DELIMS . ']++/', [__CLASS__, 'rawurlencodeMatchZero'], $password);
    }
    if ($this->userInfo === $info) {
        return $this;
    }
    $new = clone $this;
    $new->userInfo = $info;
    return $new;
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.