<?php
 class vB_Utility_Template_ParserNode_Curly_Debugvardump extends vB_Utility_Template_ParserNode_Curly_Raw { public function validate() : array { return []; } public function compile() : string { if (isset($this->main_node->attributes[0])) { $definedVarsCode = ''; $output = parent::compile(); $printFunc = !empty($this->main_node->attributes[1]) ? 'print_r' : 'var_dump'; } else { $definedVarsCode = '$VB_DEFINED_VARS = array_keys(get_defined_vars()); '; $output = '$VB_DEFINED_VARS'; $printFunc = 'print_r'; } if ($printFunc == 'var_dump') { $debug = '((ini_get("xdebug.default_enable") AND ini_get("xdebug.overload_var_dump")) ?  ob_get_clean() : "<pre>" . htmlspecialchars(ob_get_clean()) . "</pre>")'; } else { $debug = '"<pre>" . htmlspecialchars(ob_get_clean()) . "</pre>"'; } return '""; ' . $definedVarsCode . 'ob_start(); ' . $printFunc . '(' . $output . '); ' . '$final_rendered .= \'<div style="border:3px solid red;padding:10px;margin:10px;max-height:100px;overflow:auto;">' . $printFunc . ': ' . str_replace("'", '\\\'', $output) . '\' . ' . $debug . ' . \'</div>\'; $final_rendered .= \'\''; } } 