From 8f723385139f485a5850b05de58d8794cf8f7423 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Mon, 30 Mar 2015 20:06:15 +0100 Subject: [PATCH] [FrameworkBundle] Move lint commands to lint namespace. --- src/Symfony/Bridge/Twig/Command/LintCommand.php | 17 +++++++++++------ .../Twig/Tests/Command/LintCommandTest.php | 2 +- .../FrameworkBundle/Command/YamlLintCommand.php | 7 ++++++- .../Bundle/FrameworkBundle/composer.json | 2 +- .../Bundle/TwigBundle/Command/LintCommand.php | 2 +- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 449422b6d07b..ccf6b8764dfb 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -35,13 +35,13 @@ class LintCommand extends Command /** * {@inheritdoc} */ - public function __construct($name = 'twig:lint') + public function __construct($name = 'lint:twig') { parent::__construct($name); } /** - * Sets the twig environment + * Sets the twig environment. * * @param \Twig_Environment $twig */ @@ -61,6 +61,7 @@ protected function getTwigEnvironment() protected function configure() { $this + ->setAliases(array('twig:lint')) ->setDescription('Lints a template and outputs encountered errors') ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt') ->addArgument('filename', InputArgument::IS_ARRAY) @@ -87,6 +88,10 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { + if (false !== strpos($input->getFirstArgument(), ':l')) { + $output->writeln('The use of "twig:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:twig" instead.'); + } + $twig = $this->getTwigEnvironment(); if (null === $twig) { @@ -99,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (0 === count($filenames)) { if (0 !== ftell(STDIN)) { - throw new \RuntimeException("Please provide a filename or pipe template content to STDIN."); + throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.'); } $template = ''; @@ -210,14 +215,14 @@ private function renderException(OutputInterface $output, $template, \Twig_Error $line = $exception->getTemplateLine(); if ($file) { - $output->writeln(sprintf("KO in %s (line %s)", $file, $line)); + $output->writeln(sprintf('KO in %s (line %s)', $file, $line)); } else { - $output->writeln(sprintf("KO (line %s)", $line)); + $output->writeln(sprintf('KO (line %s)', $line)); } foreach ($this->getContext($template, $line) as $no => $code) { $output->writeln(sprintf( - "%s %-6s %s", + '%s %-6s %s', $no == $line ? '>>' : ' ', $no, $code diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index 9a159b762369..a86f74b54874 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -80,7 +80,7 @@ private function createCommandTester() $application = new Application(); $application->add($command); - $command = $application->find('twig:lint'); + $command = $application->find('lint:twig'); return new CommandTester($command); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php index 6565ef85bc84..8a6fdd33ceac 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php @@ -33,7 +33,8 @@ class YamlLintCommand extends Command protected function configure() { $this - ->setName('yaml:lint') + ->setName('lint:yaml') + ->setAliases(array('yaml:lint')) ->setDescription('Lints a file and outputs encountered errors') ->addArgument('filename', null, 'A file or a directory or STDIN') ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt') @@ -65,6 +66,10 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { + if (false !== strpos($input->getFirstArgument(), ':l')) { + $output->writeln('The use of "yaml:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:yaml" instead.'); + } + $filename = $input->getArgument('filename'); if (!$filename) { diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 98012bdaccb9..acee5a9ad03f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -53,7 +53,7 @@ "symfony/finder": "For using the translation loader and cache warmer", "symfony/form": "For using forms", "symfony/validator": "For using validation", - "symfony/yaml": "For using the debug:config and yaml:lint commands", + "symfony/yaml": "For using the debug:config and lint:yaml commands", "doctrine/cache": "For using alternative cache drivers" }, "autoload": { diff --git a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php index a5759d8c7163..60afc27ea59d 100644 --- a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php +++ b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php @@ -59,7 +59,7 @@ protected function configure() Or all template files in a bundle: php %command.full_name% @AcmeDemoBundle - + EOF ) ;