Skip to content

Commit 8ee9609

Browse files
committed
[Yaml] Deprecate tags using colon
1 parent 7695112 commit 8ee9609

File tree

15 files changed

+166
-43
lines changed

15 files changed

+166
-43
lines changed

UPGRADE-3.4.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ FrameworkBundle
3030
require symfony/stopwatch` in your `dev` environment.
3131

3232
* Using the `KERNEL_DIR` environment variable or the automatic guessing based
33-
on the `phpunit.xml` / `phpunit.xml.dist` file location is deprecated since 3.4.
33+
on the `phpunit.xml` / `phpunit.xml.dist` file location is deprecated since 3.4.
3434
Set the `KERNEL_CLASS` environment variable to the fully-qualified class name
35-
of your Kernel instead. Not setting the `KERNEL_CLASS` environment variable
36-
will throw an exception on 4.0 unless you override the `KernelTestCase::createKernel()`
35+
of your Kernel instead. Not setting the `KERNEL_CLASS` environment variable
36+
will throw an exception on 4.0 unless you override the `KernelTestCase::createKernel()`
3737
or `KernelTestCase::getKernelClass()` method.
38-
39-
* The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
38+
39+
* The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
4040
methods are deprecated since 3.4 and will be removed in 4.0.
4141

4242
* The `--no-prefix` option of the `translation:update` command is deprecated and
@@ -83,7 +83,7 @@ TwigBridge
8383
* deprecated the `Symfony\Bridge\Twig\Form\TwigRenderer` class, use the `FormRenderer`
8484
class from the Form component instead
8585

86-
* deprecated `Symfony\Bridge\Twig\Command\DebugCommand::set/getTwigEnvironment` and the ability
86+
* deprecated `Symfony\Bridge\Twig\Command\DebugCommand::set/getTwigEnvironment` and the ability
8787
to pass a command name as first argument
8888

8989
* deprecated `Symfony\Bridge\Twig\Command\LintCommand::set/getTwigEnvironment` and the ability
@@ -95,7 +95,7 @@ TwigBundle
9595
* deprecated the `Symfony\Bundle\TwigBundle\Command\DebugCommand` class, use the `DebugCommand`
9696
class from the Twig bridge instead
9797

98-
* deprecated relying on the `ContainerAwareInterface` implementation for
98+
* deprecated relying on the `ContainerAwareInterface` implementation for
9999
`Symfony\Bundle\TwigBundle\Command\LintCommand`
100100

101101
Validator
@@ -107,6 +107,24 @@ Validator
107107
Yaml
108108
----
109109

110+
* using the `!php/object:` tag is deprecated and won't be supported in 4.0. Use
111+
the `!php/object` tag (without the colon) instead.
112+
113+
* using the `!php/const:` tag is deprecated and won't be supported in 4.0. Use
114+
the `!php/const` tag (without the colon) instead.
115+
116+
Before:
117+
118+
```yml
119+
!php/const:PHP_INT_MAX
120+
```
121+
122+
After:
123+
124+
```yml
125+
!php/const PHP_INT_MAX
126+
```
127+
110128
* Support for the `!str` tag is deprecated, use the `!!str` tag instead.
111129

112130
* Using the non-specific tag `!` is deprecated and will have a different

UPGRADE-4.0.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ FrameworkBundle
336336
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass` class
337337
has been removed. Use the `Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass`
338338
class instead.
339-
339+
340340
* Using the `KERNEL_DIR` environment variable and the automatic guessing based
341-
on the `phpunit.xml` file location have been removed from the `KernelTestCase::getKernelClass()`
341+
on the `phpunit.xml` file location have been removed from the `KernelTestCase::getKernelClass()`
342342
method implementation. Set the `KERNEL_CLASS` environment variable to the
343-
fully-qualified class name of your Kernel or override the `KernelTestCase::createKernel()`
343+
fully-qualified class name of your Kernel or override the `KernelTestCase::createKernel()`
344344
or `KernelTestCase::getKernelClass()` method instead.
345-
345+
346346
* The methods `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
347347
have been removed.
348348

@@ -771,3 +771,21 @@ Yaml
771771

772772
* The behavior of the non-specific tag `!` is changed and now forces
773773
non-evaluating your values.
774+
775+
* The `!php/object:` tag was removed in favor of the `!php/object` tag (without
776+
the colon).
777+
778+
* The `!php/const:` tag was removed in favor of the `!php/const` tag (without
779+
the colon).
780+
781+
Before:
782+
783+
```yml
784+
!php/const:PHP_INT_MAX
785+
```
786+
787+
After:
788+
789+
```yml
790+
!php/const PHP_INT_MAX
791+
```

src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ parameters:
55
- false
66
- 0
77
- 1000.3
8-
- !php/const:PHP_INT_MAX
8+
- !php/const PHP_INT_MAX
99
bar: foo
1010
escape: '@@escapeme'
1111
foo_bar: '@foo_bar'

src/Symfony/Component/DependencyInjection/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"psr/container": "^1.0"
2121
},
2222
"require-dev": {
23-
"symfony/yaml": "~3.3|~4.0",
23+
"symfony/yaml": "~3.4|~4.0",
2424
"symfony/config": "~3.3|~4.0",
2525
"symfony/expression-language": "~2.8|~3.0|~4.0"
2626
},
@@ -34,7 +34,7 @@
3434
"conflict": {
3535
"symfony/config": "<3.3.1",
3636
"symfony/finder": "<3.3",
37-
"symfony/yaml": "<3.3"
37+
"symfony/yaml": "<3.4"
3838
},
3939
"provide": {
4040
"psr/container-implementation": "1.0"

src/Symfony/Component/Serializer/Tests/Encoder/YamlEncoderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public function testContext()
6161
$obj = new \stdClass();
6262
$obj->bar = 2;
6363

64-
$this->assertEquals(" foo: !php/object:O:8:\"stdClass\":1:{s:3:\"bar\";i:2;}\n", $encoder->encode(array('foo' => $obj), 'yaml'));
64+
$this->assertEquals(" foo: !php/object 'O:8:\"stdClass\":1:{s:3:\"bar\";i:2;}'\n", $encoder->encode(array('foo' => $obj), 'yaml'));
6565
$this->assertEquals(' { foo: null }', $encoder->encode(array('foo' => $obj), 'yaml', array('yaml_inline' => 0, 'yaml_indent' => 2, 'yaml_flags' => 0)));
66-
$this->assertEquals(array('foo' => $obj), $encoder->decode('foo: !php/object:O:8:"stdClass":1:{s:3:"bar";i:2;}', 'yaml'));
67-
$this->assertEquals(array('foo' => null), $encoder->decode('foo: !php/object:O:8:"stdClass":1:{s:3:"bar";i:2;}', 'yaml', array('yaml_flags' => 0)));
66+
$this->assertEquals(array('foo' => $obj), $encoder->decode("foo: !php/object 'O:8:\"stdClass\":1:{s:3:\"bar\";i:2;}'", 'yaml'));
67+
$this->assertEquals(array('foo' => null), $encoder->decode("foo: !php/object 'O:8:\"stdClass\":1:{s:3:\"bar\";i:2;}'", 'yaml', array('yaml_flags' => 0)));
6868
}
6969
}

src/Symfony/Component/Serializer/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": ">=5.5.9"
2020
},
2121
"require-dev": {
22-
"symfony/yaml": "~3.3|~4.0",
22+
"symfony/yaml": "~3.4|~4.0",
2323
"symfony/config": "~2.8|~3.0|~4.0",
2424
"symfony/property-access": "~2.8|~3.0|~4.0",
2525
"symfony/http-foundation": "~2.8|~3.0|~4.0",
@@ -34,7 +34,7 @@
3434
"symfony/dependency-injection": "<3.2",
3535
"symfony/property-access": ">=3.0,<3.0.4|>=2.8,<2.8.4",
3636
"symfony/property-info": "<3.1",
37-
"symfony/yaml": "<3.3"
37+
"symfony/yaml": "<3.4"
3838
},
3939
"suggest": {
4040
"psr/cache-implementation": "For using the metadata cache.",

src/Symfony/Component/Validator/Tests/Mapping/Loader/mapping-with-constants.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Symfony\Component\Validator\Tests\Fixtures\Entity:
55
properties:
66
firstName:
77
- Range:
8-
max: !php/const:PHP_INT_MAX
8+
max: !php/const PHP_INT_MAX

src/Symfony/Component/Validator/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"symfony/http-kernel": "^3.3.5|~4.0",
2626
"symfony/var-dumper": "~3.3|~4.0",
2727
"symfony/intl": "^2.8.18|^3.2.5|~4.0",
28-
"symfony/yaml": "~3.3|~4.0",
28+
"symfony/yaml": "~3.4|~4.0",
2929
"symfony/config": "~2.8|~3.0|~4.0",
3030
"symfony/dependency-injection": "~3.3|~4.0",
3131
"symfony/expression-language": "~2.8|~3.0|~4.0",
@@ -39,7 +39,7 @@
3939
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
4040
"symfony/dependency-injection": "<3.3",
4141
"symfony/http-kernel": "<3.3.5",
42-
"symfony/yaml": "<3.3"
42+
"symfony/yaml": "<3.4"
4343
},
4444
"suggest": {
4545
"psr/cache-implementation": "For using the metadata cache.",

src/Symfony/Component/Yaml/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ CHANGELOG
44
3.4.0
55
-----
66

7+
* Deprecated the tag`!php/object:` tag which will be replaced by the
8+
`!php/object` tag (without the colon) in 4.0.
9+
10+
* Deprecated the tag`!php/const:` tag which will be replaced by the
11+
`!php/const` tag (without the colon) in 4.0.
12+
713
* Support for the `!str` tag is deprecated, use the `!!str` tag instead.
814

915
* Deprecated using the non-specific tag `!` as its behavior will change in 4.0.

src/Symfony/Component/Yaml/Inline.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static function dump($value, $flags = 0)
170170
}
171171

172172
if (Yaml::DUMP_OBJECT & $flags) {
173-
return '!php/object:'.serialize($value);
173+
return '!php/object '.self::dump(serialize($value));
174174
}
175175

176176
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) {
@@ -620,6 +620,8 @@ private static function evaluateScalar($scalar, $flags, $references = array())
620620
return (int) self::parseScalar(substr($scalar, 2), $flags);
621621
case 0 === strpos($scalar, '!php/object:'):
622622
if (self::$objectSupport) {
623+
@trigger_error('The !php/object: tag to indicate dumped PHP objects is deprecated since version 3.4 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.', E_USER_DEPRECATED);
624+
623625
return unserialize(substr($scalar, 12));
624626
}
625627

@@ -630,7 +632,7 @@ private static function evaluateScalar($scalar, $flags, $references = array())
630632
return;
631633
case 0 === strpos($scalar, '!!php/object:'):
632634
if (self::$objectSupport) {
633-
@trigger_error('The !!php/object tag to indicate dumped PHP objects is deprecated since version 3.1 and will be removed in 4.0. Use the !php/object tag instead.', E_USER_DEPRECATED);
635+
@trigger_error('The !!php/object: tag to indicate dumped PHP objects is deprecated since version 3.1 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.', E_USER_DEPRECATED);
634636

635637
return unserialize(substr($scalar, 13));
636638
}
@@ -639,9 +641,21 @@ private static function evaluateScalar($scalar, $flags, $references = array())
639641
throw new ParseException('Object support when parsing a YAML file has been disabled.');
640642
}
641643

644+
return;
645+
case 0 === strpos($scalar, '!php/object'):
646+
if (self::$objectSupport) {
647+
return unserialize(self::parseScalar(substr($scalar, 12)));
648+
}
649+
650+
if (self::$exceptionOnInvalidType) {
651+
throw new ParseException('Object support when parsing a YAML file has been disabled.');
652+
}
653+
642654
return;
643655
case 0 === strpos($scalar, '!php/const:'):
644656
if (self::$constantSupport) {
657+
@trigger_error('The !php/const: tag to indicate dumped PHP constants is deprecated since version 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead.', E_USER_DEPRECATED);
658+
645659
if (defined($const = substr($scalar, 11))) {
646660
return constant($const);
647661
}
@@ -652,6 +666,20 @@ private static function evaluateScalar($scalar, $flags, $references = array())
652666
throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar));
653667
}
654668

669+
return;
670+
671+
case 0 === strpos($scalar, '!php/const'):
672+
if (self::$constantSupport) {
673+
if (defined($const = self::parseScalar(substr($scalar, 11)))) {
674+
return constant($const);
675+
}
676+
677+
throw new ParseException(sprintf('The constant "%s" is not defined.', $const));
678+
}
679+
if (self::$exceptionOnInvalidType) {
680+
throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar));
681+
}
682+
655683
return;
656684
case 0 === strpos($scalar, '!!float '):
657685
return (float) substr($scalar, 8);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy