Permalink
Browse files

Merge pull request #33 from janmoesen/improve-var_dump-xdebug-check

Spoon::dump: improve Xdebug var_dump detection
  • Loading branch information...
bauffman committed Feb 19, 2012
2 parents b869948 + 06d4de4 commit ebf29464c11ba2ae734abf0b5cf928a0e3e00a5c
Showing with 5 additions and 2 deletions.
  1. +5 −2 spoon/spoon.php
View
@@ -197,8 +197,11 @@ public static function dump($var, $exit = true)
var_dump($var);
$output = ob_get_clean();
- // no xdebug installed
- if(!extension_loaded('xdebug'))
+ // Make sure var_dump is not overridden by Xdebug before tweaking its output.
+ // Note that all truthy INI values ("On", "true", 1) are returned as "1" by ini_get().
+ $hasXdebugVarDump = extension_loaded('xdebug') && ini_get('xdebug.overload_var_dump') === '1';
+
+ if(!$hasXdebugVarDump)
{
$output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
$output = '<pre>' . htmlspecialchars($output, ENT_QUOTES, SPOON_CHARSET) . '</pre>';

0 comments on commit ebf2946

Please sign in to comment.