Skip to content

Commit

Permalink
Implemented issue #457: var_dump() overloading for the commandline.
Browse files Browse the repository at this point in the history
This is a continuation of the xdebug.cli_color argument. The code simply works
the same but doesn't apply the ANSI symbols.  Ought to work on Windows too, but
haven't tested that as my dev environment is broken for it.
  • Loading branch information
derickr committed Nov 11, 2011
1 parent 4da0c69 commit 535df90
Show file tree
Hide file tree
Showing 32 changed files with 309 additions and 38 deletions.
1 change: 1 addition & 0 deletions tests/bug00022.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ xdebug.auto_trace=0
xdebug.collect_params=1
xdebug.collect_assignments=0
xdebug.profiler_enable=0
xdebug.overload_var_dump=0
--FILE--
<?php
function foo($s) {
Expand Down
1 change: 1 addition & 0 deletions tests/bug00212a.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage( XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE );
Expand Down
1 change: 1 addition & 0 deletions tests/bug00212b.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage( XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE );
Expand Down
1 change: 1 addition & 0 deletions tests/bug00212c.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage( XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE );
Expand Down
1 change: 1 addition & 0 deletions tests/bug00213.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage( XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE );
Expand Down
1 change: 1 addition & 0 deletions tests/bug00241.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ xdebug.auto_profile=0
xdebug.profiler_enable=0
xdebug.var_display_max_depth=3
xdebug.var_display_max_children=2
xdebug.overload_var_dump=0
--FILE--
<?php
function error_handler($errno, $string, $file, $line, $context)
Expand Down
1 change: 1 addition & 0 deletions tests/bug00265.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.profiler_enable=0
xdebug.trace_format=0
xdebug.overload_var_dump=0
--FILE--
<?php
register_shutdown_function( 'f' );
Expand Down
1 change: 1 addition & 0 deletions tests/bug00334.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.profiler_enable=0
xdebug.trace_format=0
xdebug.overload_var_dump=0
--FILE--
<?php
// Run me from the PHP CLI
Expand Down
72 changes: 72 additions & 0 deletions tests/bug00457-2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
--TEST--
Test for bug #457: var_dump() overloading from the command line
--INI--
html_errors=0
xdebug.default_enable=1
xdebug.var_display_max_data=32
xdebug.var_display_max_children=4
xdebug.var_display_max_depth=2
xdebug.cli_color=2
--FILE--
<?php
$array = array(
"A very long string that should be cut off at 32 characters",
array(
"a test for the depth setting",
array(
"this should not show"
)
),
"third element",
"fourth element (still shows)",
"fifth element (should not show)"
);
var_dump($array);

$object = new stdClass;
$object->prop1 = "A very long string that should be cut off at 32 characters";
$object->array = array(
"a test for the depth setting",
array(
"this should not show"
)
);
$object->prop3 = "third element";
$object->prop4 = "fourth element (still shows)";
$object->prop5 = "fifth element (should not show)";
var_dump($object);
--EXPECTF--
array(5) {
[0] =>
string(58) 'A very long string that should b'...
[1] =>
array(2) {
[0] =>
string(28) 'a test for the depth setting'
[1] =>
array(1) {
...
}
}
[2] =>
string(13) 'third element'
[3] =>
string(28) 'fourth element (still shows)'

(more elements)...
}
class stdClass#1 (5) {
public $prop1 => string(58) 'A very long string that should b'...
public $array => array(2) {
[0] =>
string(28) 'a test for the depth setting'
[1] =>
array(1) {
...
}
}
public $prop3 => string(13) 'third element'
public $prop4 => string(28) 'fourth element (still shows)'

(more elements)...
}
72 changes: 72 additions & 0 deletions tests/bug00457.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
--TEST--
Test for bug #457: var_dump() overloading from the command line
--INI--
html_errors=0
xdebug.default_enable=1
xdebug.var_display_max_data=32
xdebug.var_display_max_children=4
xdebug.var_display_max_depth=2
xdebug.cli_color=1
--FILE--
<?php
$array = array(
"A very long string that should be cut off at 32 characters",
array(
"a test for the depth setting",
array(
"this should not show"
)
),
"third element",
"fourth element (still shows)",
"fifth element (should not show)"
);
var_dump($array);

$object = new stdClass;
$object->prop1 = "A very long string that should be cut off at 32 characters";
$object->array = array(
"a test for the depth setting",
array(
"this should not show"
)
);
$object->prop3 = "third element";
$object->prop4 = "fourth element (still shows)";
$object->prop5 = "fifth element (should not show)";
var_dump($object);
--EXPECTF--
array(5) {
[0] =>
string(58) 'A very long string that should b'...
[1] =>
array(2) {
[0] =>
string(28) 'a test for the depth setting'
[1] =>
array(1) {
...
}
}
[2] =>
string(13) 'third element'
[3] =>
string(28) 'fourth element (still shows)'

(more elements)...
}
class stdClass#1 (5) {
public $prop1 => string(58) 'A very long string that should b'...
public $array => array(2) {
[0] =>
string(28) 'a test for the depth setting'
[1] =>
array(1) {
...
}
}
public $prop3 => string(13) 'third element'
public $prop4 => string(28) 'fourth element (still shows)'

(more elements)...
}
1 change: 1 addition & 0 deletions tests/bug00470.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
Expand Down
1 change: 1 addition & 0 deletions tests/bug00472.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
Expand Down
1 change: 1 addition & 0 deletions tests/bug00515.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
Expand Down
2 changes: 2 additions & 0 deletions tests/bug00535.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
Test for bug #535: Code coverage and return before function|class ending
--INI--
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage();
Expand Down
1 change: 1 addition & 0 deletions tests/bug00538-2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Test for bug #538: Error in watches and call stack parameter with string containing '\\'
--INI--
xdebug.collect_params=3
xdebug.overload_var_dump=0
--FILE--
<?php
function call($param1, $param2, $param3)
Expand Down
1 change: 1 addition & 0 deletions tests/bug00562.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Test for bug #562: Incorrect coverage information for closure function headers
<?php if (!version_compare(phpversion(), "5.3", '>=')) echo "skip >= PHP 5.3 needed\n"; ?>
--INI--
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php

Expand Down
2 changes: 2 additions & 0 deletions tests/bug00651.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
Test for bug #651: Incorrect code coverage after ! empty() in conditional
--INI--
xdebug.overload_var_dump=0
--FILE--
<?php

Expand Down
2 changes: 2 additions & 0 deletions tests/bug00651b.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
Test for bug #651: Incorrect code coverage after empty() in conditional
--INI--
xdebug.overload_var_dump=0
--FILE--
<?php

Expand Down
2 changes: 2 additions & 0 deletions tests/bug00651c.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
Test for bug #651: Incorrect code coverage after isset() in conditional
--INI--
xdebug.overload_var_dump=0
--FILE--
<?php

Expand Down
1 change: 1 addition & 0 deletions tests/bug00693.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Test for bug #693: Cachegrind files not written when filename is very long
xdebug.profiler_enable=1
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=cachegrind.01-%r.02-%r.03-%r.04-%r.05-%r.06-%r.07-%r.08-%r.09-%r.10-%r.11-%r.12-%r.13-%r.14-%r.15-%r.16-%r.17-%r.18-%r.19-%r.20-%r.21-%r.22-%r.23-%r.24-%r.25-%r.26-%r.27-%r.28-%r.29-%r.30
xdebug.overload_var_dump=0
--FILE--
<?php
$file = xdebug_get_profiler_filename();
Expand Down
1 change: 1 addition & 0 deletions tests/bug00697.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
Expand Down
1 change: 1 addition & 0 deletions tests/bug00703.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
Expand Down
1 change: 1 addition & 0 deletions tests/coverage.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage();
Expand Down
1 change: 1 addition & 0 deletions tests/coverage2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
Expand Down
1 change: 1 addition & 0 deletions tests/coverage3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.coverage_enable=1
xdebug.overload_var_dump=0
--FILE--
<?php
function a($b)
Expand Down
1 change: 1 addition & 0 deletions tests/coverage4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.extended_info=1
xdebug.overload_var_dump=0
--FILE--
<?php
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
Expand Down
1 change: 1 addition & 0 deletions tests/get_declared_vars.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ xdebug.profiler_enable=0
xdebug.dump_globals=0
xdebug.collect_vars=1
xdebug.show_local_vars=0
xdebug.overload_var_dump=0
--FILE--
<?php
function a($a,$b) {
Expand Down
1 change: 1 addition & 0 deletions tests/test8.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ xdebug.show_mem_delta=0
xdebug.trace_format=0
xdebug.var_display_max_depth=5
xdebug.var_display_max_children=4
xdebug.overload_var_dump=0
--FILE--
<?php
$tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE));
Expand Down
Loading

