Skip to content

Commit 1b474c6

Browse files
[VarDumper] add meta-data on hover
1 parent bf28a50 commit 1b474c6

14 files changed

+165
-131
lines changed

Caster/ConstStub.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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 Symfony\Component\VarDumper\Cloner\Stub;
15+
16+
/**
17+
* Represents a PHP constant and its value.
18+
*
19+
* @author Nicolas Grekas <[email protected]>
20+
*/
21+
class ConstStub extends Stub
22+
{
23+
public function __construct($name, $value)
24+
{
25+
$this->class = $name;
26+
$this->value = $value;
27+
}
28+
}

Caster/CasterStub.php renamed to Caster/CutStub.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
*
1919
* @author Nicolas Grekas <[email protected]>
2020
*/
21-
class CasterStub extends Stub
21+
class CutStub extends Stub
2222
{
23-
public function __construct($value, $class = '')
23+
public function __construct($value)
2424
{
25-
$this->class = $class;
2625
$this->value = $value;
2726

2827
switch (gettype($value)) {
@@ -47,12 +46,10 @@ public function __construct($value, $class = '')
4746
break;
4847

4948
case 'string':
50-
if ('' === $class) {
51-
$this->type = self::TYPE_STRING;
52-
$this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY;
53-
$this->cut = self::STRING_BINARY === $this->class ? strlen($value) : (function_exists('iconv_strlen') ? iconv_strlen($value, 'UTF-8') : -1);
54-
$this->value = '';
55-
}
49+
$this->type = self::TYPE_STRING;
50+
$this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY;
51+
$this->cut = self::STRING_BINARY === $this->class ? strlen($value) : (function_exists('iconv_strlen') ? iconv_strlen($value, 'UTF-8') : -1);
52+
$this->value = '';
5653
break;
5754
}
5855
}

Caster/DOMCaster.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class DOMCaster
6464
public static function castException(\DOMException $e, array $a, Stub $stub, $isNested)
6565
{
6666
if (isset($a["\0*\0code"], self::$errorCodes[$a["\0*\0code"]])) {
67-
$a["\0*\0code"] = new CasterStub(self::$errorCodes[$a["\0*\0code"]], 'const');
67+
$a["\0*\0code"] = new ConstStub(self::$errorCodes[$a["\0*\0code"]], $a["\0*\0code"]);
6868
}
6969

7070
return $a;
@@ -93,21 +93,21 @@ public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested)
9393
{
9494
$a += array(
9595
'nodeName' => $dom->nodeName,
96-
'nodeValue' => new CasterStub($dom->nodeValue),
97-
'nodeType' => new CasterStub(self::$nodeTypes[$dom->nodeType], 'const'),
98-
'parentNode' => new CasterStub($dom->parentNode),
96+
'nodeValue' => new CutStub($dom->nodeValue),
97+
'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
98+
'parentNode' => new CutStub($dom->parentNode),
9999
'childNodes' => $dom->childNodes,
100-
'firstChild' => new CasterStub($dom->firstChild),
101-
'lastChild' => new CasterStub($dom->lastChild),
102-
'previousSibling' => new CasterStub($dom->previousSibling),
103-
'nextSibling' => new CasterStub($dom->nextSibling),
100+
'firstChild' => new CutStub($dom->firstChild),
101+
'lastChild' => new CutStub($dom->lastChild),
102+
'previousSibling' => new CutStub($dom->previousSibling),
103+
'nextSibling' => new CutStub($dom->nextSibling),
104104
'attributes' => $dom->attributes,
105-
'ownerDocument' => new CasterStub($dom->ownerDocument),
105+
'ownerDocument' => new CutStub($dom->ownerDocument),
106106
'namespaceURI' => $dom->namespaceURI,
107107
'prefix' => $dom->prefix,
108108
'localName' => $dom->localName,
109109
'baseURI' => $dom->baseURI,
110-
'textContent' => new CasterStub($dom->textContent),
110+
'textContent' => new CutStub($dom->textContent),
111111
);
112112

113113
return $a;
@@ -119,13 +119,13 @@ public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub
119119

120120
$a += array(
121121
'nodeName' => $dom->nodeName,
122-
'nodeValue' => new CasterStub($dom->nodeValue),
123-
'nodeType' => new CasterStub(self::$nodeTypes[$dom->nodeType], 'const'),
122+
'nodeValue' => new CutStub($dom->nodeValue),
123+
'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
124124
'prefix' => $dom->prefix,
125125
'localName' => $dom->localName,
126126
'namespaceURI' => $dom->namespaceURI,
127-
'ownerDocument' => new CasterStub($dom->ownerDocument),
128-
'parentNode' => new CasterStub($dom->parentNode),
127+
'ownerDocument' => new CutStub($dom->ownerDocument),
128+
'parentNode' => new CutStub($dom->parentNode),
129129
);
130130

131131
return $a;
@@ -139,7 +139,7 @@ public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $is
139139
$a += array(
140140
'doctype' => $dom->doctype,
141141
'implementation' => $dom->implementation,
142-
'documentElement' => new CasterStub($dom->documentElement),
142+
'documentElement' => new CutStub($dom->documentElement),
143143
'actualEncoding' => $dom->actualEncoding,
144144
'encoding' => $dom->encoding,
145145
'xmlEncoding' => $dom->xmlEncoding,

Caster/DoctrineCaster.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public static function castPersistentCollection(PersistentCollection $coll, arra
5050
{
5151
$prefix = "\0Doctrine\\ORM\\PersistentCollection\0";
5252

53-
$a[$prefix.'snapshot'] = new CasterStub($a[$prefix.'snapshot']);
54-
$a[$prefix.'association'] = new CasterStub($a[$prefix.'association']);
55-
$a[$prefix.'typeClass'] = new CasterStub($a[$prefix.'typeClass']);
53+
$a[$prefix.'snapshot'] = new CutStub($a[$prefix.'snapshot']);
54+
$a[$prefix.'association'] = new CutStub($a[$prefix.'association']);
55+
$a[$prefix.'typeClass'] = new CutStub($a[$prefix.'typeClass']);
5656

5757
return $a;
5858
}

Caster/ExceptionCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function castException(\Exception $e, array $a, Stub $stub, $isNes
6161
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested)
6262
{
6363
if (isset($a[$s = "\0*\0severity"], self::$errorTypes[$a[$s]])) {
64-
$a[$s] = new CasterStub(self::$errorTypes[$a[$s]], 'const');
64+
$a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]);
6565
}
6666

6767
return $a;

Caster/PdoCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function castPdo(\PDO $c, array $a, Stub $stub, $isNested)
7272
try {
7373
$a[$attr] = 'ERRMODE' === $attr ? $errmode : $c->getAttribute(constant("PDO::ATTR_{$attr}"));
7474
if (isset($values[$a[$attr]])) {
75-
$a[$attr] = new CasterStub($values[$a[$attr]], 'const');
75+
$a[$attr] = new ConstStub($values[$a[$attr]], $a[$attr]);
7676
}
7777
} catch (\Exception $m) {
7878
}

Caster/SplCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, S
7272
$c->setIteratorMode(\SplDoublyLinkedList::IT_MODE_KEEP | $mode & ~\SplDoublyLinkedList::IT_MODE_DELETE);
7373

7474
$a += array(
75-
"\0~\0mode" => new CasterStub((($mode & \SplDoublyLinkedList::IT_MODE_LIFO) ? 'IT_MODE_LIFO' : 'IT_MODE_FIFO').' | '.(($mode & \SplDoublyLinkedList::IT_MODE_KEEP) ? 'IT_MODE_KEEP' : 'IT_MODE_DELETE'), 'const'),
75+
"\0~\0mode" => new ConstStub((($mode & \SplDoublyLinkedList::IT_MODE_LIFO) ? 'IT_MODE_LIFO' : 'IT_MODE_FIFO').' | '.(($mode & \SplDoublyLinkedList::IT_MODE_KEEP) ? 'IT_MODE_KEEP' : 'IT_MODE_DELETE'), $mode),
7676
"\0~\0dllist" => iterator_to_array($c),
7777
);
7878
$c->setIteratorMode($mode);

Caster/StubCaster.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
use Symfony\Component\VarDumper\Cloner\Stub;
1515

1616
/**
17-
* Casts a CasterStub.
17+
* Casts a caster's Stub.
1818
*
1919
* @author Nicolas Grekas <[email protected]>
2020
*/
2121
class StubCaster
2222
{
23-
public static function castStub(CasterStub $c, array $a, Stub $stub, $isNested)
23+
public static function castStub(Stub $c, array $a, Stub $stub, $isNested)
2424
{
2525
if ($isNested) {
2626
$stub->type = $c->type;
@@ -33,7 +33,7 @@ public static function castStub(CasterStub $c, array $a, Stub $stub, $isNested)
3333
}
3434
}
3535

36-
public static function castNestedFat($obj, array $a, Stub $stub, $isNested)
36+
public static function cutInternals($obj, array $a, Stub $stub, $isNested)
3737
{
3838
if ($isNested) {
3939
$stub->cut += count($a);

Cloner/AbstractCloner.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
abstract class AbstractCloner implements ClonerInterface
2222
{
2323
public static $defaultCasters = array(
24-
'Symfony\Component\VarDumper\Caster\CasterStub' => 'Symfony\Component\VarDumper\Caster\StubCaster::castStub',
24+
'Symfony\Component\VarDumper\Caster\CutStub' => 'Symfony\Component\VarDumper\Caster\StubCaster::castStub',
25+
'Symfony\Component\VarDumper\Caster\ConstStub' => 'Symfony\Component\VarDumper\Caster\StubCaster::castStub',
2526

2627
'Closure' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castClosure',
2728
'Reflector' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castReflector',
2829

29-
'Doctrine\Common\Persistence\ObjectManager' => 'Symfony\Component\VarDumper\Caster\StubCaster::castNestedFat',
30+
'Doctrine\Common\Persistence\ObjectManager' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
3031
'Doctrine\Common\Proxy\Proxy' => 'Symfony\Component\VarDumper\Caster\DoctrineCaster::castCommonProxy',
3132
'Doctrine\ORM\Proxy\Proxy' => 'Symfony\Component\VarDumper\Caster\DoctrineCaster::castOrmProxy',
3233
'Doctrine\ORM\PersistentCollection' => 'Symfony\Component\VarDumper\Caster\DoctrineCaster::castPersistentCollection',
@@ -57,7 +58,7 @@ abstract class AbstractCloner implements ClonerInterface
5758
'ErrorException' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castErrorException',
5859
'Exception' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castException',
5960
'Symfony\Component\DependencyInjection\ContainerInterface'
60-
=> 'Symfony\Component\VarDumper\Caster\StubCaster::castNestedFat',
61+
=> 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals',
6162
'Symfony\Component\VarDumper\Exception\ThrowingCasterException'
6263
=> 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castThrowingCasterException',
6364

Cloner/Cursor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Cursor
3333
public $hardRefHandle = 0;
3434
public $hashType;
3535
public $hashKey;
36+
public $hashKeyIsBinary;
3637
public $hashIndex = 0;
3738
public $hashLength = 0;
3839
public $hashCut = 0;

0 commit comments

Comments
 (0)