[Yaml] Deprecate using the non-specific tag

This commit is contained in:
Guilhem Niot 2017-05-25 11:38:18 +02:00
parent b0ede2c9c8
commit 60f5046661
6 changed files with 20 additions and 2 deletions

View File

@ -10,7 +10,7 @@ Finder
------
* The `Symfony\Component\Finder\Iterator\FilterIterator` class has been
deprecated and will be removed in 4.0 as it used to fix a bug which existed
deprecated and will be removed in 4.0 as it used to fix a bug which existed
before version 5.5.23/5.6.7.
Validator
@ -18,3 +18,9 @@ Validator
* Not setting the `strict` option of the `Choice` constraint to `true` is
deprecated and will throw an exception in Symfony 4.0.
Yaml
----
* Using the non-specific tag `!` is deprecated and will have a different
behavior in 4.0. Use a plain integer or `!!float` instead.

View File

@ -685,3 +685,6 @@ Yaml
* The constructor arguments `$offset`, `$totalNumberOfLines` and
`$skippedLineNumbers` of the `Parser` class were removed.
* The behavior of the non-specific tag `!` is changed and now forces
non-evaluating your values.

View File

@ -1,6 +1,12 @@
CHANGELOG
=========
3.4.0
-----
* Deprecated using the non-specific tag `!` as its behavior will change in 4.0.
It will force non-evaluating your values in 4.0. Use plain integers or `!!float` instead.
3.3.0
-----

View File

@ -611,6 +611,8 @@ class Inline
case 0 === strpos($scalar, '!str'):
return (string) substr($scalar, 5);
case 0 === strpos($scalar, '! '):
@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);
return (int) self::parseScalar(substr($scalar, 2), $flags);
case 0 === strpos($scalar, '!php/object:'):
if (self::$objectSupport) {

View File

@ -928,6 +928,7 @@ documents: 2
---
test: Explicit typing
deprecated: Using the non-specific tag "!" is deprecated since version 3.4 as its behavior will change in 4.0.
yaml: |
integer: 12
also int: ! "12"

View File

@ -61,7 +61,7 @@ class ParserTest extends TestCase
restore_error_handler();
$this->assertCount(1, $deprecations);
$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]);
$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]);
}
}