8000 [Yaml] deprecate parsing mappings without keys by xabbuh · Pull Request #21643 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Yaml] deprecate parsing mappings without keys #21643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UPGRADE-3.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Workflow
Yaml
----

* Omitting the key of a mapping is deprecated and will throw a `ParseException` in Symfony 4.0.

* The constructor arguments `$offset`, `$totalNumberOfLines` and
`$skippedLineNumbers` of the `Parser` class are deprecated and will be
removed in 4.0
2 changes: 2 additions & 0 deletions UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ Validator
Yaml
----

* Omitting the key of a mapping is not supported anymore and throws a `ParseException`.

* Mappings with a colon (`:`) that is not followed by a whitespace are not
supported anymore and lead to a `ParseException`(e.g. `foo:bar` must be
`foo: bar`).
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Yaml/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

3.3.0
-----

* Omitting the key of a mapping is deprecated and will throw a `ParseException` in Symfony 4.0.

3.2.0
-----

Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Yaml/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
break;
}

if (':' === $key) {
@trigger_error('Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
}

if (':' !== $key && (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
@trigger_error('Using a colon that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}" is deprecated since version 3.2 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Yaml/Tests/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,10 @@ public function testVeryLongQuotedStrings()
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
}

/**
* @group legacy
* @expectedDeprecation Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0.
*/
public function testOmittedMappingKeyIsParsedAsColon()
{
$this->assertSame(array(':' => 'foo'), Inline::parse('{: foo}'));
Expand Down
0