src/Valkyrja/HttpMessage/RequestTrait.php
protected function initialize(
        Uri $uri = null,
        string $method = null,
        Stream $body = null,
        array $headers = null
    ): void {
        $this->uri     = $uri ?? new NativeUri();
        $this->method  = $method ?? RequestMethod::GET;
        $this->body    = $body ?? new NativeStream('php://input');
        $this->headers = $headers ?? [];

        $this->setHeaders($headers);
        $this->validateMethod($this->method);
        $this->validateProtocolVersion($this->protocol);

        if ($this->hasHeader(static::$HOST_NAME) && $this->uri->getHost()) {
            $this->headerNames[static::$HOST_NAME_NORM] = static::$HOST_NAME;
            $this->headers[static::$HOST_NAME]          = [
                $this->uri->getHost(),
            ];
        }
    }
protected function initialize(
        Uri $uri = null,
        string $method = null,
        Stream $body = null,
        array $headers = null
    ): void {
        $this->uri     = $uri ?? new NativeUri();
        $this->method  = $method ?? RequestMethod::GET;
        $this->body    = $body ?? new NativeStream('php://input');
        $this->headers = $headers ?? [];

        $this->setHeaders($headers);
        $this->validateMethod($this->method);
        $this->validateProtocolVersion($this->protocol);

        if ($this->hasHeader(static::$HOST_NAME) && $this->uri->getHost()) {
            $this->headerNames[static::$HOST_NAME_NORM] = static::$HOST_NAME;
            $this->headers[static::$HOST_NAME]          = [
                $this->uri->getHost(),
            ];
        }
    }
Initialize the Request.

@param Uri    $uri     [optional] The uri
@param string $method  [optional] The method
@param Stream $body    [optional] The body stream
@param array  $headers [optional] The headers

@throws \InvalidArgumentException
@throws \Valkyrja\HttpMessage\Exceptions\InvalidMethod
@throws \Valkyrja\HttpMessage\Exceptions\InvalidPath
@throws \Valkyrja\HttpMessage\Exceptions\InvalidPort
@throws \Valkyrja\HttpMessage\Exceptions\InvalidProtocolVersion
@throws \Valkyrja\HttpMessage\Exceptions\InvalidQuery
@throws \Valkyrja\HttpMessage\Exceptions\InvalidScheme
@throws \Valkyrja\HttpMessage\Exceptions\InvalidStream

@return void