Skip to content

Commit

Permalink
feature #31130 [VarDumper] add caster for WeakReference instances of …
Browse files Browse the repository at this point in the history
…PHP 7.4 (nicolas-grekas)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[VarDumper] add caster for WeakReference instances of PHP 7.4

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

![image](https://user-images.githubusercontent.com/243674/56214443-2d9d8100-605e-11e9-86bb-157a07b5caa0.png)

Commits
-------

0cdb808 [VarDumper] add caster for WeakReference instances of PHP 7.4
  • Loading branch information
fabpot committed Apr 18, 2019
2 parents 8d96861 + 0cdb808 commit a59fe66
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 a59fe66

Please sign in to comment.