diff --git a/dBug.php b/dBug.php
index bc109b7..346d2a8 100755
--- a/dBug.php
+++ b/dBug.php
@@ -2,6 +2,9 @@
/*********************************************************************************************************************\
* LAST UPDATE
* ============
+ * Jan 25, 2012 by maliayas
+ * Sep 29, 2011 by maliayas
+ * July 25, 2011 by maliayas
* March 22, 2007
*
*
@@ -96,12 +99,12 @@ function getVariableName() {
if(isset($arrFile)) {
$arrLines = file($arrFile["file"]);
- $code = $arrLines[($arrFile["line"]-1)];
+ $code = @$arrLines[($arrFile["line"]-1)];
//find call to dBug class
- preg_match('/\bnew dBug\s*\(\s*(.+)\s*\);/i', $code, $arrMatches);
+ preg_match('/\bnew\s+dBug\s*\(\s*(.+?)\s*\)\s*;/i', $code, $arrMatches);
- return $arrMatches[1];
+ return @$arrMatches[1];
}
return "";
}
@@ -121,10 +124,10 @@ function makeTableHeader($type,$header,$colspan=2) {
}
//create the table row header
- function makeTDHeader($type,$header) {
+ function makeTDHeader($type,$header, $title = '') {
$str_d = ($this->bCollapsed) ? " style=\"display:none\"" : "";
echo "
- | ".$header." |
+ ".$header." |
";
}
@@ -161,21 +164,26 @@ function checkType($var) {
$this->varIsBoolean($var);
break;
default:
- $var=($var=="") ? "[empty string]" : $var;
- echo "\n";
+ $this->makeTableHeader('simpleVar',gettype($var));
+ $var=($var==="") ? "[empty string]" : $var;
+ //echo "\n";
+ echo ' |
| ' . htmlspecialchars($var) . ' |
';
+ echo "";
+
break;
}
}
//if variable is a NULL type
function varIsNULL() {
- echo "NULL";
+ $this->makeTableHeader('simpleVar',"null");
+ echo "";
}
//if variable is a boolean type
function varIsBoolean($var) {
- $var=($var==1) ? "TRUE" : "FALSE";
- echo $var;
+ $this->makeTableHeader('simpleVar',($var==1) ? "true" : "false");
+ echo "";
}
//if variable is an array type
@@ -199,7 +207,7 @@ function varIsArray($var) {
$this->checkType($value);
else {
$value=(trim($value)=="") ? "[empty string]" : $value;
- echo $value;
+ echo htmlspecialchars($value);
}
echo $this->closeTDRow();
}
@@ -216,32 +224,64 @@ function varIsObject($var) {
$this->makeTableHeader("object","object");
if(is_object($var)) {
- $arrObjVars=get_object_vars($var);
- foreach($arrObjVars as $key=>$value) {
-
- $value=(!is_object($value) && !is_array($value) && trim($value)=="") ? "[empty string]" : $value;
- $this->makeTDHeader("object",$key);
+ $varRef = new ReflectionObject($var);
+
+ $props = $varRef->getProperties();
+ foreach($props as $prop) {
+ $prop->setAccessible(true);
+ $propValue = $prop->getValue($var);
+ $propName = $prop->getName();
+ $propModifiers = implode(' ', Reflection::getModifierNames($prop->getModifiers()));
+ $propAttr = $prop->isPublic() ? '+' : ($prop->isPrivate() ? '-' : '#');
+ $propAttr = '[' . $propAttr . ($prop->isStatic() ? 'S' : '') . '] ';
+
+ $propValue=(gettype($propValue) == "string" && trim($propValue)==="") ? "[empty string]" : $propValue;
+ $this->makeTDHeader("object",$propAttr . $propName, $propModifiers);
//check for recursion
- if(is_object($value)||is_array($value)) {
- $var_ser = serialize($value);
+ if(is_object($propValue)||is_array($propValue)) {
+ $var_ser = serialize($propValue);
if(in_array($var_ser, $this->arrHistory, TRUE)) {
- $value = (is_object($value)) ? "*RECURSION* -> $".get_class($value) : "*RECURSION*";
+ $propValue = (is_object($propValue)) ? "*RECURSION* -> $".get_class($propValue) : "*RECURSION*";
}
}
- if(in_array(gettype($value),$this->arrType))
- $this->checkType($value);
- else echo $value;
+ if(in_array(gettype($propValue),$this->arrType))
+ $this->checkType($propValue);
+ else echo htmlspecialchars($propValue);
+ echo $this->closeTDRow();
+ }
+
+ $consts = $varRef->getConstants();
+ foreach($consts as $key => $const) {
+ $const=(gettype($const) == "string" && $const === "") ? "[empty string]" : $const;
+ $this->makeTDHeader("object",'[C] ' . $key);
+
+ echo htmlspecialchars($const);
echo $this->closeTDRow();
}
- $arrObjMethods=get_class_methods(get_class($var));
- foreach($arrObjMethods as $key=>$value) {
- $this->makeTDHeader("object",$value);
- echo "[function]".$this->closeTDRow();
+
+ $methods = $varRef->getMethods();
+ foreach($methods as $method) {
+ $method->setAccessible(true);
+ $methodName = $method->name;
+ $methodModifiers = implode(' ', Reflection::getModifierNames($method->getModifiers()));
+ $methodAttr = $method->isPublic() ? '+' : ($method->isPrivate() ? '-' : '#');
+ $methodAttr = '[' . $methodAttr
+ . ($method->isStatic() ? 'S' : '')
+ . ($method->isAbstract() ? 'A' : '')
+ . ($method->isFinal() ? 'F' : '') . '] ';
+
+ $this->makeTDHeader("object", $methodAttr . $methodName, $methodModifiers);
+
+ echo htmlspecialchars('[method]');
+ echo $this->closeTDRow();
}
+
+ } else {
+ echo "| ".$this->error("object").$this->closeTDRow();
}
- else echo " |
| ".$this->error("object").$this->closeTDRow();
+
array_pop($this->arrHistory);
echo "";
}
@@ -478,22 +518,32 @@ function dBug_toggleTable(source) {
|