Skip to content

Commit ad74db9

Browse files
committed
bug #12411 [VarDumper] Use Unicode Control Pictures (nicolas-grekas)
This PR was merged into the 2.6-dev branch. Discussion ---------- [VarDumper] Use Unicode Control Pictures | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - I wasn't satisfied with how control chars where dumped, until I found the [Unicode Control Pictures](http://www.unicode.org/charts/PDF/U2400.pdf). This PR takes advantage of them: ![capture du 2014-11-04 10 52 15](https://cloud.githubusercontent.com/assets/243674/4897678/752fac20-6408-11e4-9186-7b788c9a88bb.png) Commits ------- 6258ae8 [DebugBundle] remove README.md 50021bd [Debug] No gc_collect_cycles(), it's costly and can segfault b592e90 [VarDumper] inline dump() function loading cd076e4 [VarDumper] Use Unicode Control Pictures
2 parents 5d8fbb8 + 6258ae8 commit ad74db9

File tree

8 files changed

+23
-28
lines changed

8 files changed

+23
-28
lines changed

UPGRADE-2.6.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,18 @@ OptionsResolver
349349
// throws InvalidOptionsException
350350
$resolver->resolve(array('port' => '25'));
351351
```
352+
353+
VarDumper and DebugBundle
354+
-------------------------
355+
356+
The component and the bundle are new to Symfony 2.6. We encourage you
357+
to enable the bundle in your `app/AppKernel.php` for the *dev* or *test*
358+
environments. Just add this line before loading the `WebProfilerBundle`:
359+
360+
```php
361+
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
362+
```
363+
364+
Then enjoy dumping variables by calling `dump($var)` anywhere in your PHP
365+
and `{% dump var %}` or `{{ dump(var) }}` in Twig. Dumps are displayed
366+
**in the web debug toolbar**.

src/Symfony/Bundle/DebugBundle/README.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ public function handleException(\Exception $exception, array $error = null)
487487
public static function handleFatalError(array $error = null)
488488
{
489489
self::$reservedMemory = '';
490-
gc_collect_cycles();
491490
$handler = set_error_handler('var_dump', 0);
492491
$handler = is_array($handler) ? $handler[0] : null;
493492
restore_error_handler();

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ abstract class AbstractCloner implements ClonerInterface
8484
protected $maxString = -1;
8585

8686
private $casters = array();
87-
private $data = array(array(null));
8887
private $prevErrorHandler;
8988
private $classInfo = array();
9089

src/Symfony/Component/VarDumper/Dumper/CliDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ protected function dumpKey(Cursor $cursor)
331331
}
332332

333333
if ($cursor->hardRefTo) {
334-
$this->line .= $this->style('ref', '&'.$cursor->hardRefTo, array('count' => $cursor->hardRefCount)).' ';
334+
$this->line .= $this->style('ref', '&'.($cursor->hardRefCount ? $cursor->hardRefTo : ''), array('count' => $cursor->hardRefCount)).' ';
335335
}
336336
}
337337
}

src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class HtmlDumper extends CliDumper
3535
'num' => 'font-weight:bold; color:#1299DA',
3636
'const' => 'font-weight:bold',
3737
'str' => 'font-weight:bold; color:#56DB3A',
38-
'cchr' => 'font-style:italic',
38+
'cchr' => 'color:#FF8400',
3939
'note' => 'color:#1299DA',
4040
'ref' => 'color:#A0A0A0',
4141
'public' => 'color:#FFFFFF',
@@ -319,7 +319,8 @@ protected function style($style, $value, $attr = array())
319319

320320
$v = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
321321
$v = preg_replace_callback(self::$controlCharsRx, function ($r) {
322-
return sprintf('<span class=sf-dump-cchr title=\\x%02X>%s</span>', ord($r[0]), "\x7F" === $r[0] ? '?' : chr(64 + ord($r[0])));
322+
// Use Unicode Control Pictures - see http://www.unicode.org/charts/PDF/U2400.pdf
323+
return sprintf('<span class=sf-dump-cchr title=\\x%02X>&#%d;</span>', ord($r[0]), "\x7F" !== $r[0] ? 0x2400 + ord($r[0]) : 0x2421);
323324
}, $v);
324325

325326
if ('ref' === $style) {

src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testGet()
6262
<span class=sf-dump-key>5</span> => <span class=sf-dump-num>-INF</span>
6363
<span class=sf-dump-key>6</span> => <span class=sf-dump-num>{$intMax}</span>
6464
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="4 characters">d&#233;j&#224;</span>"
65-
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">&#233;<span class=sf-dump-cchr title=\\x00>@</span></span>"
65+
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">&#233;<span class=sf-dump-cchr title=\\x00>&#9216;</span></span>"
6666
"<span class=sf-dump-key>[]</span>" => []
6767
"<span class=sf-dump-key>res</span>" => <abbr title="`stream` resource" class=sf-dump-note>:stream</abbr> {<a class=sf-dump-ref>@{$res1}</a><samp>
6868
<span class=sf-dump-meta>wrapper_type</span>: "<span class=sf-dump-str title="9 characters">plainfile</span>"

src/Symfony/Component/VarDumper/VarDumper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Component\VarDumper\Dumper\CliDumper;
1616
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
1717

18+
// Load the global dump() function
19+
require_once __DIR__.'/Resources/functions/dump.php';
20+
1821
/**
1922
* @author Nicolas Grekas <p@tchwork.com>
2023
*/

0 commit comments

Comments
 (0)