8000 [YAML] Allow to parse custom tags when linting yaml files by pierredup · Pull Request #24870 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[YAML] Allow to parse custom tags when linting yaml files #24870

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Allow to parse custom tags when linting yaml files
  • Loading branch information
pierredup committed Nov 8, 2017
commit 59651f7f8d854e86902e0e5b1fb39a85312c50e4
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private function validate($content, $file = null)
});

try {
$this->getParser()->parse($content, Yaml::PARSE_CONSTANT);
$this->getParser()->parse($content, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
} catch (ParseException $e) {
return array('file' => $file, 'valid' => false, 'message' => $e->getMessage());
} finally {
Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/Yaml/Tests/Command/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public function testConstantAsKey()
$this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
}

public function testCustomTags()
{
$yaml = <<<YAML
foo: !my_tag {foo: bar}
YAML;
$ret = $this->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
*/
Expand Down
0