feature #19504 [Yaml] deprecate missing space after mapping key colon (xabbuh)
This PR was merged into the 3.2-dev branch.
Discussion
----------
[Yaml] deprecate missing space after mapping key colon
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | #19436, #19472
| License | MIT
| Doc PR |
Commits
-------
9a31eef
deprecate missing space after mapping key colon
This commit is contained in:
commit
e408b50c5a
@ -456,6 +456,11 @@ class Inline
|
|||||||
|
|
||||||
// key
|
// key
|
||||||
$key = self::parseScalar($mapping, $flags, array(':', ' '), array('"', "'"), $i, false);
|
$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
|
// value
|
||||||
$done = false;
|
$done = false;
|
||||||
|
@ -165,6 +165,17 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
|||||||
Inline::parse($value);
|
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
|
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user