@param string   $output

@param Response $response

@return $this
344870
protected function setVersionHeader(string $output, Response $response)
    {
        $crawler = $this->getCrawler($this->createResponseWithLowerCaseContent($output));
        $node    = $crawler->filter('head > meta[http-equiv="x-pjax-version"]');

        if ($node->count()) {
            $response->getHeaders()->set('x-pjax-version', $node->attr('content'));
        }

        return $this;
    }
168954
protected function interact(Input $input, Output $output) {
        return $this->cmd->interact($input,$output);
    }
1320686
protected function setNeededAction(Response $response) {
        if ($response->hasHtml())
        {
            $response->setNeededAction(Response::NEEDED_SHOW_HTML);
        }
        elseif ($response->isProcessing())
        {
            $response->setNeededAction(Response::NEEDED_STATUS_UPDATE);
        }
    }
1161057
protected function execute(Input $input, Output $output) {
        return $this->cmd->execute($input,$output,$this);
    }
945458
protected function initialize(Input $input, Output $output) {
        return $this->cmd->initialize($input,$output);
    }
870282
private function decorateResponse(Response $response)
    {
        if ($response instanceof Http\Response) {
            return $response;
        }

        return new Http\Response($response);
    }
873370
public function setHandler($output)
	{
		$this->_whoops->popHandler();

		if ($output == OutputData::Json)
		{
			$this->_handler = new JsonResponseHandler();
		}
		else if ($output == OutputData::Xml)
		{
			$this->_handler = new XmlResponseHandler();
		}
		else
		{
			$this->_handler = new PrettyPageHandler();
			if (!Context::getInstance()->getDevelopmentStatus())
			{
				$this->_handler->addResourcePath(\WhoopsResources\Resource::getPath());
			}
		}

		$this->_whoops->pushHandler($this->_handler);
	}
738576
public function setResponseIsObject($responseIsObject = FALSE)
    {
        $this->responseIsObject = $responseIsObject;
        $this->logger->error(__FUNCTION__, 'Response Is Object: ' . $this->responseIsObject);

        return $this;
    }
528224
public function run(OutputInterface $output, $response)
    {
        if (empty($response)) {
            // No reports printed if there are no metrics.
            $output->writeln('<info>No metrics.</info>');
            return;
        }

        $output->writeln('<info>Data Source Analysed</info>');

        $directories = array();

        foreach ($response['files'] as $file) {
            $directories[] = dirname($file);
        }
        $directories = array_unique($directories);

        // print Data Source summaries
        if (count($response['files']) > 0) {
            $text = sprintf(
                "%s" .
                "Directories                                 %10d%s" .
                "Files                                       %10d%s" .
                "Errors                                      %10d%s",
                PHP_EOL,
                count($directories),
                PHP_EOL,
                count($response['files']),
                PHP_EOL,
                count($response['errors']),
                PHP_EOL
            );
            $output->writeln($text);
        }

        if (count($response['errors'])) {
            $output->writeln('<info>Errors found</info>');

            foreach ($response['errors'] as $file => $msg) {
                $text = sprintf(
                    '%s <info>></info> %s in file %s',
                    PHP_EOL,
                    $msg,
                    $file
                );
                $output->writeln($text);
            }
        }

        // print each analyser results
        foreach ($response as $analyserName => $analyserResults) {
            if (substr($analyserName, -8) !== 'Analyser') {
                continue;
            }
            $baseNamespace = str_replace(
                'Analyser\\' . basename(str_replace('\\', '/', $analyserName)),
                '',
                $analyserName
            );
            $outputFormatter = $baseNamespace . 'Console\Formatter\\' .
                substr(basename(str_replace('\\', '/', $analyserName)), 0, -8) . 'OutputFormatter';

            if (class_exists($outputFormatter)) {
                $obj = new $outputFormatter();
                $obj($output, $analyserResults);
            }
        }

        if (isset($response['extra']['cache'])) {
            $stats = $response['extra']['cache'];
            $output->writeln(
                sprintf(
                    '%s<info>Cache: %d hits, %d misses</info>',
                    PHP_EOL,
                    $stats['hits'],
                    $stats['misses']
                )
            );
        }
    }
1117896
public function dispatch(ResponseInterface $response, int $status, $result)
    {
        // Build output array
        $contents = [
            'status' => $status,
            'result' => $result,
        ];

        // Convert output to JSON
        $contents = json_encode($contents, JSON_PRETTY_PRINT);

        // Write Response to Body
        $response->getBody()->write($contents);

        // PSR-7 response
        return $response->withStatus($status); 
    }
