Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e992eae

Browse files
committed
feature #22909 [Yaml] Deprecate using the non-specific tag (GuilhemN)
This PR was merged into the 3.4 branch. Discussion ---------- [Yaml] Deprecate using the non-specific tag | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Values tagged with the non-specific tag must not be transformed in an integer, this tag means that they must not be evaluated (see [the spec](http://www.yaml.org/spec/1.2/spec.html#tag/non-specific/)). I applied this change in #22762 to comply with the spec. Commits ------- 60f5046 [Yaml] Deprecate using the non-specific tag
2 parents bf094ef + 60f5046 commit e992eae

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed

UPGRADE-3.4.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Finder
1010
------
1111

1212
* The `Symfony\Component\Finder\Iterator\FilterIterator` class has been
13-
deprecated and will be removed in 4.0 as it used to fix a bug which existed
13+
deprecated and will be removed in 4.0 as it used to fix a bug which existed
1414
before version 5.5.23/5.6.7.
1515

1616
FrameworkBundle
@@ -54,3 +54,9 @@ Validator
5454

5555
* Not setting the `strict` option of the `Choice` constraint to `true` is
5656
deprecated and will throw an exception in Symfony 4.0.
57+
58+
Yaml
59+
----
60+
61+
* Using the non-specific tag `!` is deprecated and will have a different
62+
behavior in 4.0. Use a plain integer or `!!float` instead.

UPGRADE-4.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,3 +702,6 @@ Yaml
702702

703703
* The constructor arguments `$offset`, `$totalNumberOfLines` and
704704
`$skippedLineNumbers` of the `Parser` class were removed.
705+
706+
* The behavior of the non-specific tag `!` is changed and now forces
707+
non-evaluating your values.

src/Symfony/Component/Yaml/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
3.4.0
5+
-----
6+
7+
* Deprecated using the non-specific tag `!` as its behavior will change in 4.0.
8+
It will force non-evaluating your values in 4.0. Use plain integers or `!!float` instead.
9+
410
3.3.0
511
-----
612

src/Symfony/Component/Yaml/Inline.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,8 @@ private static function evaluateScalar($scalar, $flags, $references = array())
611611
case 0 === strpos($scalar, '!str'):
612612
return (string) substr($scalar, 5);
613613
case 0 === strpos($scalar, '! '):
614+
@trigger_error('Using the non-specific tag "!" is deprecated since version 3.4 as its behavior will change in 4.0. It will force non-evaluating your values in 4.0. Use plain integers or !!float instead.', E_USER_DEPRECATED);
615+
614616
return (int) self::parseScalar(substr($scalar, 2), $flags);
615617
case 0 === strpos($scalar, '!php/object:'):
616618
if (self::$objectSupport) {

src/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ documents: 2
928928

929929
---
930930
test: Explicit typing
931+
deprecated: Using the non-specific tag "!" is deprecated since version 3.4 as its behavior will change in 4.0.
931932
yaml: |
932933
integer: 12
933934
also int: ! "12"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testSpecifications($expected, $yaml, $comment, $deprecated)
6161
restore_error_handler();
6262

6363
$this->assertCount(1, $deprecations);
64-
$this->assertContains('Using the comma as a group separator for floats is deprecated since version 3.2 and will be removed in 4.0.', $deprecations[0]);
64+
$this->assertContains(true !== $deprecated ? $deprecated : 'Using the comma as a group separator for floats is deprecated since version 3.2 and will be removed in 4.0.', $deprecations[0]);
6565
}
6666
}
6767

0 commit comments

Comments
 (0)