Render warnings into the console.

@param File[] $files
@param OutputInterface $output
498281
protected function renderWarnings(array $files, OutputInterface $output)
    {
        foreach ($files as $file) {
            $output->writeln('<file>' . $file->getFilename() . '</file>');

            $this->renderMessages($file->getWarnings(), $output);

            $output->writeln('');
        }
    }
486564
public function writeln($messages = array())
    {
        //Write it for each message = each renderer
        foreach ($messages as $key => $message) {
            $file = $this->outputPath.DIRECTORY_SEPARATOR.$this->rendererFiles[$key].'.html';
            file_put_contents($file, $message, FILE_APPEND);
        }
    }
575087
protected function displayResult(StyleInterface $io, array $results) {

        $exitCode = 0;

        $rows = [];

        $success = $this->getCheckbox(true);
        $warning = $this->getCheckbox(false);

        // Handle each result.
        foreach ($results as $bundle => $assets) {
            foreach ($assets as $asset => $result) {

                $rows[] = [
                    true === $result ? $success : $warning,
                    $bundle,
                    basename($asset),
                ];

                $exitCode += true === $result ? 0 : 1;
            }
        }

        // Displays a table.
        $io->table(["", "Bundle", "Asset"], $rows);

        return $exitCode;
    }
1296669
protected function showLogs(OutputInterface $output, bool $result)
    {
        if (!$result || $output->isVerbose()) {
            $output->write(Splash::log()->GetConsoleLog(true));
            $output->writeln("");
            $output->writeln("");
        }
    }
1058097
public function renderHeader(array $comments = []) : void
    {
        if ($this->isSilent()) {
            return;
        }

        $this->logger->debug('rendering comments');

        foreach ($comments as $comment) {
            fwrite($this->file, ';;; ' . $comment . PHP_EOL);
        }

        fwrite($this->file, PHP_EOL);
    }
526235
private function watchForChanges(OutputInterface $output, array $files)
    {
        $output->writeln("Watching for changes");

        $previously = [];
        while (true) {
            foreach ($files as $file) {
                /** @var SplFileInfo $file */
                if ($this->checkFile($file->getRealPath(), $previously)) {
                    $output->writeln(
                        sprintf(
                            "<info>>>>></info> <comment>The following file changed:</comment> <info>%s</info>",
                            $file->getPathname()
                        )
                    );

                    $this->getJobs();
                    $this->registry->addJob($this->registry->getNewJob());

                    return;
                }
            }
            sleep(1);
        }

        return;
    }
1105095
public function renderHeader(array $comments = []) : void
    {
        if ($this->isSilent()) {
            return;
        }

        $this->logger->debug('rendering comments');

        fwrite($this->file, '<comments>' . PHP_EOL);

        foreach ($comments as $text) {
            fwrite($this->file, '<comment><![CDATA[' . $text . ']]></comment>' . PHP_EOL);
        }

        fwrite($this->file, '</comments>' . PHP_EOL);
    }
360334
protected function display(OutputInterface $output, array $rows = array(), array $failed = array())
    {
        $this->getApplication()->getHelperSet()->get('table')
            ->setHeaders(array('Name', 'Scripts', 'Rollbacks', 'Status'))
            ->setRows($rows)
            ->render($output);

        if (!empty($failed)) {
            $output->writeln(sprintf('<fg=red>Check failed for release(s) %s</fg=red>', implode(', ', $failed)));
        }
    }
41777
protected function printDbBuildVersion(OutputInterface $output) : void
    {
        $output->writeln(
            sprintf(
                '<info>Reference Database Version</info> => %s%s',
                $this->getApplication()->getDbVersions()['build.version'],
                PHP_EOL

            )
        );
    }
271757
private function execute(array  $files, $options, $errorMessage)
    {
        $outputMessage = new PreCommitOutputWriter(self::CHECKING_MESSAGE);
        $this->output->write($outputMessage->getMessage());

        $errors = [];
        foreach ($files as $file) {
            $errors[] = $this->phpMdToolProcessor->process($file, $options);
        }

        $errors = array_filter($errors);

        if (!empty($errors)) {
            $outputText = $outputMessage->setError(implode('', $errors));
            $this->output->writeln($outputMessage->getFailMessage());
            $this->output->writeln($outputText);
            $this->output->writeln(BadJobLogoResponse::paint($errorMessage));
            throw new PhpMdViolationsException();
        }

        $this->output->writeln($outputMessage->getSuccessfulMessage());
    }