8 comments on commit 535df90

@leek
Copy link

@leek leek commented on 535df90 Mar 15, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a bit excited thinking this was in the recent 2.2.0rc1 release - but apparently it is not 😢

@derickr
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It most definitely is. If you want colours you need to turn it on though with xdebug.cli_color=1

@leek
Copy link

@leek leek commented on 535df90 Mar 15, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... it seems (at least to me) as if the variable doesn't exist. Here is my output from php -i:

xdebug

xdebug support => enabled
Version => 2.2.0rc1

Supported protocols => Revision
DBGp - Common DeBuGger Protocol => $Revision: 1.145 $

Directive => Local Value => Master Value
xdebug.auto_trace => Off => Off
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 3 => 3
xdebug.collect_return => Off => Off
xdebug.collect_vars => Off => Off
xdebug.coverage_enable => On => On
xdebug.default_enable => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.extended_info => On => On
xdebug.file_link_format => no value => no value
xdebug.idekey => leek => no value
xdebug.manual_url => http://www.php.net => http://www.php.net
xdebug.max_nesting_level => 200 => 200
xdebug.overload_var_dump => On => On
xdebug.profiler_aggregate => Off => Off
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => Off => Off
xdebug.profiler_enable_trigger => On => On
xdebug.profiler_output_dir => D:\temp\php\5.3.10 => D:\temp\php\5.3.10
xdebug.profiler_output_name => cachegrind.out.%H.%t.%p => cachegrind.out.%H.%t.%p
xdebug.remote_autostart => Off => Off
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
xdebug.scream => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => On => On
xdebug.trace_enable_trigger => On => On
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => D:\temp\php\5.3.10 => D:\temp\php\5.3.10
xdebug.trace_output_name => trace.%H.%t.%p => trace.%H.%t.%p
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 10 => 10

... and the relevant section from my php.ini:

[xdebug]
zend_extension = "ext\php_xdebug-2.2.0rc1-5.3-vc9-x86.dll"
xdebug.cli_color            = 1
xdebug.profiler_output_dir  = "D:\temp\php\5.3.10"
xdebug.profiler_output_name = "cachegrind.out.%H.%t.%p"
xdebug.trace_output_dir     = "D:\temp\php\5.3.10"
xdebug.trace_output_name    = "trace.%H.%t.%p"

@leek
Copy link

@leek leek commented on 535df90 Mar 15, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derickr Let me know if there's any other debugging information you might need for this and I'll gladly post (either here or by creating an issue on the xDebug bug tracker).

@derickr
Copy link
Contributor Author

@derickr derickr commented on 535df90 Mar 15, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leek
Copy link

@leek leek commented on 535df90 Mar 15, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derickr Ahh... I was going based off of the commit message:

Ought to work on Windows too

It would be nice if xDebug would check for the ANSICON environment variable and allow color coding on Windows.

This is what Symfony2 does and I get nice colored output:

... Or really - it could just obey the cli_color variable and a note could be added to the documentation for Windows users.
This is what PHPUnit does, for example.

@derickr
Copy link
Contributor Author

@derickr derickr commented on 535df90 Mar 15, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leek
Copy link

@leek leek commented on 535df90 Mar 15, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, all set here: http://bugs.xdebug.org/view.php?id=794

Please sign in to comment.