Skip to content

Commit 6e4a258

Browse files
[Yaml] Clean some messages + add test case
1 parent 1a9d264 commit 6e4a258

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Inline.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter
249249
$output = $match[1];
250250
$i += strlen($output);
251251
} else {
252-
throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
252+
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar));
253253
}
254254

255255
if ($evaluate) {
@@ -273,7 +273,7 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter
273273
private static function parseQuotedScalar($scalar, &$i)
274274
{
275275
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
276-
throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
276+
throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)));
277277
}
278278

279279
$output = substr($match[0], 1, strlen($match[0]) - 2);
@@ -346,7 +346,7 @@ private static function parseSequence($sequence, &$i = 0, $references = array())
346346
++$i;
347347
}
348348

349-
throw new ParseException(sprintf('Malformed inline YAML string %s', $sequence));
349+
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence));
350350
}
351351

352352
/**
@@ -434,7 +434,7 @@ private static function parseMapping($mapping, &$i = 0, $references = array())
434434
}
435435
}
436436

437-
throw new ParseException(sprintf('Malformed inline YAML string %s', $mapping));
437+
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping));
438438
}
439439

440440
/**

Tests/InlineTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,4 +401,13 @@ public function getTestsForDump()
401401
array('{ foo: { bar: { 1: 2, baz: 3 } } }', array('foo' => array('bar' => array(1 => 2, 'baz' => 3)))),
402402
);
403403
}
404+
405+
/**
406+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
407+
* @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported}.
408+
*/
409+
public function testNotSupportedMissingValue()
410+
{
411+
Inline::parse('{this, is not, supported}');
412+
}
404413
}

0 commit comments

Comments
 (0)