public function withQuery($query): self
    {
        if (!\is_string($query) && !method_exists($query, '__toString')) {
            throw new \InvalidArgumentException('Uri query must be a string');
        }
        $query        = ltrim((string)$query, '?');
        $clone        = clone $this;
        $clone->query = $this->filterQuery($query);

        return $clone;
    }
public function withQuery($query): self
    {
        if (!\is_string($query) && !method_exists($query, '__toString')) {
            throw new \InvalidArgumentException('Uri query must be a string');
        }
        $query        = ltrim((string)$query, '?');
        $clone        = clone $this;
        $clone->query = $this->filterQuery($query);

        return $clone;
    }
public function withQuery ( $ query ) : self { if ( ! \ is_string ( $ query ) && ! method_exists ( $ query , '__toString' ) ) { throw new \ InvalidArgumentException ( 'Uri query must be a string' ) ; } $ query = ltrim ( ( string ) $ query , '?' ) ; $ clone = clone $ this ; $ clone -> query = $ this -> filterQuery ( $ query ) ; return $ clone ; }
Return an instance with the specified query string.
An empty query string value is equivalent to removing the query string.
@param string $query The query string to use with the new instance.
@return self A new instance with the specified query string.
@throws \InvalidArgumentException for invalid query strings.
Return an instance with the specified query string . An empty query string value is equivalent to removing the query string .