PSR2 compliance, with class alias
This commit is contained in:
parent
88fa6cbcdf
commit
3d1e5925a0
1 changed files with 37 additions and 35 deletions
72
dBug.php
72
dBug.php
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
<?php namespace dBug;
|
||||
|
||||
/*********************************************************************************************************************\
|
||||
* LAST UPDATE
|
||||
* ============
|
||||
|
@ -51,23 +52,24 @@
|
|||
*
|
||||
\*********************************************************************************************************************/
|
||||
|
||||
class dBug
|
||||
class_alias('\dBug\DBug', '\dBug');
|
||||
class DBug
|
||||
{
|
||||
|
||||
var $xmlDepth=array();
|
||||
var $xmlCData;
|
||||
var $xmlSData;
|
||||
var $xmlDData;
|
||||
var $xmlCount=0;
|
||||
var $xmlAttrib;
|
||||
var $xmlName;
|
||||
var $arrType=array("array","object","resource","boolean","NULL");
|
||||
var $bInitialized = false;
|
||||
var $bCollapsed = false;
|
||||
var $arrHistory = array();
|
||||
private $xmlDepth=array();
|
||||
private $xmlCData;
|
||||
private $xmlSData;
|
||||
private $xmlDData;
|
||||
private $xmlCount=0;
|
||||
private $xmlAttrib;
|
||||
private $xmlName;
|
||||
private $arrType=array("array","object","resource","boolean","NULL");
|
||||
private $bInitialized = false;
|
||||
private $bCollapsed = false;
|
||||
private $arrHistory = array();
|
||||
|
||||
//constructor
|
||||
function __construct($var, $forceType = "", $bCollapsed = false)
|
||||
public function __construct($var, $forceType = "", $bCollapsed = false)
|
||||
{
|
||||
//include js and css scripts
|
||||
if (!defined('BDBUGINIT')) {
|
||||
|
@ -84,7 +86,7 @@ class dBug
|
|||
}
|
||||
|
||||
//get variable name
|
||||
function getVariableName()
|
||||
private function getVariableName()
|
||||
{
|
||||
$arrBacktrace = debug_backtrace();
|
||||
|
||||
|
@ -117,7 +119,7 @@ class dBug
|
|||
}
|
||||
|
||||
//create the main table header
|
||||
function makeTableHeader($type, $header, $colspan = 2)
|
||||
private function makeTableHeader($type, $header, $colspan = 2)
|
||||
{
|
||||
if (!$this->bInitialized) {
|
||||
$header = $this->getVariableName() . " (" . $header . ")";
|
||||
|
@ -132,7 +134,7 @@ class dBug
|
|||
}
|
||||
|
||||
//create the table row header
|
||||
function makeTDHeader($type, $header)
|
||||
private function makeTDHeader($type, $header)
|
||||
{
|
||||
$str_d = ($this->bCollapsed) ? " style=\"display:none\"" : "";
|
||||
echo "<tr".$str_d.">
|
||||
|
@ -141,13 +143,13 @@ class dBug
|
|||
}
|
||||
|
||||
//close table row
|
||||
function closeTDRow()
|
||||
private function closeTDRow()
|
||||
{
|
||||
return "</td></tr>\n";
|
||||
}
|
||||
|
||||
//error
|
||||
function error($type)
|
||||
private function error($type)
|
||||
{
|
||||
$error="Error: Variable cannot be a";
|
||||
// this just checks if the type starts with a vowel or "x" and displays either "a" or "an"
|
||||
|
@ -158,7 +160,7 @@ class dBug
|
|||
}
|
||||
|
||||
//check variable type
|
||||
function checkType($var)
|
||||
private function checkType($var)
|
||||
{
|
||||
switch (gettype($var)) {
|
||||
case "resource":
|
||||
|
@ -184,20 +186,20 @@ class dBug
|
|||
}
|
||||
|
||||
//if variable is a NULL type
|
||||
function varIsNULL()
|
||||
private function varIsNULL()
|
||||
{
|
||||
echo "NULL";
|
||||
}
|
||||
|
||||
//if variable is a boolean type
|
||||
function varIsBoolean($var)
|
||||
private function varIsBoolean($var)
|
||||
{
|
||||
$var=($var==1) ? "TRUE" : "FALSE";
|
||||
echo $var;
|
||||
}
|
||||
|
||||
//if variable is an array type
|
||||
function varIsArray($var)
|
||||
private function varIsArray($var)
|
||||
{
|
||||
$var_ser = serialize($var);
|
||||
array_push($this->arrHistory, $var_ser);
|
||||
|
@ -231,7 +233,7 @@ class dBug
|
|||
}
|
||||
|
||||
//if variable is an object type
|
||||
function varIsObject($var)
|
||||
private function varIsObject($var)
|
||||
{
|
||||
$var_ser = serialize($var);
|
||||
array_push($this->arrHistory, $var_ser);
|
||||
|
@ -270,7 +272,7 @@ class dBug
|
|||
}
|
||||
|
||||
//if variable is a resource type
|
||||
function varIsResource($var)
|
||||
private function varIsResource($var)
|
||||
{
|
||||
$this->makeTableHeader("resourceC", "resource", 1);
|
||||
echo "<tr>\n<td>\n";
|
||||
|
@ -299,7 +301,7 @@ class dBug
|
|||
}
|
||||
|
||||
//if variable is a database resource type
|
||||
function varIsDBResource($var, $db = "mysql")
|
||||
private function varIsDBResource($var, $db = "mysql")
|
||||
{
|
||||
if ($db == "pgsql") {
|
||||
$db = "pg";
|
||||
|
@ -348,7 +350,7 @@ class dBug
|
|||
}
|
||||
|
||||
//if variable is an image/gd resource type
|
||||
function varIsGDResource($var)
|
||||
private function varIsGDResource($var)
|
||||
{
|
||||
$this->makeTableHeader("resource", "gd", 2);
|
||||
$this->makeTDHeader("resource", "Width");
|
||||
|
@ -361,13 +363,13 @@ class dBug
|
|||
}
|
||||
|
||||
//if variable is an xml type
|
||||
function varIsXml($var)
|
||||
private function varIsXml($var)
|
||||
{
|
||||
$this->varIsXmlResource($var);
|
||||
}
|
||||
|
||||
//if variable is an xml resource type
|
||||
function varIsXmlResource($var)
|
||||
private function varIsXmlResource($var)
|
||||
{
|
||||
$xml_parser=xml_parser_create();
|
||||
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
|
||||
|
@ -401,7 +403,7 @@ class dBug
|
|||
}
|
||||
|
||||
//parse xml
|
||||
function xmlParse($xml_parser, $data, $bFinal)
|
||||
private function xmlParse($xml_parser, $data, $bFinal)
|
||||
{
|
||||
if (!xml_parse($xml_parser, $data, $bFinal)) {
|
||||
die(sprintf(
|
||||
|
@ -413,7 +415,7 @@ class dBug
|
|||
}
|
||||
|
||||
//xml: inititiated when a start tag is encountered
|
||||
function xmlStartElement($parser, $name, $attribs)
|
||||
private function xmlStartElement($parser, $name, $attribs)
|
||||
{
|
||||
$this->xmlAttrib[$this->xmlCount]=$attribs;
|
||||
$this->xmlName[$this->xmlCount]=$name;
|
||||
|
@ -431,7 +433,7 @@ class dBug
|
|||
}
|
||||
|
||||
//xml: initiated when an end tag is encountered
|
||||
function xmlEndElement($parser, $name)
|
||||
private function xmlEndElement($parser, $name)
|
||||
{
|
||||
for ($i=0; $i<$this->xmlCount; $i++) {
|
||||
eval($this->xmlSData[$i]);
|
||||
|
@ -450,7 +452,7 @@ class dBug
|
|||
}
|
||||
|
||||
//xml: initiated when text between tags is encountered
|
||||
function xmlCharacterData($parser, $data)
|
||||
private function xmlCharacterData($parser, $data)
|
||||
{
|
||||
$count=$this->xmlCount-1;
|
||||
if (!empty($this->xmlCData[$count])) {
|
||||
|
@ -461,7 +463,7 @@ class dBug
|
|||
}
|
||||
|
||||
//xml: initiated when a comment or other miscellaneous texts is encountered
|
||||
function xmlDefaultHandler($parser, $data)
|
||||
private function xmlDefaultHandler($parser, $data)
|
||||
{
|
||||
//strip '<!--' and '-->' off comments
|
||||
$data=str_replace(array("<!--","-->"), "", htmlspecialchars($data));
|
||||
|
@ -473,7 +475,7 @@ class dBug
|
|||
}
|
||||
}
|
||||
|
||||
function initJSandCSS()
|
||||
private function initJSandCSS()
|
||||
{
|
||||
echo <<<SCRIPTS
|
||||
<script language="JavaScript">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue