diff --git a/src/Symfony/Component/VarDumper/Caster/DateCaster.php b/src/Symfony/Component/VarDumper/Caster/DateCaster.php index f3258b19a6f2..70f229a0d8b7 100644 --- a/src/Symfony/Component/VarDumper/Caster/DateCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DateCaster.php @@ -31,7 +31,11 @@ public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, .($location ? ($d->format('I') ? "\nDST On" : "\nDST Off") : '') ; - $a = []; + unset( + $a[Caster::PREFIX_DYNAMIC.'date'], + $a[Caster::PREFIX_DYNAMIC.'timezone'], + $a[Caster::PREFIX_DYNAMIC.'timezone_type'] + ); $a[$prefix.'date'] = new ConstStub(self::formatDateTime($d, $location ? ' e (P)' : ' P'), $title); $stub->class .= $d->format(' @U'); diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php index da8b4d0fa5c3..87485448dcc9 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php @@ -16,6 +16,7 @@ use Symfony\Component\VarDumper\Caster\DateCaster; use Symfony\Component\VarDumper\Cloner\Stub; use Symfony\Component\VarDumper\Test\VarDumperTestTrait; +use Symfony\Component\VarDumper\Tests\Fixtures\DateTimeChild; /** * @author Dany Maillard @@ -55,7 +56,7 @@ public function testCastDateTime($time, $timezone, $xDate, $xTimestamp, $xInfos) $stub = new Stub(); $date = new \DateTime($time, new \DateTimeZone($timezone)); - $cast = DateCaster::castDateTime($date, ['foo' => 'bar'], $stub, false, 0); + $cast = DateCaster::castDateTime($date, Caster::castObject($date, \DateTime::class), $stub, false, 0); $xDump = << "foo" + "\\x00~\\x00date" => $xDate +] +EODUMP; + + $this->assertDumpEquals($xDump, $dateCast); + + $xDump = <<assertDumpMatchesFormat($xDump, $dateCast["\0~\0date"]); + } + /** * @dataProvider provideIntervals */ diff --git a/src/Symfony/Component/VarDumper/Tests/Fixtures/DateTimeChild.php b/src/Symfony/Component/VarDumper/Tests/Fixtures/DateTimeChild.php new file mode 100644 index 000000000000..2ea2df6514ae --- /dev/null +++ b/src/Symfony/Component/VarDumper/Tests/Fixtures/DateTimeChild.php @@ -0,0 +1,8 @@ + pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy