Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 06d4de41b042931f606f80e433b00ad2e19bd51a 1 parent b869948
Jan Moesen authored February 15, 2012

Showing 1 changed file with 5 additions and 2 deletions. Show diff stats Hide diff stats

  1. 7  spoon/spoon.php
7  spoon/spoon.php
@@ -197,8 +197,11 @@ public static function dump($var, $exit = true)
197 197
 		var_dump($var);
198 198
 		$output = ob_get_clean();
199 199
 
200  
-		// no xdebug installed
201  
-		if(!extension_loaded('xdebug'))
  200
+		// Make sure var_dump is not overridden by Xdebug before tweaking its output.
  201
+		// Note that all truthy INI values ("On", "true", 1) are returned as "1" by ini_get().
  202
+		$hasXdebugVarDump = extension_loaded('xdebug') && ini_get('xdebug.overload_var_dump') === '1';
  203
+
  204
+		if(!$hasXdebugVarDump)
202 205
 		{
203 206
 			$output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
204 207
 			$output = '<pre>' . htmlspecialchars($output, ENT_QUOTES, SPOON_CHARSET) . '</pre>';

0 notes on commit 06d4de4

Please sign in to comment.
Something went wrong with that request. Please try again.