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 b414587

Browse filesBrowse files
committed
Suggest using quotes instead of Yaml::PARSE_KEYS_AS_STRINGS
1 parent 0763898 commit b414587
Copy full SHA for b414587

File tree

7 files changed

+23
-31
lines changed
Filter options

7 files changed

+23
-31
lines changed

‎UPGRADE-3.3.md

Copy file name to clipboardExpand all lines: UPGRADE-3.3.md
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,16 +365,14 @@ Yaml
365365

366366
* Deprecated support for implicitly parsing non-string mapping keys as strings.
367367
Mapping keys that are no strings will lead to a `ParseException` in Symfony
368-
4.0. Use the `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as
369-
strings.
368+
4.0. Use quotes to opt-in for keys to be parsed as strings.
370369

371370
Before:
372371

373372
```php
374373
$yaml = <<<YAML
375374
null: null key
376375
true: boolean true
377-
1: integer key
378376
2.0: float key
379377
YAML;
380378

@@ -386,13 +384,12 @@ Yaml
386384
```php
387385

388386
$yaml = <<<YAML
389-
null: null key
390-
true: boolean true
391-
1: integer key
392-
2.0: float key
387+
"null": null key
388+
"true": boolean true
389+
"2.0": float key
393390
YAML;
394391

395-
Yaml::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS);
392+
Yaml::parse($yaml);
396393
```
397394

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

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ FrameworkBundle
326326
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass` class
327327
has been removed. Use the `Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass`
328328
class instead.
329-
330-
* The `Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory` class has been removed.
329+
330+
* The `Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory` class has been removed.
331331
Use `Symfony\Component\Validator\ContainerConstraintValidatorFactory` instead.
332332

333333
HttpFoundation
@@ -555,16 +555,15 @@ Yaml
555555
throws a `ParseException`.
556556

557557
* Removed support for implicitly parsing non-string mapping keys as strings.
558-
Mapping keys that are no strings will result in a `ParseException`. Use the
559-
`PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as strings.
558+
Mapping keys that are no strings will result in a `ParseException`. Use
559+
quotes to opt-in for keys to be parsed as strings.
560560

561561
Before:
562562

563563
```php
564564
$yaml = <<<YAML
565565
null: null key
566566
true: boolean true
567-
1: integer key
568567
2.0: float key
569568
YAML;
570569

@@ -576,13 +575,12 @@ Yaml
576575
```php
577576

578577
$yaml = <<<YAML
579-
null: null key
580-
true: boolean true
581-
1: integer key
582-
2.0: float key
578+
"null": null key
579+
"true": boolean true
580+
"2.0": float key
583581
YAML;
584582

585-
Yaml::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS);
583+
Yaml::parse($yaml);
586584
```
587585

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

‎src/Symfony/Component/Yaml/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/CHANGELOG.md
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ CHANGELOG
99

1010
* Deprecated support for implicitly parsing non-string mapping keys as strings.
1111
Mapping keys that are no strings will lead to a `ParseException` in Symfony
12-
4.0. Use the `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as
13-
strings.
12+
4.0. Use quotes to opt-in for keys to be parsed as strings.
1413

1514
Before:
1615

1716
```php
1817
$yaml = <<<YAML
1918
null: null key
2019
true: boolean true
21-
1: integer key
2220
2.0: float key
2321
YAML;
2422

@@ -30,13 +28,12 @@ CHANGELOG
3028
```php
3129

3230
$yaml = <<<YAML
33-
null: null key
34-
true: boolean true
35-
1: integer key
36-
2.0: float key
31+
"null": null key
32+
"true": boolean true
33+
"2.0": float key
3734
YAML;
3835

39-
Yaml::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS);
36+
Yaml::parse($yaml);
4037
```
4138

4239
* Omitted mapping values will be parsed as `null`.

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Inline.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
494494
$evaluatedKey = self::evaluateScalar($key, $flags, $references);
495495

496496
if ('' !== $key && $evaluatedKey !== $key && !is_string($evaluatedKey) && !is_int($evaluatedKey)) {
497-
@trigger_error('Implicit casting of incompatible mapping keys to strings is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRINGS flag to explicitly enable the type casts.', E_USER_DEPRECATED);
497+
@trigger_error('Implicit casting of incompatible mapping keys to strings is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.', E_USER_DEPRECATED);
498498
}
499499
}
500500

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Parser.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private function doParse($value, $flags)
238238

239239
if (!(Yaml::PARSE_KEYS_AS_STRINGS & $flags) && !is_string($key) && !is_int($key)) {
240240
$keyType = is_numeric($key) ? 'numeric key' : 'non-string key';
241-
@trigger_error(sprintf('Implicit casting of %s to string is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRINGS flag to explicitly enable the type casts.', $keyType), E_USER_DEPRECATED);
241+
@trigger_error(sprintf('Implicit casting of %s to string is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.', $keyType), E_USER_DEPRECATED);
242242
}
243243

244244
// Convert float keys to strings, to avoid being converted to integers by PHP

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

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

731731
/**
732732
* @group legacy
733-
* @expectedDeprecation Implicit casting of incompatible mapping keys to strings is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRINGS flag to explicitly enable the type casts.
733+
* @expectedDeprecation Implicit casting of incompatible mapping keys to strings is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.
734734
* @dataProvider getNotPhpCompatibleMappingKeyData
735735
*/
736736
public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/ParserTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ public function testYamlDirective()
10811081

10821082
/**
10831083
* @group legacy
1084-
* @expectedDeprecation Implicit casting of numeric key to string is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRINGS flag to explicitly enable the type casts.
1084+
* @expectedDeprecation Implicit casting of numeric key to string is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.
10851085
*/
10861086
public function testFloatKeys()
10871087
{
@@ -1103,7 +1103,7 @@ public function testFloatKeys()
11031103

11041104
/**
11051105
* @group legacy
1106-
* @expectedDeprecation Implicit casting of non-string key to string is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRINGS flag to explicitly enable the type casts.
1106+
* @expectedDeprecation Implicit casting of non-string key to string is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.
11071107
*/
11081108
public function testBooleanKeys()
11091109
{

0 commit comments

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