From 7fb9cade79715b30a30b9e3e14c7888dd71004de Mon Sep 17 00:00:00 2001 From: Brad Kent Date: Wed, 3 Dec 2014 23:21:56 -0600 Subject: [PATCH] 1.2 release candidate for real this time update to readme updates to unit-test's Test class VarDump - objects - list properties before methods VarDump - tables - remove deprecated html attributes / move vertical alignment to css. fixed nested array bug --- Debug.php | 2 +- README.md | 17 +++++++++++++++++ VarDump.php | 12 ++++++------ css/Debug.css | 2 +- tests/Test.php | 52 +++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 76 insertions(+), 9 deletions(-) diff --git a/Debug.php b/Debug.php index 8e325ed8..51686a7f 100644 --- a/Debug.php +++ b/Debug.php @@ -391,7 +391,7 @@ public function set($path, $newVal = null) } if (isset($new['debug']['emailTo']) && !isset($new['errorHandler']['emailTo'])) { // also set errorHandler's emailTo - $new['errorHandler']['emailTo'] = $new['emailTo']; + $new['errorHandler']['emailTo'] = $new['debug']['emailTo']; } if (isset($new['data'])) { $this->data = array_merge($this->data, $new['data']); diff --git a/README.md b/README.md index 8417d6d6..f667b3a9 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,22 @@ Browser/javascript like console class for PHP ![Screenshot of PHPDebugConsole's Output](http://www.bradkent.com/images/bradkent.com/php/screenshot.png) +### Installation +This library requires PHP 5.0 or later (PHP 5.2 to "catch" fatal errors), and has no userland dependencies. + +It is installable and autoloadable via [Composer](https://getcomposer.org/) as [bdk/debug](https://packagist.org/packages/bdk/debug). + +```json +{ + "require": { + "bdk/debug": "~1.2", + } +} +``` +Alternatively, [download a release](https://github.com/bkdotcom/debug/releases) or clone this repository, then require or include its `Debug.php`_ file + +See http://www.bradkent.com/?page=php/debug for more information + ### Methods * log @@ -27,6 +43,7 @@ Browser/javascript like console class for PHP * timeEnd * *… [more](http://www.bradkent.com/?page=php/debug#docs-methods)* +### Quality [![SensioLabsInsight](https://insight.sensiolabs.com/projects/789295b4-6040-4367-8fd5-b04a6f0d7a0c/big.png)](https://insight.sensiolabs.com/projects/789295b4-6040-4367-8fd5-b04a6f0d7a0c) ### Changelog diff --git a/VarDump.php b/VarDump.php index 9f98ced5..deda061a 100644 --- a/VarDump.php +++ b/VarDump.php @@ -280,7 +280,7 @@ public function dumpTable($array, $caption = null) $str = '
'.$str.'
'; } else { $keys = $this->utilities->arrayColKeys($array); - $str = ''."\n" // style="border:solid 1px;" + $str = '
'."\n" .''."\n"; $values = array(); foreach ($keys as $key) { @@ -326,7 +326,7 @@ protected function dumpTableRow($keys, $row, $rowKey) $value = $row; } if (is_array($value)) { - $value = call_user_func(array($this,__FUNCTION__), $value); + $value = $this->dumpTable($value); } elseif ($value === $undefined) { $value = ''; } else { @@ -339,7 +339,7 @@ protected function dumpTableRow($keys, $row, $rowKey) $class = $matches[1]; $rowKey = $matches[2]; } - $str .= ''; + $str .= ''; foreach ($values as $v) { // remove the span wrapper.. add span's class to TD $class = null; @@ -406,8 +406,8 @@ protected function getValueAbstraction($val, $opts = array(), $hist = array()) ); if ($opts['html'] || $opts['flatten']) { $val = $val['class']."\n" - .' methods: '.$val['methods']."\n" - .' properties: '.$val['properties']; + .' properties: '.$val['properties']."\n" + .' methods: '.$val['methods']; if ($opts['flatten'] && count($hist) > 1) { $val = str_replace("\n", "\n ", $val); } @@ -459,7 +459,7 @@ protected function getValueHtml($val, $type = null, $typeMore = null) '\1'."\n".'\2', $val ); - $html = preg_replace('#\sproperties: #', '
properties: ', $html); + $html = preg_replace('#\smethods: #', '
methods: ', $html); $val = ''.$html.''; } elseif ($type) { $attribs = array( diff --git a/css/Debug.css b/css/Debug.css index 786af646..4919ccfa 100644 --- a/css/Debug.css +++ b/css/Debug.css @@ -39,7 +39,7 @@ .debug table { border-collapse:collapse; } .debug table caption { font-weight:bold; font-style:italic; } .debug table th { font-weight:bold; background-color: rgba(0,0,0,0.1); } -.debug table th, .debug table td { border:1px solid #000; padding:1px .25em; } +.debug table th, .debug table td { border:1px solid #000; padding:1px .25em; vertical-align:top; } .debug ul { margin-top: 0; margin-bottom: 0; } .debug .alert { diff --git a/tests/Test.php b/tests/Test.php index 8b1d6713..01055b5b 100644 --- a/tests/Test.php +++ b/tests/Test.php @@ -1,11 +1,61 @@
'.$caption.'
'.$rowKey.'
'.$rowKey.'