diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index 48f6d94a0391..271f2d847410 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -18,6 +18,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Parser; +use Symfony\Component\Yaml\Yaml; /** * Validates YAML files syntax and outputs encountered errors. @@ -111,7 +112,7 @@ private function validate($content, $file = null) }); try { - $this->getParser()->parse($content); + $this->getParser()->parse($content, Yaml::PARSE_CONSTANT); } catch (ParseException $e) { return array('file' => $file, 'valid' => false, 'message' => $e->getMessage()); } finally { diff --git a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php index ce6ad480cf2b..75aa067f2289 100644 --- a/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php @@ -51,6 +51,15 @@ public function testLintIncorrectFile() $this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay())); } + public function testConstantAsKey() + { + $yaml = <<createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false)); + $this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success'); + } + /** * @expectedException \RuntimeException */ @@ -105,3 +114,8 @@ protected function tearDown() rmdir(sys_get_temp_dir().'/framework-yml-lint-test'); } } + +class Foo +{ + const TEST = 'foo'; +}