diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index 463a7dccae90..36a50190d122 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -97,7 +97,7 @@ public function getDumpArgs() array('foo' => 'bar'), array(), "
array:1 [\n"
-                ."  \"foo\" => \"bar\"\n"
+                ."  \"foo\" => \"bar\"\n"
                 ."]\n"
                 ."
\n", ), diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index a48d88bf09f2..058b8bc23f43 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -39,6 +39,8 @@ class CliDumper extends AbstractDumper 'protected' => '38;5;166', 'private' => '38;5;160', 'meta' => '38;5;27', + 'key' => '38;5;27', + 'index' => '38;5;27', ); protected static $controlCharsRx = '/[\x00-\x1F\x7F]/'; @@ -258,14 +260,16 @@ protected function dumpKey(Cursor $cursor) if (null !== $key = $cursor->hashKey) { $attr = array('binary' => $cursor->hashKeyIsBinary); $bin = $cursor->hashKeyIsBinary ? 'b' : ''; + $style = 'key'; switch ($cursor->hashType) { default: case Cursor::HASH_INDEXED: + $style = 'index'; case Cursor::HASH_ASSOC: if (is_int($key)) { - $this->line .= $this->style('meta', $key).' => '; + $this->line .= $this->style($style, $key).' => '; } else { - $this->line .= $bin.'"'.$this->style('meta', $key).'" => '; + $this->line .= $bin.'"'.$this->style($style, $key).'" => '; } break; @@ -274,28 +278,33 @@ protected function dumpKey(Cursor $cursor) // No break; case Cursor::HASH_OBJECT: if (!isset($key[0]) || "\0" !== $key[0]) { - $this->line .= $bin.$this->style('public', $key).': '; + $this->line .= '+'.$bin.$this->style('public', $key).': '; } elseif (0 < strpos($key, "\0", 1)) { $key = explode("\0", substr($key, 1), 2); switch ($key[0]) { case '+': // User inserted keys $attr['dynamic'] = true; - $this->line .= $bin.'"'.$this->style('public', $key[1], $attr).'": '; + $this->line .= '+'.$bin.'"'.$this->style('public', $key[1], $attr).'": '; break 2; - - case '~': $style = 'meta'; break; - case '*': $style = 'protected'; break; + case '~': + $style = 'meta'; + break; + case '*': + $style = 'protected'; + $bin = '#'.$bin; + break; default: $attr['class'] = $key[0]; $style = 'private'; + $bin = '-'.$bin; break; } $this->line .= $bin.$this->style($style, $key[1], $attr).': '; } else { // This case should not happen - $this->line .= $bin.'"'.$this->style('private', $key, array('class' => '')).'": '; + $this->line .= '-'.$bin.'"'.$this->style('private', $key, array('class' => '')).'": '; } break; } diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index ec9900749406..f7e70ebdbec1 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -42,6 +42,8 @@ class HtmlDumper extends CliDumper 'protected' => 'color:#D75F00', 'private' => 'color:#D70000', 'meta' => 'color:#005FFF', + 'key' => 'color:#005FFF', + 'index' => 'color:#005FFF', ); /** @@ -337,8 +339,8 @@ protected function style($style, $value, $attr = array()) if ('const' === $style && array_key_exists('value', $attr)) { $style .= sprintf(' title="%s"', htmlspecialchars(json_encode($attr['value']), ENT_QUOTES, 'UTF-8')); - } elseif ('public' === $style && !empty($attr['dynamic'])) { - $style .= ' title="Runtime added dynamic property"'; + } elseif ('public' === $style) { + $style .= sprintf(' title="%s"', empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property'); } elseif ('str' === $style && 1 < $attr['length']) { $style .= sprintf(' title="%s%s characters"', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : ''); } elseif ('note' === $style) { @@ -347,8 +349,10 @@ protected function style($style, $value, $attr = array()) } elseif (':' === $v[0]) { return sprintf('%s', substr($v, 1), $style, $v); } + } elseif ('protected' === $style) { + $style .= ' title="Protected property"'; } elseif ('private' === $style) { - $style .= sprintf(' title="%s::%s"', $attr['class'], $v); + $style .= sprintf(' title="Private property defined in class: `%s`"', $attr['class']); } return "$v"; diff --git a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php index c78121276345..49710aaa88ea 100644 --- a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php @@ -72,8 +72,8 @@ public function testGet() } 8 => :Unknown {@{$res2}} "obj" => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d - foo: "foo" - "bar": "bar" + +foo: "foo" + +"bar": "bar" } "closure" => Closure {#%d reflection: """ diff --git a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php index 999c09860119..2916ba4506ea 100644 --- a/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php @@ -52,19 +52,19 @@ public function testGet() $this->assertStringMatchesFormat( <<array:25 [ - "number" => 1 - 0 => &1 null - "const" => 1.1 - 1 => true - 2 => false - 3 => NAN - 4 => INF - 5 => -INF - 6 => {$intMax} - "str" => "déjà" - 7 => b"é@" - "[]" => [] - "res" => :stream {@{$res1} + "number" => 1 + 0 => &1 null + "const" => 1.1 + 1 => true + 2 => false + 3 => NAN + 4 => INF + 5 => -INF + 6 => {$intMax} + "str" => "déjà" + 7 => b"é@" + "[]" => [] + "res" => :stream {@{$res1} wrapper_type: "plainfile" stream_type: "STDIO" mode: "r" @@ -75,12 +75,12 @@ public function testGet() eof: false options: [] } - 8 => :Unknown {@{$res2}} - "obj" => DumbFoo {#%d - foo: "foo" - "bar": "bar" + 8 => :Unknown {@{$res2}} + "obj" => DumbFoo {#%d + +foo: "foo" + +"bar": "bar" } - "closure" => Closure {#%d + "closure" => Closure {#%d reflection: """ Closure [ <user> {$closureLabel} Symfony\Component\VarDumper\Tests\Fixture\{closure} ] { @@ {$var['file']} {$var['line']} - {$var['line']} @@ -92,19 +92,19 @@ public function testGet() } """ } - "line" => {$var['line']} - "nobj" => array:1 [ - 0 => &3 {#%d} + "line" => {$var['line']} + "nobj" => array:1 [ + 0 => &3 {#%d} ] - "recurs" => &4 array:1 [ - 0 => &4 array:1 [&4] + "recurs" => &4 array:1 [ + 0 => &4 array:1 [&4] ] - 9 => &1 null - "sobj" => DumbFoo {#%d} - "snobj" => &3 {#%d} - "snobj2" => {#%d} - "file" => "{$var['file']}" - b"bin-key-é" => "" + 9 => &1 null + "sobj" => DumbFoo {#%d} + "snobj" => &3 {#%d} + "snobj2" => {#%d} + "file" => "{$var['file']}" + b"bin-key-é" => "" ]