function _acquia_purge_export_debug_symbols in Acquia Purge 6
Same name and namespace in other branches
- 7 acquia_purge.deprecated.inc \_acquia_purge_export_debug_symbols()
Turn a PHP variable into a string with data type information for debugging.
@returns A one-line comma separated string with data types as var_dump() generates.
Parameters
mixed $symbols: Arbitrary PHP variable, preferably a associative array.
1 call to _acquia_purge_export_debug_symbols()
- _acquia_purge_queue_processpurge_requests in ./
acquia_purge.module - Queue manager: process the given HTTP requests and do it efficiently.
File
- ./
acquia_purge.module, line 273 - Acquia Purge, Top-notch Varnish purging on Acquia Cloud!
Code
function _acquia_purge_export_debug_symbols($symbols) {
// Capture a string using PHPs very own var_dump() using output buffering.
ob_start();
var_dump($symbols);
$symbols = ob_get_clean();
// Clean up and reduce the output footprint for both normal and xdebug output.
if (extension_loaded('xdebug')) {
$symbols = trim(html_entity_decode(strip_tags($symbols)));
$symbols = drupal_substr($symbols, strpos($symbols, "\n") + 1);
$symbols = str_replace(" '", '', $symbols);
$symbols = str_replace("' =>", ':', $symbols);
$symbols = implode(', ', explode("\n", $symbols));
}
else {
$symbols = strip_tags($symbols);
$symbols = drupal_substr($symbols, strpos($symbols, "\n") + 1);
$symbols = str_replace(' ["', '', $symbols);
$symbols = str_replace("\"]=>\n ", ':', $symbols);
$symbols = rtrim($symbols, "}\n");
$symbols = implode(', ', explode("\n", $symbols));
}
// To reduce bandwidth and storage needs we shorten data type indicators.
$symbols = str_replace(' string', 'S', $symbols);
$symbols = str_replace(' int', 'I', $symbols);
$symbols = str_replace(' float', 'F', $symbols);
$symbols = str_replace(' boolean', 'B', $symbols);
$symbols = str_replace(' bool', 'B', $symbols);
$symbols = str_replace(' null', 'NLL', $symbols);
$symbols = str_replace(' NULL', 'NLL', $symbols);
$symbols = str_replace('length=', 'l=', $symbols);
// Return the resulting string.
return $symbols;
}