Skip to content

Commit 9815af3

Browse files
GuilhemNxabbuh
authored andcommitted
[Yaml] Deprecate tags using colon
1 parent 8e517f6 commit 9815af3

File tree

15 files changed

+166
-44
lines changed

15 files changed

+166
-44
lines changed

UPGRADE-3.4.md

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

3939
* Using the `KERNEL_DIR` environment variable or the automatic guessing based
40-
on the `phpunit.xml` / `phpunit.xml.dist` file location is deprecated since 3.4.
40+
on the `phpunit.xml` / `phpunit.xml.dist` file location is deprecated since 3.4.
4141
Set the `KERNEL_CLASS` environment variable to the fully-qualified class name
42-
of your Kernel instead. Not setting the `KERNEL_CLASS` environment variable
43-
will throw an exception on 4.0 unless you override the `KernelTestCase::createKernel()`
42+
of your Kernel instead. Not setting the `KERNEL_CLASS` environment variable
43+
will throw an exception on 4.0 unless you override the `KernelTestCase::createKernel()`
4444
or `KernelTestCase::getKernelClass()` method.
45-
46-
* The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
45+
46+
* The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
4747
methods are deprecated since 3.4 and will be removed in 4.0.
4848

4949
* The `--no-prefix` option of the `translation:update` command is deprecated and
@@ -90,7 +90,7 @@ TwigBridge
9090
* deprecated the `Symfony\Bridge\Twig\Form\TwigRenderer` class, use the `FormRenderer`
9191
class from the Form component instead
9292

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

9696
* deprecated `Symfony\Bridge\Twig\Command\LintCommand::set/getTwigEnvironment` and the ability
@@ -102,7 +102,7 @@ TwigBundle
102102
* deprecated the `Symfony\Bundle\TwigBundle\Command\DebugCommand` class, use the `DebugCommand`
103103
class from the Twig bridge instead
104104

105-
* deprecated relying on the `ContainerAwareInterface` implementation for
105+
* deprecated relying on the `ContainerAwareInterface` implementation for
106106
`Symfony\Bundle\TwigBundle\Command\LintCommand`
107107

108108
Validator
@@ -114,6 +114,24 @@ Validator
114114
Yaml
115115
----
116116

117+
* using the `!php/object:` tag is deprecated and won't be supported in 4.0. Use
118+
the `!php/object` tag (without the colon) instead.
119+
120+
* using the `!php/const:` tag is deprecated and won't be supported in 4.0. Use
121+
the `!php/const` tag (without the colon) instead.
122+
123+
Before:
124+
125+
```yml
126+
!php/const:PHP_INT_MAX
127+
```
128+
129+
After:
130+
131+
```yml
132+
!php/const PHP_INT_MAX
133+
```
134+
117135
* Support for the `!str` tag is deprecated, use the `!!str` tag instead.
118136

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

UPGRADE-4.0.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ FrameworkBundle
345345
class instead.
346346

347347
* Using the `KERNEL_DIR` environment variable and the automatic guessing based
348-
on the `phpunit.xml` file location have been removed from the `KernelTestCase::getKernelClass()`
348+
on the `phpunit.xml` file location have been removed from the `KernelTestCase::getKernelClass()`
349349
method implementation. Set the `KERNEL_CLASS` environment variable to the
350-
fully-qualified class name of your Kernel or override the `KernelTestCase::createKernel()`
350+
fully-qualified class name of your Kernel or override the `KernelTestCase::createKernel()`
351351
or `KernelTestCase::getKernelClass()` method instead.
352352

353353
* The `Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory` class has been removed.
@@ -356,10 +356,10 @@ FrameworkBundle
356356
* The `--no-prefix` option of the `translation:update` command has
357357
been removed.
358358

359-
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass` class has been removed.
359+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass` class has been removed.
360360
Use the `Symfony\Component\HttpKernel\DependencyInjection\AddCacheClearerPass` class instead.
361361

362-
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass` class has been removed.
362+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass` class has been removed.
363363
Use the `Symfony\Component\HttpKernel\DependencyInjection\AddCacheWarmerPass` class instead.
364364

365365
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass`
@@ -561,7 +561,7 @@ TwigBridge
561561
* The `TwigRendererEngine::setEnvironment()` method has been removed.
562562
Pass the Twig Environment as second argument of the constructor instead.
563563

564-
* Removed `Symfony\Bridge\Twig\Command\DebugCommand::set/getTwigEnvironment` and the ability
564+
* Removed `Symfony\Bridge\Twig\Command\DebugCommand::set/getTwigEnvironment` and the ability
565565
to pass a command name as first argument.
566566

567567
* Removed `Symfony\Bridge\Twig\Command\LintCommand::set/getTwigEnvironment` and the ability
@@ -773,3 +773,21 @@ Yaml
773773

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

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
},
@@ -35,7 +35,7 @@
3535
"symfony/config": "<3.3.1",
3636
"symfony/finder": "<3.3",
3737
"symfony/proxy-manager-bridge": "<3.4",
38-
"symfony/yaml": "<3.3"
38+
"symfony/yaml": "<3.4"
3939
},
4040
"provide": {
4141
"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 `!php/object:` tag which will be replaced by the
8+
`!php/object` tag (without the colon) in 4.0.
9+
10+
* Deprecated the `!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: 29 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,19 @@ 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+
case 0 === strpos($scalar, '!php/const'):
671+
if (self::$constantSupport) {
672+
if (defined($const = self::parseScalar(substr($scalar, 11)))) {
673+
return constant($const);
674+
}
675+
676+
throw new ParseException(sprintf('The constant "%s" is not defined.', $const));
677+
}
678+
if (self::$exceptionOnInvalidType) {
679+
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));
680+
}
681+
655682
return;
656683
case 0 === strpos($scalar, '!!float '):
657684
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