deprecate missing space after mapping key colon

This commit is contained in:
Christian Flothmann 2016-07-28 23:09:37 +02:00
parent 983b560e15
commit 9a31eeff56
2 changed files with 18 additions and 2 deletions

View File

@ -456,6 +456,11 @@ class Inline
// key
$key = self::parseScalar($mapping, $flags, array(':', ' '), array('"', "'"), $i, false);
$i = strpos($mapping, ':', $i);
if (!isset($mapping[$i + 1]) || ' ' !== $mapping[$i + 1]) {
@trigger_error('Omitting the space after the colon that follows a mapping key definition is deprecated since version 3.2 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
}
// value
$done = false;

View File

@ -165,6 +165,17 @@ class InlineTest extends \PHPUnit_Framework_TestCase
Inline::parse($value);
}
/**
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
*/
public function testParseMappingKeyWithColonNotFollowedBySpace()
{
ErrorAssert::assertDeprecationsAreTriggered('Omitting the space after the colon that follows a mapping key definition is deprecated since version 3.2 and will throw a ParseException in 4.0.', function () {
Inline::parse('{1:""}');
});
}
/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
*/