8000 remove legacy php/const and php/object tag support · symfony/symfony@7f6a0d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f6a0d8

Browse files
committed
remove legacy php/const and php/object tag support
1 parent b27c965 commit 7f6a0d8

File tree

3 files changed

+2
-106
lines changed

3 files changed

+2
-106
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -554,30 +554,6 @@ private static function evaluateScalar($scalar, $flags, $references = array())
554554
return (string) substr($scalar, 6);
555555
case 0 === strpos($scalar, '! '):
556556
return substr($scalar, 2);
557-
case 0 === strpos($scalar, '!php/object:'):
558-
if (self::$objectSupport) {
559-
@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);
560-
561-
return unserialize(substr($scalar, 12));
562-
}
563-
564-
if (self::$exceptionOnInvalidType) {
565-
throw new ParseException('Object support when parsing a YAML file has been disabled.');
566-
}
567-
568-
return;
569-
case 0 === strpos($scalar, '!!php/object:'):
570-
if (self::$objectSupport) {
571-
@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);
572-
573-
return unserialize(substr($scalar, 13));
574-
}
575-
576-
if (self::$exceptionOnInvalidType) {
577-
throw new ParseException('Object support when parsing a YAML file has been disabled.');
578-
}
579-
580-
return;
581557
case 0 === strpos($scalar, '!php/object'):
582558
if (self::$objectSupport) {
583559
return unserialize(self::parseScalar(substr($scalar, 12)));
@@ -587,21 +563,6 @@ private static function evaluateScalar($scalar, $flags, $references = array())
587563
throw new ParseException('Object support when parsing a YAML file has been disabled.');
588564
}
589565

590-
return;
591-
case 0 === strpos($scalar, '!php/const:'):
592-
if (self::$constantSupport) {
593-
@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);
594-
595-
if (defined($const = substr($scalar, 11))) {
596-
return constant($const);
597-
}
598-
599-
throw new ParseException(sprintf('The constant "%s" is not defined.', $const));
600-
}
601-
if (self::$exceptionOnInvalidType) {
602-
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));
603-
}
604-
605566
return;
606567
case 0 === strpos($scalar, '!php/const'):
607568
if (self::$constantSupport) {
@@ -690,7 +651,7 @@ private static function parseTag($value, &$i, $flags)
690651
$nextOffset += strspn($value, ' ', $nextOffset);
691652

692653
// Is followed by a scalar and is a built-in tag
693-
if ($tag && (!isset($value[$nextOffset]) || !in_array($value[$nextOffset], array('[', '{'), true)) && ('!' === $tag[0] || 'str' === $tag || 0 === strpos($tag, 'php/const:') || 0 === strpos($tag, 'php/object:'))) {
654+
if ($tag && (!isset($value[$nextOffset]) || !in_array($value[$nextOffset], array('[', '{'), true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) {
694655
// Manage in {@link self::evaluateScalar()}
695656
return;
696657
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ public function testParsePhpConstantThrowsExceptionOnInvalidType()
7474
Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
7575
}
7676

77-
/**
78-
* @group legacy
79-
* @expectedDeprecation 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.
80-
*/
81-
public function testDeprecatedConstantTag()
82-
{
83-
Inline::parse('!php/const:PHP_INT_MAX', Yaml::PARSE_CONSTANT);
84-
}
85-
8677
/**
8778
* @dataProvider getTestsForDump
8879
*/

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

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -441,39 +441,12 @@ public function testObjectSupportEnabled()
441441
public function testObjectSupportDisabledButNoExceptions()
442442
{
443443
$input = <<<'EOF'
444-
foo: !php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
444+
foo: !php/object O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
445445
bar: 1
446446
EOF;
447447
$this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
448448
}
449449

450-
/**
451-
* @group legacy
452-
* @dataProvider deprecatedObjectValueProvider
453-
*/
454-
public function testObjectSupportEnabledWithDeprecatedTag($yaml)
455-
{
456-
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($yaml, Yaml::PARSE_OBJECT), '->parse() is able to parse objects');
457-
}
458-
459-
public function deprecatedObjectValueProvider()
460-
{
461-
return array(
462-
array(
463-
<<<YAML
464-
foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
465-
bar: 1
466-
YAML
467-
),
468-
array(
469-
<<<YAML
470-
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
471-
bar: 1
472-
YAML
473-
),
474-
);
475-
}
476-
477450
/**
478451
* @dataProvider getObjectForMapTests
479452
*/
@@ -1782,35 +1755,6 @@ public function testPhpConstantTagMappingKey()
17821755

17831756
$this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT));
17841757
}
1785-
1786-
/**
1787-
* @group legacy
1788-
* @expectedDeprecation 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.
1789-
* @expectedDeprecation 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.
1790-
* @expectedDeprecation 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.
1791-
*/
1792-
public function testDeprecatedPhpConstantTagMappingKey()
1793-
{
1794-
$yaml = <<<YAML
1795-
transitions:
1796-
!php/const:Symfony\Component\Yaml\Tests\B::FOO:
1797-
from:
1798-
- !php/const:Symfony\Component\Yaml\Tests\B::BAR
1799-
to: !php/const:Symfony\Component\Yaml\Tests\B::BAZ
1800-
YAML;
1801-
$expected = array(
1802-
'transitions' => array(
1803-
'foo' => array(
1804-
'from' => array(
1805-
'bar',
1806-
),
1807-
'to' => 'baz',
1808-
),
1809-
),
1810-
);
1811-
1812-
$this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT));
1813-
}
18141758
}
18151759

18161760
class B

0 commit comments

Comments
 (0)
0