8000 Allow to parse custom tags when linting yaml files · symfony/symfony@277dddf · GitHub
[go: up one dir, main page]

Skip to content

Commit 277dddf

Browse files
committed
Allow to parse custom tags when linting yaml files
1 parent 7bcb90f commit 277dddf

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Symfony/Component/Yaml/Command/LintCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
101101
return $this->display($io, $filesInfo);
102102
}
103103

104-
private function validate($content, $file = null)
104+
private function validate($content, $flags, $file = null)
105105
{
106106
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
107107
if (E_USER_DEPRECATED === $level) {
@@ -112,7 +112,7 @@ private function validate($content, $file = null)
112112
});
113113

114114
try {
115-
$this->getParser()->parse($content, Yaml::PARSE_CONSTANT);
115+
$this->getParser()->parse($content, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
116116
} catch (ParseException $e) {
117117
return array('file' => $file, 'valid' => false, 'message' => $e->getMessage());
118118
} finally {

src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ public function testConstantAsKey()
6060
$this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
6161
}
6262

63+
public function testCustomTags()
64+
{
65+
$yaml = <<<YAML
66+
foo: !my_tag {foo: bar}
67+
YAML;
68+
$ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
69+
$this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
70+
}
71+
6372
/**
6473
* @expectedException \RuntimeException
6574
*/

0 commit comments

Comments
 (0)
0