Skip to content
Browse files

Spoon::dump: improve Xdebug var_dump detection

It is possible to have Xdebug loaded, but not have it override the var_dump
output. This leaves the output lacking.

Note that Xdebug is smart about the SAPI: it only outputs HTML when it is
expected to. The CLI does not get HTML. Spoon::dump() would profit from a
similar approach.
  • Loading branch information
janmoesen committed Feb 15, 2012
1 parent b869948 commit 06d4de41b042931f606f80e433b00ad2e19bd51a
Showing with 5 additions and 2 deletions.
  1. +5 −2 spoon/spoon.php
@@ -197,8 +197,11 @@ public static function dump($var, $exit = true)
$output = ob_get_clean();

// no xdebug installed
// 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';

$output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
$output = '<pre>' . htmlspecialchars($output, ENT_QUOTES, SPOON_CHARSET) . '</pre>';

0 comments on commit 06d4de4

Please sign in to comment.
You can’t perform that action at this time.