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

Skip to content

Commit 3380346

Browse files
committed
[Yaml] deprecate parsing the !!php/object tag
1 parent f146c8d commit 3380346

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ private static function evaluateScalar($scalar, $references = array())
488488
return;
489489
case 0 === strpos($scalar, '!!php/object:'):
490490
if (self::$objectSupport) {
491+
@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);
492+
491493
return unserialize(substr($scalar, 13));
492494
}
493495

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,19 @@ public function testBlockLiteralWithLeadingNewlines()
422422
public function testObjectSupportEnabled()
423423
{
424424
$input = <<<EOF
425-
foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
425+
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
426426
bar: 1
427427
EOF;
428428
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
429+
}
429430

431+
/**
432+
* @group legacy
433+
*/
434+
public function testObjectSupportEnabledWithDeprecatedTag()
435+
{
430436
$input = <<<EOF
431-
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
437+
foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
432438
bar: 1
433439
EOF;
434440
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');

0 commit comments

Comments
 (0)