Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9bdaba4

Browse filesBrowse files
committed
[Yaml] fix exception contexts
1 parent 7830fa7 commit 9bdaba4
Copy full SHA for 9bdaba4

File tree

2 files changed

+5
-5
lines changed
Filter options

2 files changed

+5
-5
lines changed

‎src/Symfony/Component/Yaml/Parser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Parser.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
8888
$isRef = $isInPlace = $isProcessed = false;
8989
if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
9090
if ($context && 'mapping' == $context) {
91-
throw new ParseException('You cannot define a sequence item when in a mapping');
91+
throw new ParseException('You cannot define a sequence item when in a mapping', $this->getRealCurrentLineNb() + 1, $this->currentLine);
9292
}
9393
$context = 'sequence';
9494

@@ -127,7 +127,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
127127
}
128128
} elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'")))) {
129129
if ($context && 'sequence' == $context) {
130-
throw new ParseException('You cannot define a mapping item when in a sequence');
130+
throw new ParseException('You cannot define a mapping item when in a sequence', $this->currentLineNb + 1, $this->currentLine);
131131
}
132132
$context = 'mapping';
133133

@@ -214,7 +214,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
214214
} else {
215215
// multiple documents are not supported
216216
if ('---' === $this->currentLine) {
217-
throw new ParseException('Multiple documents are not supported.');
217+
throw new ParseException('Multiple documents are not supported.', $this->currentLineNb + 1, $this->currentLine);
218218
}
219219

220220
// 1-liner optionally followed by newline(s)
@@ -449,7 +449,7 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport)
449449
}
450450

451451
if (!array_key_exists($value, $this->refs)) {
452-
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLine);
452+
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine);
453453
}
454454

455455
return $this->refs[$value];

‎src/Symfony/Component/Yaml/Tests/ParserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/ParserTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ public function testShortcutKeyUnindentedCollectionException()
525525

526526
/**
527527
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
528-
* @expectedExceptionMessage Multiple documents are not supported.
528+
* @expectedExceptionMessageRegExp /^Multiple documents are not supported.+/
529529
*/
530530
public function testMultipleDocumentsNotSupportedException()
531531
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.