diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index d20b9cf1934ca..01857fc1af08d 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -145,7 +145,7 @@ private function validate(Environment $twig, $template, $file) } 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); diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index 271f2d8474109..36025bdebb8b7 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -105,7 +105,7 @@ private function validate($content, $file = null) { $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()->getRealCurrentLineNb() + 1); } return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false; @@ -114,7 +114,7 @@ private function validate($content, $file = null) 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(); } diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 887e2184a0efb..1c27af8182be2 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -453,9 +453,11 @@ private function parseBlock($offset, $yaml, $flags) /** * Returns the current line number (takes the offset into account). * + * @internal + * * @return int The current line number */ - private function getRealCurrentLineNb() + public function getRealCurrentLineNb() { $realCurrentLineNumber = $this->currentLineNb + $this->offset;
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: