@param mixed $return

@return ResponseInterface
183880
public function default($return): ResponseInterface
    {
        if ($this->output === null) {
            $this->to();
        }

        switch ($this->output) {
            case 'json':
                if ($return === true) {
                    $return = [];
                }

                return $this->json($return);

            case 'text':
                return $this->text($return);

            case 'html':
                return $this->html($return);

            case 'template':
                return $this->template(null, $return);

            case 'redirect':
                return $this->redirect($return);

            case 'file':
                return $this->file($return);

            default:
                return $this->empty();
        }
    }
631314
public function render( $return = false ) {

		// Get the rendered output.
		$output = $this->get_renderer()->render( $this, true );

		if ( $return ) {
			return $output;
		}

		echo wp_kses( $output, wp_kses_allowed_html( 'post' ) );
	}
1012111
private function processHttpOkResponse(ResponseInterface $response)
    {
        $body = $this->getBodyAsArray($response);

        if (isset($body['error'])) {
            $response = $this->processHttpOkResponseWithError($body);
        } else {
            $response = $this->processHttpOkResponseWithoutError($body);
        }

        return $response;
    }
531458
public function response(ResponseInterface $response)
    {
        $this->lastResponse = $response;

        $content = $response->getBody()->getContents();

        $decoded = json_decode($content); // parse as object
        $data = $decoded;

        if (!empty($decoded)) {
            reset($decoded);
            $data = current($decoded); // get first attribute from array, e.g.: subscription, subscriptions, errors.
        }

        $this->checkRateLimit($response)
            ->checkForErrors($response, $data);

        return $data;
    }
879326
protected function configureResponse(ResponseInterface $Response){
        $Response->setRequest($this->Request);
        $Response->extract();
        return $Response;
    }
1234968
public function createResponse(array $result): Response
    {
        if (empty($this->deferred)) {
            return response($result);
        }

        return response()->stream(
            function () use ($result): void {
                $nested = 1;
                $this->result = $result;
                $this->isStreaming = true;
                $this->stream->stream($result, [], empty($this->deferred));

                if ($executionTime = config('lighthouse.defer.max_execution_ms', 0)) {
                    $this->maxExecutionTime = microtime(true) + ($executionTime * 1000);
                }

                // TODO: Allow nested_levels to be set in config
                // to break out of loop early.
                while (
                    count($this->deferred)
                    && ! $this->executionTimeExpired()
                    && ! $this->maxNestedFieldsResolved($nested)
                ) {
                    $nested++;
                    $this->executeDeferred();
                }

                // We've hit the max execution time or max nested levels of deferred fields.
                // We process remaining deferred fields, but are no longer allowing additional
                // fields to be deferred.
                if (count($this->deferred)) {
                    $this->acceptFurtherDeferring = false;
                    $this->executeDeferred();
                }
            },
            200,
            [
                // TODO: Allow headers to be set in config
                'X-Accel-Buffering' => 'no',
                'Content-Type' => 'multipart/mixed; boundary="-"',
            ]
        );
    }
5300
public function modify(ResponseInterface $response) : ResponseInterface
    {
        /** @var ResponseModifierInterface $modifier */
        foreach ($this->collection as $modifier) {
            $response = $modifier->modify($response);
        }

        return $response;
    }
318963
public final function run(): ResponseInterface
    {
        try {
            $this->prepare();
            try {
                $body = "";
                $container = $this->getContainer();
                $controller = $this->getController($container);
                $body = $controller->execute($container);
                unset($container);
                $response = $controller->getResponse();
                unset($controller);
                return $this->send($response, $body);
            } catch (RuntimeException $e) {
                trigger_error("Run warning: " . $e->getMessage(), E_USER_WARNING);
                unset($container);
                return $this->send($controller->getResponse(), $body);
            } catch (RouterException $e) {
                trigger_error("Run notice: " . $e->getMessage(), E_USER_NOTICE);
                return $this->send($this->getResponse()->withStatus(404), $body);
            } catch (DispatcherException $e) {
                trigger_error("Run error: " . $e->getMessage(), E_USER_ERROR);
                return $this->send($this->getResponse()->withStatus(500), $body);
            }
        } catch (RuntimeException $e) {
            throw new RuntimeException("Can't run application: " . $e->getMessage());
        }
    }
175219
public function prepareResponse($response)
    {
        $request = \app(Request::class);

        if ($response instanceof Responsable) {
            $response = $response->toResponse($request);
        }

        if ($response instanceof PsrResponseInterface) {
            $response = (new HttpFoundationFactory())->createResponse($response);
        } elseif (! $response instanceof SymfonyResponse) {
            $response = new Response($response);
        } elseif ($response instanceof BinaryFileResponse) {
            $response = $response->prepare(Request::capture());
        }

        return $response->prepare($request);
    }
875518
private function wrapResponse(Response $response, $result = null, string $output = ''): Response
    {
        if ($result instanceof Response) {
            if (!empty($output) && $result->getBody()->isWritable()) {
                $result->getBody()->write($output);
            }

            return $result;
        }

        if (is_array($result) || $result instanceof \JsonSerializable) {
            $response = $this->writeJson($response, $result);
        } else {
            $response->getBody()->write($result);
        }

        //Always glue buffered output
        $response->getBody()->write($output);

        return $response;
    }
590530
protected function processResult($result)
    {
        $output = Helper::objectToArray($result);

        if (! is_array($output)) {
            throw new Error\Api($output);
        }

        if (isset($output['result'])) {
            return $output;
        }

        if (
            isset($output['request']) &&
            $output['request']['result'] != 1 &&
            $output['request']['result'] !== 'TRUE') {
            throw new Error\Api($output['request']['errorId'] . ' - ' . $output['request']['errorMessage']);
        }

        return $output;
    }
538281
public function returnType($type = null)
  {
    if (null === $type)
    {
      return $this->responseConfig['returnType'];
    }

    $this->responseConfig['returnType'] = $type;

    return $this;
  }
1133182
public function behave(Response $response)
    {
        return new Response(
            json_decode($response->content(), true),
            $response->contentType(),
            $response->error(),
            $response->errorCode(),
            $response->headerLines(),
            $response->statusCode()
        );
    }
532440
public function respond($input, $status = self::INTERNAL_ERROR, array $header = [])
    {
        return ResponseHelper::fill($this->response, $input, $status, $header);
    }
595415
protected function getResponse( $response ) {
		if ( is_string( $response ) ) {
			return Response::output( $response );
		}

		if ( is_array( $response ) ) {
			return Response::json( $response );
		}

		if ( $response instanceof ResponsableInterface ) {
			return $response->toResponse();
		}

		return $response;
	}
130303
protected function createLaravelResponse(ResponseInterface $response)
    {
        return new Response(
            (string) $response->getBody(),
            $response->getStatusCode(),
            $response->getHeaders()
        );
    }
318548
public function justReturn($return = null)
    {
        $fqn = ltrim($this->function_name->fullyQualifiedName(), '\\');

        \Patchwork\redefine($fqn, function () use ($return) {
            return $return;
        });

        $this->assertRedefined($fqn);
    }