Skip to content

Commit 0eb696f

Browse files
committed
prevent notice for invalid octal numbers on PHP 7.4
1 parent cfa048c commit 0eb696f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,12 +762,12 @@ private static function evaluateScalar($scalar, $flags, $references = [])
762762
$raw = $scalar;
763763
$cast = (int) $scalar;
764764

765-
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
765+
return '0' === $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
766766
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
767767
$raw = $scalar;
768768
$cast = (int) $scalar;
769769

770-
return '0' == $scalar[1] ? -octdec(substr($scalar, 1)) : (($raw === (string) $cast) ? $cast : $raw);
770+
return '0' === $scalar[1] ? -octdec(substr($scalar, 1)) : (($raw === (string) $cast) ? $cast : $raw);
771771
case is_numeric($scalar):
772772
case Parser::preg_match(self::getHexRegex(), $scalar):
773773
$scalar = str_replace('_', '', $scalar);

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,4 +842,14 @@ public function phpConstTagWithEmptyValueProvider()
842842
[['' => 'foo', 'bar' => 'ccc'], '{!php/const : foo, bar: ccc}'],
843843
];
844844
}
845+
846+
public function testParseInvalidPositiveOctalNumber()
847+
{
848+
self::assertSame(342391, Inline::parse('0123456789'));
849+
}
850+
851+
public function testParseInvalidNegativeOctalNumber()
852+
{
853+
self::assertSame(-342391, Inline::parse('-0123456789'));
854+
}
845855
}

0 commit comments

Comments
 (0)