Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f72338

Browse files
committed
[FrameworkBundle] Move lint commands to lint namespace.
1 parent 4b19daf commit 8f72338

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ class LintCommand extends Command
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
public function __construct($name = 'twig:lint')
38+
public function __construct($name = 'lint:twig')
3939
{
4040
parent::__construct($name);
4141
}
4242

4343
/**
44-
* Sets the twig environment
44+
* Sets the twig environment.
4545
*
4646
* @param \Twig_Environment $twig
4747
*/
@@ -61,6 +61,7 @@ protected function getTwigEnvironment()
6161
protected function configure()
6262
{
6363
$this
64+
->setAliases(array('twig:lint'))
6465
->setDescription('Lints a template and outputs encountered errors')
6566
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
6667
->addArgument('filename', InputArgument::IS_ARRAY)
@@ -87,6 +88,10 @@ protected function configure()
8788

8889
protected function execute(InputInterface $input, OutputInterface $output)
8990
{
91+
if (false !== strpos($input->getFirstArgument(), ':l')) {
92+
$output->writeln('<comment>The use of "twig:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:twig" instead.</comment>');
93+
}
94+
9095
$twig = $this->getTwigEnvironment();
9196

9297
if (null === $twig) {
@@ -99,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
99104

100105
if (0 === count($filenames)) {
101106
if (0 !== ftell(STDIN)) {
102-
throw new \RuntimeException("Please provide a filename or pipe template content to STDIN.");
107+
throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.');
103108
}
104109

105110
$template = '';
@@ -210,14 +215,14 @@ private function renderException(OutputInterface $output, $template, \Twig_Error
210215
$line = $exception->getTemplateLine();
211216

212217
if ($file) {
213-
$output->writeln(sprintf("<error>KO</error> in %s (line %s)", $file, $line));
218+
$output->writeln(sprintf('<error>KO</error> in %s (line %s)', $file, $line));
214219
} else {
215-
$output->writeln(sprintf("<error>KO</error> (line %s)", $line));
220+
$output->writeln(sprintf('<error>KO</error> (line %s)', $line));
216221
}
217222

218223
foreach ($this->getContext($template, $line) as $no => $code) {
219224
$output->writeln(sprintf(
220-
"%s %-6s %s",
225+
'%s %-6s %s',
221226
$no == $line ? '<error>>></error>' : ' ',
222227
$no,
223228
$code

src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private function createCommandTester()
8080

8181
$application = new Application();
8282
$application->add($command);
83-
$command = $application->find('twig:lint');
83+
$command = $application->find('lint:twig');
8484

8585
return new CommandTester($command);
8686
}

src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class YamlLintCommand extends Command
3333
protected function configure()
3434
{
3535
$this
36-
->setName('yaml:lint')
36+
->setName('lint:yaml')
37+
->setAliases(array('yaml:lint'))
3738
->setDescription('Lints a file and outputs encountered errors')
3839
->addArgument('filename', null, 'A file or a directory or STDIN')
3940
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
@@ -65,6 +66,10 @@ protected function configure()
6566

6667
protected function execute(InputInterface $input, OutputInterface $output)
6768
{
69+
if (false !== strpos($input->getFirstArgument(), ':l')) {
70+
$output->writeln('<comment>The use of "yaml:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:yaml" instead.</comment>');
71+
}
72+
6873
$filename = $input->getArgument('filename');
6974

7075
if (!$filename) {

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"symfony/finder": "For using the translation loader and cache warmer",
5454
"symfony/form": "For using forms",
5555
"symfony/validator": "For using validation",
56-
"symfony/yaml": "For using the debug:config and yaml:lint commands",
56+
"symfony/yaml": "For using the debug:config and lint:yaml commands",
5757
"doctrine/cache": "For using alternative cache drivers"
5858
},
5959
"autoload": {

src/Symfony/Bundle/TwigBundle/Command/LintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function configure()
5959
Or all template files in a bundle:
6060
6161
<info>php %command.full_name% @AcmeDemoBundle</info>
62-
62+
6363
EOF
6464
)
6565
;

0 commit comments

Comments
 (0)