Skip to content

Commit 99247bb

Browse files
lyrixxnicolas-grekas
authored andcommitted
[VarDumper] Added a support for casting Ramsey/Uuid
1 parent 54ba699 commit 99247bb

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

src/Symfony/Component/VarDumper/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
to configure casters & flags to use in tests
99
* added `ImagineCaster` and infrastructure to dump images
1010
* added the stamps of a message after it is dispatched in `TraceableMessageBus` and `MessengerDataCollector` collected data
11+
* added `UuidCaster`
1112

1213
4.3.0
1314
-----

src/Symfony/Component/VarDumper/Caster/ImagineCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
class ImagineCaster
2121
{
22-
public static function castImage(ImageInterface $c, array $a, Stub $stub, $isNested)
22+
public static function castImage(ImageInterface $c, array $a, Stub $stub, bool $isNested): array
2323
{
2424
$imgData = $c->get('png');
2525
if (\strlen($imgData) > 1 * 1000 * 1000) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\VarDumper\Caster;
13+
14+
use Ramsey\Uuid\UuidInterface;
15+
use Symfony\Component\VarDumper\Cloner\Stub;
16+
17+
/**
18+
* @author Grégoire Pineau <lyrixx@lyrixx.info>
19+
*/
20+
class UuidCaster
21+
{
22+
public static function castRamseyUuid(UuidInterface $c, array $a, Stub $stub, bool $isNested): array
23+
{
24+
$a += [
25+
Caster::PREFIX_VIRTUAL.'uuid' => (string) $c,
26+
];
27+
28+
return $a;
29+
}
30+
}

src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ abstract class AbstractCloner implements ClonerInterface
8989

9090
'Imagine\Image\ImageInterface' => ['Symfony\Component\VarDumper\Caster\ImagineCaster', 'castImage'],
9191

92+
'Ramsey\Uuid\UuidInterface' => ['Symfony\Component\VarDumper\Caster\UuidCaster', 'castRamseyUuid'],
93+
9294
'ProxyManager\Proxy\ProxyInterface' => ['Symfony\Component\VarDumper\Caster\ProxyManagerCaster', 'castProxy'],
9395
'PHPUnit_Framework_MockObject_MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
9496
'PHPUnit\Framework\MockObject\MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],

0 commit comments

Comments
 (0)
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