private function LintCommand::validate in Lockr 7.3
1 call to LintCommand::validate()
- LintCommand::execute in vendor/
symfony/ yaml/ Command/ LintCommand.php
File
- vendor/
symfony/ yaml/ Command/ LintCommand.php, line 109
Class
- LintCommand
- Validates YAML files syntax and outputs encountered errors.
Namespace
Symfony\Component\Yaml\CommandCode
private function validate($content, $flags, $file = null) {
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
if (E_USER_DEPRECATED === $level) {
throw new ParseException($message, $this
->getParser()
->getRealCurrentLineNb() + 1);
}
return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false;
});
try {
$this
->getParser()
->parse($content, Yaml::PARSE_CONSTANT | $flags);
} catch (ParseException $e) {
return [
'file' => $file,
'line' => $e
->getParsedLine(),
'valid' => false,
'message' => $e
->getMessage(),
];
} finally {
restore_error_handler();
}
return [
'file' => $file,
'valid' => true,
];
}