Skip to content

Commit 9036cb3

Browse files
Merge branch '5.3' into 5.4
* 5.3: [VarDumper] Fix handling of "new" in initializers on PHP 8.1
2 parents 083f2bc + b43c51f commit 9036cb3

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Caster/ReflectionCaster.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ public static function getSignature(array $a)
384384
$signature .= 10 > \strlen($v) && !str_contains($v, '\\') ? "'{$v}'" : "'…".\strlen($v)."'";
385385
} elseif (\is_bool($v)) {
386386
$signature .= $v ? 'true' : 'false';
387+
} elseif (\is_object($v)) {
388+
$signature .= 'new '.substr(strrchr('\\'.get_debug_type($v), '\\'), 1);
387389
} else {
388390
$signature .= $v;
389391
}

Tests/Caster/ReflectionCasterTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,27 @@ public function testGenerator()
602602
$this->assertDumpMatchesFormat($expectedDump, $generator);
603603
}
604604

605+
/**
606+
* @requires PHP 8.1
607+
*/
608+
public function testNewInInitializer()
609+
{
610+
$f = eval('return function ($a = new stdClass()) {};');
611+
$line = __LINE__ - 1;
612+
613+
$this->assertDumpMatchesFormat(
614+
<<<EOTXT
615+
Closure(\$a = new stdClass) {
616+
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
617+
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
618+
file: "%sReflectionCasterTest.php($line) : eval()'d code"
619+
line: "1 to 1"
620+
}
621+
EOTXT
622+
, $f
623+
);
624+
}
625+
605626
/**
606627
* @requires PHP 8
607628
*/

0 commit comments

Comments
 (0)