src/Leevel/Http/Response.php
public function setStatusCode(int $code, ?string $text = null): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        $this->statusCode = $code;

        if ($this->isInvalid()) {
            $e = sprintf('The HTTP status code %s is not valid.', $code);

            throw new InvalidArgumentException($e);
        }

        if (null === $text) {
            $this->statusText = self::$statusTexts[$code] ?? 'unknown status';

            return $this;
        }

        $this->statusText = $text;

        return $this;
    }
public function setStatusCode(int $code, ?string $text = null): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        $this->statusCode = $code;

        if ($this->isInvalid()) {
            $e = sprintf('The HTTP status code %s is not valid.', $code);

            throw new InvalidArgumentException($e);
        }

        if (null === $text) {
            $this->statusText = self::$statusTexts[$code] ?? 'unknown status';

            return $this;
        }

        $this->statusText = $text;

        return $this;
    }
设置相应状态码.

@param int         $code
@param null|string $text

@return $this