Current File : /var/www/prestashop/modules/ps_metrics/vendor/friendsofphp/php-cs-fixer/src/Console/Application.php |
<?php
declare (strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace ps_metrics_module_v4_0_6\PhpCsFixer\Console;
use ps_metrics_module_v4_0_6\PhpCsFixer\Console\Command\DescribeCommand;
use ps_metrics_module_v4_0_6\PhpCsFixer\Console\Command\FixCommand;
use ps_metrics_module_v4_0_6\PhpCsFixer\Console\Command\HelpCommand;
use ps_metrics_module_v4_0_6\PhpCsFixer\Console\Command\ListFilesCommand;
use ps_metrics_module_v4_0_6\PhpCsFixer\Console\Command\ListSetsCommand;
use ps_metrics_module_v4_0_6\PhpCsFixer\Console\Command\SelfUpdateCommand;
use ps_metrics_module_v4_0_6\PhpCsFixer\Console\SelfUpdate\GithubClient;
use ps_metrics_module_v4_0_6\PhpCsFixer\Console\SelfUpdate\NewVersionChecker;
use ps_metrics_module_v4_0_6\PhpCsFixer\PharChecker;
use ps_metrics_module_v4_0_6\PhpCsFixer\ToolInfo;
use ps_metrics_module_v4_0_6\PhpCsFixer\Utils;
use Symfony\Component\Console\Application as BaseApplication;
use Symfony\Component\Console\Command\ListCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @author Fabien Potencier <fabien@symfony.com>
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @internal
*/
final class Application extends BaseApplication
{
public const VERSION = '3.4.0';
public const VERSION_CODENAME = 'Si!';
/**
* @var ToolInfo
*/
private $toolInfo;
public function __construct()
{
parent::__construct('PHP CS Fixer', self::VERSION);
$this->toolInfo = new ToolInfo();
// in alphabetical order
$this->add(new DescribeCommand());
$this->add(new FixCommand($this->toolInfo));
$this->add(new ListFilesCommand($this->toolInfo));
$this->add(new ListSetsCommand());
$this->add(new SelfUpdateCommand(new NewVersionChecker(new GithubClient()), $this->toolInfo, new PharChecker()));
}
public static function getMajorVersion() : int
{
return (int) \explode('.', self::VERSION)[0];
}
/**
* {@inheritdoc}
*/
public function doRun(InputInterface $input, OutputInterface $output) : int
{
$stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : ($input->hasParameterOption('--format', \true) && 'txt' !== $input->getParameterOption('--format', null, \true) ? null : $output);
if (null !== $stdErr) {
$warningsDetector = new WarningsDetector($this->toolInfo);
$warningsDetector->detectOldVendor();
$warningsDetector->detectOldMajor();
$warnings = $warningsDetector->getWarnings();
if (\count($warnings) > 0) {
foreach ($warnings as $warning) {
$stdErr->writeln(\sprintf($stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s', $warning));
}
$stdErr->writeln('');
}
}
$result = parent::doRun($input, $output);
if (null !== $stdErr && $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$triggeredDeprecations = Utils::getTriggeredDeprecations();
if (\count($triggeredDeprecations) > 0) {
$stdErr->writeln('');
$stdErr->writeln($stdErr->isDecorated() ? '<bg=yellow;fg=black;>Detected deprecations in use:</>' : 'Detected deprecations in use:');
foreach ($triggeredDeprecations as $deprecation) {
$stdErr->writeln(\sprintf('- %s', $deprecation));
}
}
}
return $result;
}
/**
* {@inheritdoc}
*/
public function getLongVersion() : string
{
$version = \implode('', [
parent::getLongVersion(),
self::VERSION_CODENAME ? \sprintf(' <info>%s</info>', self::VERSION_CODENAME) : '',
// @phpstan-ignore-line to avoid `Ternary operator condition is always true|false.`
' by <comment>Fabien Potencier</comment> and <comment>Dariusz Ruminski</comment>',
]);
$commit = '@git-commit@';
if ('@' . 'git-commit@' !== $commit) {
// @phpstan-ignore-line as `$commit` is replaced during phar building
$version .= ' (' . \substr($commit, 0, 7) . ')';
}
return $version;
}
/**
* {@inheritdoc}
*/
protected function getDefaultCommands() : array
{
return [new HelpCommand(), new ListCommand()];
}
}