diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 70f4c35c44a9e..ae70ea6ec3079 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -601,9 +601,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer case 0 === strncmp($scalar, '!php/object', 11): if (self::$objectSupport) { if (!isset($scalar[12])) { - trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/object tag without a value is deprecated.'); - - return false; + throw new ParseException('Missing value for tag "!php/object".', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } return unserialize(self::parseScalar(substr($scalar, 12))); @@ -617,9 +615,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer case 0 === strncmp($scalar, '!php/const', 10): if (self::$constantSupport) { if (!isset($scalar[11])) { - trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/const tag without a value is deprecated.'); - - return ''; + throw new ParseException('Missing value for tag "!php/const".', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } $i = 0; @@ -660,22 +656,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer switch (true) { case ctype_digit($scalar): - if (preg_match('/^0[0-7]+$/', $scalar)) { - trigger_deprecation('symfony/yaml', '5.1', 'Support for parsing numbers prefixed with 0 as octal numbers. They will be parsed as strings as of 6.0.'); - - return octdec($scalar); - } - - $cast = (int) $scalar; - - return ($scalar === (string) $cast) ? $cast : $scalar; case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)): - if (preg_match('/^-0[0-7]+$/', $scalar)) { - trigger_deprecation('symfony/yaml', '5.1', 'Support for parsing numbers prefixed with 0 as octal numbers. They will be parsed as strings as of 6.0.'); - - return -octdec(substr($scalar, 1)); - } - $cast = (int) $scalar; return ($scalar === (string) $cast) ? $cast : $scalar; diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index e6e61981900e2..5e7451ba7228a 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -757,92 +757,73 @@ public function getTestsForOctalNumbers() } /** - * @group legacy * @dataProvider getTestsForOctalNumbersYaml11Notation */ - public function testParseOctalNumbersYaml11Notation(int $expected, string $yaml) + public function testParseOctalNumbersYaml11Notation(string $expected, string $yaml) { - $this->expectDeprecation('Since symfony/yaml 5.1: Support for parsing numbers prefixed with 0 as octal numbers. They will be parsed as strings as of 6.0.'); - self::assertSame($expected, Inline::parse($yaml)); } public function getTestsForOctalNumbersYaml11Notation() { return [ - 'positive octal number' => [28, '034'], - 'positive octal number with separator' => [1243, '0_2_3_3_3'], - 'negative octal number' => [-28, '-034'], + 'positive octal number' => ['034', '034'], + 'positive octal number with separator' => ['02333', '0_2_3_3_3'], + 'negative octal number' => ['-034', '-034'], + 'invalid positive octal number' => ['0123456789', '0123456789'], + 'invalid negative octal number' => ['-0123456789', '-0123456789'], ]; } /** * @dataProvider phpObjectTagWithEmptyValueProvider - * - * @group legacy */ - public function testPhpObjectWithEmptyValue($expected, $value) + public function testPhpObjectWithEmptyValue(string $value) { - $this->expectDeprecation('Since symfony/yaml 5.1: Using the !php/object tag without a value is deprecated.'); + $this->expectException(ParseException::class); + $this->expectExceptionMessage('Missing value for tag "!php/object" at line 1 (near "!php/object").'); - $this->assertSame($expected, Inline::parse($value, Yaml::PARSE_OBJECT)); + Inline::parse($value, Yaml::PARSE_OBJECT); } public function phpObjectTagWithEmptyValueProvider() { return [ - [false, '!php/object'], - [false, '!php/object '], - [false, '!php/object '], - [[false], '[!php/object]'], - [[false], '[!php/object ]'], - [[false, 'foo'], '[!php/object , foo]'], + ['!php/object'], + ['!php/object '], + ['!php/object '], + ['[!php/object]'], + ['[!php/object ]'], + ['[!php/object , foo]'], ]; } /** * @dataProvider phpConstTagWithEmptyValueProvider - * - * @group legacy */ - public function testPhpConstTagWithEmptyValue($expected, $value) + public function testPhpConstTagWithEmptyValue(string $value) { - $this->expectDeprecation('Since symfony/yaml 5.1: Using the !php/const tag without a value is deprecated.'); + $this->expectException(ParseException::class); + $this->expectExceptionMessage('Missing value for tag "!php/const" at line 1 (near "!php/const").'); - $this->assertSame($expected, Inline::parse($value, Yaml::PARSE_CONSTANT)); + Inline::parse($value, Yaml::PARSE_CONSTANT); } public function phpConstTagWithEmptyValueProvider() { return [ - ['', '!php/const'], - ['', '!php/const '], - ['', '!php/const '], - [[''], '[!php/const]'], - [[''], '[!php/const ]'], - [['', 'foo'], '[!php/const , foo]'], - [['' => 'foo'], '{!php/const: foo}'], - [['' => 'foo'], '{!php/const : foo}'], - [['' => 'foo', 'bar' => 'ccc'], '{!php/const : foo, bar: ccc}'], + ['!php/const'], + ['!php/const '], + ['!php/const '], + ['[!php/const]'], + ['[!php/const ]'], + ['[!php/const , foo]'], + ['{!php/const: foo}'], + ['{!php/const : foo}'], + ['{!php/const : foo, bar: ccc}'], ]; } - /** - * @group legacy - */ - public function testParsePositiveOctalNumberContainingInvalidDigits() - { - self::assertSame('0123456789', Inline::parse('0123456789')); - } - - /** - * @group legacy - */ - public function testParseNegativeOctalNumberContainingInvalidDigits() - { - self::assertSame('-0123456789', Inline::parse('-0123456789')); - } - public function testParseCommentNotPrefixedBySpaces() { self::assertSame('foo', Inline::parse('"foo"#comment'));