Skip to content

Commit a2ae6bf

Browse files
committed
[Yaml] fix the displayed line number
`getRealCurrentLineNb()` returns line numbers index by 0 (as they serve as array indexes internally).
1 parent 1baac5a commit a2ae6bf

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private function validate($content, $file = null)
105105
{
106106
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
107107
if (E_USER_DEPRECATED === $level) {
108-
throw new ParseException($message, $this->getParser()->getLastLineNumberBeforeDeprecation());
108+
throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1);
109109
}
110110

111111
return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false;

src/Symfony/Component/Yaml/Parser.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,6 @@ public function parse($value, $flags = 0)
124124
return $data;
125125
}
126126

127-
/**
128-
* @internal
129-
*
130-
* @return int
131-
*/
132-
public function getLastLineNumberBeforeDeprecation()
133-
{
134-
return $this->getRealCurrentLineNb();
135-
}
136-
137127
private function doParse($value, $flags)
138128
{
139129
$this->currentLineNb = -1;
@@ -463,9 +453,11 @@ private function parseBlock($offset, $yaml, $flags)
463453
/**
464454
* Returns the current line number (takes the offset into account).
465455
*
456+
* @internal
457+
*
466458
* @return int The current line number
467459
*/
468-
private function getRealCurrentLineNb()
460+
public function getRealCurrentLineNb()
469461
{
470462
$realCurrentLineNumber = $this->currentLineNb + $this->offset;
471463

0 commit comments

Comments
 (0)