Skip to content

Commit defb343

Browse files
committed
Merge branch '3.4' into 4.4
* 3.4: Prevent parsing invalid octal digits as octal numbers [DI] fix ContainerBuilder on PHP8 [Console] Make sure $maxAttempts is an int or null. [VarDumper] Fix caster for invalid SplFileInfo objects on php 8. [Intl] Skip test cases that produce a TypeError on php 8. [PhpUnitBridge] Adjust output parsing for PHPUnit 9.3. [PhpUnitBridge] CoverageListenerTrait update for PHPUnit 8.5/9.x add bosnian (bs) translation [Debug] Parse "x not found" errors correctly on php 8.
2 parents 96800ef + b7d9b4a commit defb343

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Inline.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,16 +636,16 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
636636

637637
switch (true) {
638638
case ctype_digit($scalar):
639-
if ('0' === $scalar[0]) {
640-
return octdec(preg_replace('/[^0-7]/', '', $scalar));
639+
if (preg_match('/^0[0-7]+$/', $scalar)) {
640+
return octdec($scalar);
641641
}
642642

643643
$cast = (int) $scalar;
644644

645645
return ($scalar === (string) $cast) ? $cast : $scalar;
646646
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
647-
if ('0' === $scalar[1]) {
648-
return -octdec(preg_replace('/[^0-7]/', '', substr($scalar, 1)));
647+
if (preg_match('/^-0[0-7]+$/', $scalar)) {
648+
return -octdec(substr($scalar, 1));
649649
}
650650

651651
$cast = (int) $scalar;

Tests/InlineTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,12 +791,12 @@ public function phpConstTagWithEmptyValueProvider()
791791

792792
public function testParsePositiveOctalNumberContainingInvalidDigits()
793793
{
794-
self::assertSame(342391, Inline::parse('0123456789'));
794+
self::assertSame('0123456789', Inline::parse('0123456789'));
795795
}
796796

797797
public function testParseNegativeOctalNumberContainingInvalidDigits()
798798
{
799-
self::assertSame(-342391, Inline::parse('-0123456789'));
799+
self::assertSame('-0123456789', Inline::parse('-0123456789'));
800800
}
801801

802802
/**

0 commit comments

Comments
 (0)