[Yaml][Twig][Lint] Added line numbers to JSON output.
This commit is contained in:
parent
8483564b71
commit
c6d19b1976
@ -145,7 +145,7 @@ EOF
|
||||
} catch (Error $e) {
|
||||
$twig->setLoader($realLoader);
|
||||
|
||||
return array('template' => $template, 'file' => $file, 'valid' => false, 'exception' => $e);
|
||||
return array('template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e);
|
||||
}
|
||||
|
||||
return array('template' => $template, 'file' => $file, 'valid' => true);
|
||||
|
@ -105,7 +105,7 @@ EOF
|
||||
{
|
||||
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
|
||||
if (E_USER_DEPRECATED === $level) {
|
||||
throw new ParseException($message);
|
||||
throw new ParseException($message, $this->getParser()->getLastLineNumberBeforeDeprecation());
|
||||
}
|
||||
|
||||
return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false;
|
||||
@ -114,7 +114,7 @@ EOF
|
||||
try {
|
||||
$this->getParser()->parse($content, Yaml::PARSE_CONSTANT);
|
||||
} catch (ParseException $e) {
|
||||
return array('file' => $file, 'valid' => false, 'message' => $e->getMessage());
|
||||
return array('file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMessage());
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
|
@ -75,6 +75,16 @@ class Parser
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLastLineNumberBeforeDeprecation()
|
||||
{
|
||||
return $this->getRealCurrentLineNb();
|
||||
}
|
||||
|
||||
private function doParse($value, $flags)
|
||||
{
|
||||
$this->currentLineNb = -1;
|
||||
|
Reference in New Issue
Block a user