Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0152a4f

Browse filesBrowse files
[VarDumper] add meta-data on hover
1 parent 0e6465a commit 0152a4f
Copy full SHA for 0152a4f

File tree

Expand file treeCollapse file tree

15 files changed

+157
-124
lines changed
Filter options
Expand file treeCollapse file tree

15 files changed

+157
-124
lines changed

‎src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getDumpArgs()
9797
array('foo' => 'bar'),
9898
array(),
9999
"<pre class=sf-dump id=sf-dump data-indent-pad=\" \"><span class=sf-dump-note>array:1</span> [<samp>\n"
100-
." \"<span class=sf-dump-meta>foo</span>\" => \"<span class=sf-dump-str>bar</span>\"\n"
100+
." \"<span class=sf-dump-meta>foo</span>\" => \"<span class=sf-dump-str title=\"3 characters\">bar</span>\"\n"
101101
."</samp>]\n"
102102
."</pre><script>Sfdump(\"sf-dump\")</script>\n",
103103
),
+28Lines 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 <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 Symfony\Component\VarDumper\Cloner\Stub;
15+
16+
/**
17+
* Represents a PHP constant and its value.
18+
*
19+
* @author Nicolas Grekas <p@tchwork.com>
20+
*/
21+
class ConstStub extends Stub
22+
{
23+
public function __construct($name, $value)
24+
{
25+
$this->class = $name;
26+
$this->value = $value;
27+
}
28+
}

‎src/Symfony/Component/VarDumper/Caster/CasterStub.php renamed to ‎src/Symfony/Component/VarDumper/Caster/CutStub.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/CutStub.php
+6-9Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
*
1919
* @author Nicolas Grekas <p@tchwork.com>
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
}

‎src/Symfony/Component/VarDumper/Caster/DOMCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/DOMCaster.php
+15-15Lines 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,

‎src/Symfony/Component/VarDumper/Caster/DoctrineCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/DoctrineCaster.php
+3-3Lines 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
}

‎src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
+1-1Lines 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;

‎src/Symfony/Component/VarDumper/Caster/PdoCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/PdoCaster.php
+1-1Lines 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
}

‎src/Symfony/Component/VarDumper/Caster/SplCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/SplCaster.php
+1-1Lines 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);

‎src/Symfony/Component/VarDumper/Caster/StubCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/StubCaster.php
+3-3Lines 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 <p@tchwork.com>
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);

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
+4-3Lines 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

‎src/Symfony/Component/VarDumper/Cloner/Cursor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/Cursor.php
+1Lines 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;

‎src/Symfony/Component/VarDumper/Cloner/Data.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/Data.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ private function dumpItem($dumper, $cursor, &$refs, $item)
142142
} elseif ('array' === $type) {
143143
$dumper->enterHash($cursor, Cursor::HASH_INDEXED, 0, false);
144144
$dumper->leaveHash($cursor, Cursor::HASH_INDEXED, 0, false, 0);
145+
} elseif ('string' === $type) {
146+
$dumper->dumpString($cursor, $item, false, 0);
145147
} else {
146148
$dumper->dumpScalar($cursor, $type, $item);
147149
}
@@ -169,7 +171,9 @@ private function dumpChildren($dumper, $parentCursor, &$refs, $children, $hashCu
169171
$cursor->hashIndex = 0;
170172
$cursor->hashLength = count($children);
171173
$cursor->hashCut = $hashCut;
172-
foreach ($children as $cursor->hashKey => $child) {
174+
foreach ($children as $key => $child) {
175+
$cursor->hashKeyIsBinary = isset($key[0]) && !preg_match('//u', $key);
176+
$cursor->hashKey = $cursor->hashKeyIsBinary ? self::utf8Encode($key) : $key;
173177
$this->dumpItem($dumper, $cursor, $refs, $child);
174178
if (++$cursor->hashIndex === $this->maxItemsPerDepth || $cursor->stop) {
175179
$parentCursor->stop = true;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.