src/Leevel/Http/Response.php
public function setContent($content): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        $this->original = $content;

        if ($this->contentShouldJson($content)) {
            $this->setHeader('Content-Type', 'application/json');

            $this->isJson = true;

            $content = $this->contentToJson($content);
        }

        if (null !== $content &&
            !is_scalar($content) &&
            !is_callable([$content, '__toString'])) {
            $e = sprintf('The Response content must be a scalar or object implementing __toString(), %s given.', gettype($content));

            throw new UnexpectedValueException($e);
        }

        $this->content = (string) $content;

        return $this;
    }
public function setContent($content): IResponse
    {
        if ($this->checkFlowControl()) {
            return $this;
        }

        $this->original = $content;

        if ($this->contentShouldJson($content)) {
            $this->setHeader('Content-Type', 'application/json');

            $this->isJson = true;

            $content = $this->contentToJson($content);
        }

        if (null !== $content &&
            !is_scalar($content) &&
            !is_callable([$content, '__toString'])) {
            $e = sprintf('The Response content must be a scalar or object implementing __toString(), %s given.', gettype($content));

            throw new UnexpectedValueException($e);
        }

        $this->content = (string) $content;

        return $this;
    }
设置内容.

@param mixed $content

@return $this