Skip to content

Commit

Permalink
[VarDumper] add caster for WeakReference instances of PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Apr 16, 2019
1 parent 278a7ec commit 0cdb808
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php
Expand Up @@ -280,6 +280,13 @@ public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub
return $a;
}

public static function castReference(\ReflectionReference $c, array $a, Stub $stub, $isNested)
{
$a[Caster::PREFIX_VIRTUAL.'id'] = $c->getId();

return $a;
}

public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, $isNested)
{
self::addMap($a, $c, [
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/VarDumper/Caster/SplCaster.php
Expand Up @@ -188,6 +188,13 @@ public static function castOuterIterator(\OuterIterator $c, array $a, Stub $stub
return $a;
}

public static function castWeakReference(\WeakReference $c, array $a, Stub $stub, $isNested)
{
$a[Caster::PREFIX_VIRTUAL.'object'] = $c->get();

return $a;
}

private static function castSplArray($c, array $a, Stub $stub, $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
Expand Up @@ -38,6 +38,7 @@ abstract class AbstractCloner implements ClonerInterface
'ReflectionMethod' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castMethod'],
'ReflectionParameter' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castParameter'],
'ReflectionProperty' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castProperty'],
'ReflectionReference' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castReference'],
'ReflectionExtension' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castExtension'],
'ReflectionZendExtension' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castZendExtension'],

Expand Down Expand Up @@ -109,6 +110,7 @@ abstract class AbstractCloner implements ClonerInterface
'SplObjectStorage' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castObjectStorage'],
'SplPriorityQueue' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castHeap'],
'OuterIterator' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castOuterIterator'],
'WeakReference' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castWeakReference'],

'Redis' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedis'],
'RedisArray' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisArray'],
Expand Down

0 comments on commit 0cdb808

Please sign in to comment.