740715
protected function _outputHandle($output=null)
    {
        if ($output === null) {
            // do nothing
        } elseif ($output instanceof ResponseInterface) {
            $this->response = $output;
        } elseif ($output) {
            if (is_scalar($output)) {
                $this->response = $this->renderText($output);
            } elseif (is_array($output)) {
                $this->response = $this->renderJson($output);
            } elseif ($output instanceof Collection) {
                $this->response = $this->renderJson($output->all());
            }
        }
        
        if ($data = $this->getRenderBuffer()) {
            $this->response->write($data);
        }
        
        return $this->response;
    }
93182
private function dumpAssetic(OutputInterface $output)
    {
        $command = $this->getApplication()->find('assetic:dump');

        $arguments = [
            'command' => 'assetic:dump',
            '--env' => 'prod',
            '--no-debug' => true,
        ];

        $input = new ArrayInput($arguments);

        return $command->run($input, $output);
    }
799471
public function connectOutputToLogging(OutputInterface $output, $command)
    {
        static $alreadyConnected = false;
        $helper = $this;

        // ignore any second or later invocations of this method
        if ($alreadyConnected) {
            return;
        }

        /** @var Dispatcher $eventDispatcher  */
        $eventDispatcher = $command->getService('event_dispatcher');

        $eventDispatcher->addListener(
            'parser.file.pre',
            function (PreFileEvent $event) use ($output) {
                $output->writeln('Parsing <info>'.$event->getFile().'</info>');
            }
        );

        $eventDispatcher->addListener(
            'system.log',
            function (LogEvent $event) use ($command, $helper, $output) {
                $helper->logEvent($output, $event, $command);
            }
        );

        $alreadyConnected = true;
    }
151723
public function initConfig(OutputInterface $output = null)
    {
        $log = function ($message) use ($output) {
            if ($output) {
                $output->writeln($message);
            }
        };

        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            throw new \RuntimeException('This feature is currently only supported on Linux and OSX (maybe). Please submit a PR to support it on windows.');
        }

        $configDir = $this->getConfigDir();
        $distDir = $this->getDistConfigDir();

        if (!$this->filesystem->exists($configDir)) {
            $log('<info>[+] Creating directory:</info> '.$configDir);
            $this->filesystem->mkdir($configDir);
        }

        $configFilenames = [
            'alias.yml',
            'phpcrsh.yml',
        ];

        foreach ($configFilenames as $configFilename) {
            $srcFile = $distDir.'/'.$configFilename;
            $destFile = $configDir.'/'.$configFilename;

            if (!$this->filesystem->exists($srcFile)) {
                throw new \Exception('Dist (source) file "'.$srcFile.'" does not exist.');
            }

            if ($this->filesystem->exists($destFile)) {
                $log(sprintf('<info>File</info> %s <info> already exists, not overwriting.', $destFile));

                return;
            }

            $this->filesystem->copy($srcFile, $destFile);
            $log('<info>[+] Creating file:</info> '.$destFile);
        }
    }
552405
public function write($messages = array())
    {
        //Write it for each message = each renderer
        foreach ($messages as $key => $message) {
            $file = $this->outputPath.DIRECTORY_SEPARATOR.$this->rendererFiles[$key].'.html';
            file_put_contents($file, $message);
            $this->copyAssets($key);
        }
    }
279373
public function runExport(array $options, OutputInterface $output)
    {
        $options = $this->validate($options);

        $options['contentTypeIds'] = Text::getIdListFromString($options['contentTypeIdList']);
        $chunkDir = $this->fileSystemHelper->createChunkDir();

        $languages = $this->getLanguages($options);
        $options['languages'] = $languages;

        try {
            $this->fileSystemHelper->lock();
            $urls = $this->generateFiles($languages, $chunkDir, $options, $output);
            $this->fileSystemHelper->unlock();

            $credentials = $this->authenticator->getCredentials();
            $securedDirCredentials = $this->fileSystemHelper->secureDir($chunkDir, $credentials);

            $response = $this->exportNotifier->sendRecommendationResponse($urls, $options, $securedDirCredentials);
            $this->logger->info(sprintf('eZ Recommendation Response: %s', $response));
            $output->writeln('Done');
        } catch (Exception $e) {
            $this->logger->error(sprintf('Error while generating export: %s', $e->getMessage()));
            $this->fileSystemHelper->unlock();

            throw $e;
        }
    }
895450
public function render(OutputInterface $output, ResultCollection $results)
    {
        $data = array_map(function (array $result) {
            return [
                'file' => $result[0],
                'commits' => $result[1],
                'complexity' => $result[2],
                'score' => $result[3],
            ];
        }, $results->toArray());

        $output->write(json_encode($data));
    }