1290348
protected function setUriHeader(Response $response, Request $request)
    {
        $response->header('X-PJAX-URL', $request->getRequestUri());

        return $this;
    }
347975
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->setInputAndOutput($input, $output);

        return $this->doExecute();
    }
1193818
public function output($response)
    {
        //argument 1 should be an array or ArrayAccess
        Argument::i()->test(1, 'array', 'ArrayAccess');
        
        $code = $response['code'];
        $headers = $response['headers'];
        $body = $response['body'];
        
        if (is_int($code)) {
            http_response_code($code);
        }
        
        if (!isset($headers['Content-Type']) && !isset($headers['content-type'])) {
            $headers['Content-Type'] = 'text/html; charset=utf-8';
        }
        
        if (!$body) {
            $body = '';
        }
        
        //if it's not scalar
        if (!is_scalar($body)) {
            $body = json_encode($body, JSON_PRETTY_PRINT);
        }
        
        foreach ($headers as $name => $value) {
            if (!$value) {
                header($name);
                continue;
            }
            
            header($name.':'.$value);
        }

        $check = new \StdClass();
        $check->stop = false;

        $this->trigger('server-output', $response, $body, $check);
        
        if (!$check->stop) {
            echo (string) $body;
            $this->successful = true;
        }
        
        return $this;
    }
549859
public function handle($input, $output = null)
	{
		try
		{
			$this->bootstrap();

			return $this->getArtisan()->run($input, $output);
		}
		catch (Exception $e)
		{
			$this->reportException($e);

			$this->renderException($output, $e);

			return 1;
		}
	}
227571
public function before(InputInterface $input=null,
        OutputInterface $output=null
    ) {
        $this->output       = $output;
        $this->loadOutputStyles();
        return $this;
    }
627345
public function output($response)
    {
        // Set format
        switch ($this->format) {
            case 'json':
                $response = array_merge_recursive($response, $this->extra);
                $this->header('Content-type: application/json; charset=utf-8');
                $response = json_encode($response);

                // Replace string numbers for integers
                $response = preg_replace('/(")([0-9]+)(")/is', '\\2', $response);
                break;
            case 'html':
                $this->header('Content-type: text/html; charset=utf-8');
                $response = $this->html($response);
                break;
        }

        // Set cookies
        foreach ($this->cookies as $key => $value) {
            setcookie($key, $value, time() + 3600, '/');
        }

        // Set headers
        foreach ($this->headers as $header) {
            header($header);
        }

        // Return response
        echo $response;
        exit;
    }
453056
public function run(OutputInterface $output, $response)
    {
        $output->writeln('<comment>Diagnostics:</comment>');

        foreach ($response as $key => $value) {
            if (strcasecmp('php_version', $key) == 0) {
                $output->writeln('Checking php settings:');

                $output->writeln(
                    sprintf(
                        '- Requires PHP ' . ApiDiagnose::PHP_MIN . ' or better %s',
                        is_bool($value) ? '<error>FAIL</error>' : '<info>OK</info>'
                    )
                );
                if ($output->isVeryVerbose() && is_bool($value)) {
                    $this->writeComment(
                        $output,
                        'Upgrading to PHP ' .
                        ApiDiagnose::PHP_RECOMMANDED . ' or higher is recommended.'
                    );
                }
            }

            if (strcasecmp('php_ini', $key) == 0) {
                $output->writeln(
                    sprintf(
                        '- php.ini file loaded <info>%s</info>',
                        is_bool($value) ? 'NONE' : $value
                    )
                );
            }

            if (preg_match('/^(.*)_loaded$/', $key, $matches)) {
                // checks extensions loaded
                if (strcasecmp('xdebug', $matches[1]) == 0) {
                    // Xdebug is special case (performance issue)
                    $output->writeln(
                        sprintf(
                            '- Xdebug extension loaded %s',
                            $value ? '<warning>YES</warning>' : '<info>NO</info>'
                        )
                    );
                    if ($output->isVeryVerbose()) {
                        $this->writeComment(
                            $output,
                            'You are encouraged to unload xdebug extension' .
                            ' to speed up execution.'
                        );
                    }
                    if ($output->isVeryVerbose() && $response['xdebug_profiler_enable']) {
                        $this->writeComment(
                            $output,
                            'The xdebug.profiler_enable setting is enabled,' .
                            ' this can slow down execution a lot.'
                        );
                    }
                } else {
                    $output->writeln(
                        sprintf(
                            '- %s extension loaded %s',
                            $matches[1],
                            $value ? '<info>YES</info>' : '<error>FAIL</error>'
                        )
                    );
                }
            }
        }
    }