getVariableName fix (#12)
This commit is contained in:
parent
f7d3d26a38
commit
d00db454c2
3 changed files with 26 additions and 20 deletions
|
@ -17,10 +17,8 @@
|
|||
}
|
||||
],
|
||||
"require" : {
|
||||
"php" : ">=5.3"
|
||||
},
|
||||
"suggest" : {
|
||||
"ext-Reflection" : "to show protected and private info (now is only implemented for Exceptions)"
|
||||
"php" : ">=5.3",
|
||||
"ext-Reflection" : "to show protected and private info (now is only implemented for Exceptions) and to work with types in stack"
|
||||
},
|
||||
"support" : {
|
||||
"issues" : "https://github.com/KOLANICH/dBug/issues"
|
||||
|
|
8
dBug.php
8
dBug.php
|
@ -42,6 +42,7 @@ class dBug
|
|||
public $bCollapsed = false;
|
||||
public $arrHistory = array();
|
||||
public static $embeddedStringMaxLength=50;
|
||||
public $classRefl;
|
||||
|
||||
/*!
|
||||
@param mixed $var Variable to dump
|
||||
|
@ -55,6 +56,8 @@ class dBug
|
|||
define('BDBUGINIT', true);
|
||||
static::initJSandCSS();
|
||||
}
|
||||
$this->classRefl = new \ReflectionClass(get_class($this));
|
||||
|
||||
$arrAccept=array("array",'object',"xml"); //array of variable types that can be "forced"
|
||||
$this->bCollapsed = $bCollapsed;
|
||||
if(in_array($forceType, $arrAccept))
|
||||
|
@ -75,7 +78,7 @@ class dBug
|
|||
for ($i=count($arrBacktrace)-1; $i>=0; $i--) {
|
||||
$arrCurrent = $arrBacktrace[$i];
|
||||
if(array_key_exists("function", $arrCurrent) &&
|
||||
(in_array($arrCurrent["function"], $arrInclude) || (0 != strcasecmp($arrCurrent["function"], "dbug"))))
|
||||
(in_array($arrCurrent["function"], $arrInclude) || (0 != strcasecmp($arrCurrent["function"], $this->classRefl->getConstructor()->getName()))))
|
||||
continue;
|
||||
|
||||
$arrFile = $arrCurrent;
|
||||
|
@ -88,8 +91,7 @@ class dBug
|
|||
$code = $arrLines[($arrFile["line"]-1)];
|
||||
|
||||
//find call to dBug class
|
||||
preg_match('/\bnew dBug\s*\(\s*(.+)\s*\);/i', $code, $arrMatches);
|
||||
|
||||
preg_match('/\bnew\s+(?:'.preg_quote($this->classRefl->getNamespaceName()).'\\\\)?'.preg_quote($this->classRefl->getShortName()).'\s*\(\s*(.+)\s*\);/i', $code, $arrMatches);
|
||||
return isset($arrMatches[1])?$arrMatches[1]:'[multiline]';
|
||||
}
|
||||
|
||||
|
|
32
tests.php
32
tests.php
|
@ -15,6 +15,10 @@ ini_set('display_errors', 1);
|
|||
}
|
||||
new dBug($a);
|
||||
new myDBug($a);
|
||||
new myDBug("test", "", true);
|
||||
new dBug(
|
||||
$a
|
||||
);
|
||||
|
||||
$a="The quick brown fox jumps over the lazy dog\nThe five boxing wizards jump quickly.\r\nСъешь же ещё этих мягких французских булок, да выпей чаю\n";
|
||||
new dBug($a);
|
||||
|
@ -89,18 +93,20 @@ ini_set('display_errors', 1);
|
|||
|
||||
//drawing Sierpinsky triangle
|
||||
//http://php.net/manual/en/function.imagesetpixel.php
|
||||
$x = 200;
|
||||
$y = 200;
|
||||
$img = imagecreatetruecolor($x, $y);
|
||||
|
||||
$corners[0] = array('x' => 100, 'y' => 10);
|
||||
$corners[1] = array('x' => 0, 'y' => 190);
|
||||
$corners[2] = array('x' => 200, 'y' => 190);
|
||||
{
|
||||
$x = 200;
|
||||
$y = 200;
|
||||
$img = imagecreatetruecolor($x, $y);
|
||||
|
||||
$corners[0] = array('x' => 100, 'y' => 10);
|
||||
$corners[1] = array('x' => 0, 'y' => 190);
|
||||
$corners[2] = array('x' => 200, 'y' => 190);
|
||||
|
||||
for ($i = 0; $i < 10000; $i++) {
|
||||
$a = rand(0, 2);
|
||||
imagesetpixel($img, round($x), round($y), imagecolorallocate($img, 255*$x/190, 255*(1-$y/190), 255*$a/2));
|
||||
$x = ($x + $corners[$a]['x']) / 2;
|
||||
$y = ($y + $corners[$a]['y']) / 2;
|
||||
for ($i = 0; $i < 10000; $i++) {
|
||||
$a = rand(0, 2);
|
||||
imagesetpixel($img, round($x), round($y), imagecolorallocate($img, 255*$x/190, 255*(1-$y/190), 255*$a/2));
|
||||
$x = ($x + $corners[$a]['x']) / 2;
|
||||
$y = ($y + $corners[$a]['y']) / 2;
|
||||
}
|
||||
new dBug($img);
|
||||
}
|
||||
new dBug($img);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue