8000 [FrameworkBundle] Move lint commands to lint namespace. by aitboudad · Pull Request #14116 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Move lint commands to lint namespace. #14116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] Move lint commands to lint namespace.
  • Loading branch information
aitboudad committed Apr 2, 2015
commit 8f723385139f485a5850b05de58d8794cf8f7423
17 changes: 11 additions & 6 deletions src/Symfony/Bridge/Twig/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ class LintCommand extends Command
/**
* {@inheritdoc}
*/
public function __construct($name = 'twig:lint')
public function __construct($name = 'lint:twig')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without an alias, this will break now for people relying on the old name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

{
parent::__construct($name);
}

/**
* Sets the twig environment
* Sets the twig environment.
*
* @param \Twig_Environment $twig
*/
Expand All @@ -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)
Expand All @@ -87,6 +88,10 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
if (false !== strpos($input->getFirstArgument(), ':l')) {
$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>');
}

$twig = $this->getTwigEnvironment();

if (null === $twig) {
Expand All @@ -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 = '';
Expand Down Expand Up @@ -210,14 +215,14 @@ private function renderException(OutputInterface $output, $template, \Twig_Error
$line = $exception->getTemplateLine();

if ($file) {
$output->writeln(sprintf("<error>KO</error> in %s (line %s)", $file, $line));
$output->writeln(sprintf('<error>KO</error> in %s (line %s)', $file, $line));
} else {
$output->writeln(sprintf("<error>KO</error> (line %s)", $line));
$output->writeln(sprintf('<error>KO</error> (line %s)', $line));
}

foreach ($this->getContext($template, $line) as $no => $code) {
$output->writeln(sprintf(
"%s %-6s %s",
'%s %-6s %s',
$no == $line ? '<error>>></error>' : ' ',
$no,
$code
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -65,6 +66,10 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
if (false !== strpos($input->getFirstArgument(), ':l')) {
$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>');
}

$filename = $input->getArgument('filename');

if (!$filename) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function configure()
Or all template files in a bundle:

<info>php %command.full_name% @AcmeDemoBundle</info>

EOF
)
;
Expand Down
0