Skip to content

Commit

Permalink
Merge branch '2.7'
Browse files Browse the repository at this point in the history
* 2.7: (61 commits)
  fixxed order of usage
  [2.7] [Form] Replaced calls to array_search() by in_array() where is no need to get the index
  removed the last deprecation notice
  [Serializer] Silent deprecation notice
  removed deprecation notice
  [PropertyAccess] Show property path in all exception messages
  added deprecation notice for HttpCache::createEsi()
  added missing deprecation notice when using the form_enctype function
  [Process] Make test AbstractProcessTest::testStartAfterATimeout useful again
  removed non-sense example
  Fixes small typo.
  [Validator] Remove unnecessary include in tests
  [HttpFoundation] minor: clarify Request::getUrlencodedPrefix() regex
  fixed typo
  [Serializer] Use Serializer's LogicException when applicable
  [Serializer] Use autoloader for annotations in tests
  [Validator] fix DOS-style line endings
  Drop useless execution bit
  bumped Symfony version to 2.6.5
  [Serializer] update changelog
  ...

Conflicts:
	CHANGELOG-2.3.md
	CHANGELOG-2.5.md
	CHANGELOG-2.6.md
	src/Symfony/Bridge/Twig/Node/FormEnctypeNode.php
	src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php
	src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php
  • Loading branch information
fabpot committed Feb 5, 2015
2 parents 03d5fba + 46f9d7a commit af0aac3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
22 changes: 16 additions & 6 deletions Command/LintCommand.php
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bridge\Twig\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -58,7 +59,7 @@ protected function configure()
$this
->setDescription('Lints a template and outputs encountered errors')
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
->addArgument('filename')
->addArgument('filename', InputArgument::IS_ARRAY)
->setHelp(<<<EOF
The <info>%command.name%</info> command lints a template and outputs to STDOUT
the first encountered syntax error.
Expand Down Expand Up @@ -90,9 +91,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 1;
}

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

if (!$filename) {
if (0 === count($filenames)) {
if (0 !== ftell(STDIN)) {
throw new \RuntimeException("Please provide a filename or pipe template content to STDIN.");
}
Expand All @@ -105,12 +106,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
return $this->display($input, $output, array($this->validate($twig, $template, uniqid('sf_'))));
}

$filesInfo = $this->getFilesInfo($twig, $filenames);

return $this->display($input, $output, $filesInfo);
}

private function getFilesInfo(\Twig_Environment $twig, array $filenames)
{
$filesInfo = array();
foreach ($this->findFiles($filename) as $file) {
$filesInfo[] = $this->validate($twig, file_get_contents($file), $file);
foreach ($filenames as $filename) {
foreach ($this->findFiles($filename) as $file) {
$filesInfo[] = $this->validate($twig, file_get_contents($file), $file);
}
}

return $this->display($input, $output, $filesInfo);
return $filesInfo;
}

protected function findFiles($filename)
Expand Down
2 changes: 1 addition & 1 deletion Extension/FormExtension.php
Expand Up @@ -143,7 +143,7 @@ public function humanize($text)
public function isSelectedChoice(ChoiceView $choice, $selectedValue)
{
if (is_array($selectedValue)) {
return false !== array_search($choice->value, $selectedValue, true);
return in_array($choice->value, $selectedValue, true);
}

return $choice->value === $selectedValue;
Expand Down
8 changes: 4 additions & 4 deletions Tests/Command/LintCommandTest.php
Expand Up @@ -28,7 +28,7 @@ public function testLintCorrectFile()
$tester = $this->createCommandTester();
$filename = $this->createFile('{{ foo }}');

$ret = $tester->execute(array('filename' => $filename), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE));
$ret = $tester->execute(array('filename' => array($filename)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE));

$this->assertEquals(0, $ret, 'Returns 0 in case of success');
$this->assertRegExp('/^OK in /', $tester->getDisplay());
Expand All @@ -39,7 +39,7 @@ public function testLintIncorrectFile()
$tester = $this->createCommandTester();
$filename = $this->createFile('{{ foo');

$ret = $tester->execute(array('filename' => $filename));
$ret = $tester->execute(array('filename' => array($filename)));

$this->assertEquals(1, $ret, 'Returns 1 in case of error');
$this->assertRegExp('/^KO in /', $tester->getDisplay());
Expand All @@ -54,15 +54,15 @@ public function testLintFileNotReadable()
$filename = $this->createFile('');
unlink($filename);

$ret = $tester->execute(array('filename' => $filename));
$ret = $tester->execute(array('filename' => array($filename)));
}

public function testLintFileCompileTimeException()
{
$tester = $this->createCommandTester();
$filename = $this->createFile("{{ 2|number_format(2, decimal_point='.', ',') }}");

$ret = $tester->execute(array('filename' => $filename));
$ret = $tester->execute(array('filename' => array($filename)));

$this->assertEquals(1, $ret, 'Returns 1 in case of error');
$this->assertRegExp('/^KO in /', $tester->getDisplay());
Expand Down

0 comments on commit af0aac3

Please sign in to comment.