Skip to content

Commit

Permalink
Fix #7, Fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
LePampim committed Feb 16, 2024
1 parent 105a609 commit 3fe2ed2
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 60 deletions.
6 changes: 2 additions & 4 deletions examples/example_simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$isDev = true;

require_once "../fastDbgPHP.class.php";
require_once "./fastDbgPHP.class.php";

// FastDbgPHP Configuration
FastDbgPHP::setDevelopmentMode($isDev);
Expand All @@ -23,8 +23,6 @@
"age" => 18,
"from" => "Brazil"
];
$i = new DateTime();

fdbg($a, $b, $c, $d, $e, $f, $g, $h, $i);
fdbg($a, $b, $c, $d, $e, $f, $g, $h);

fdbg();
11 changes: 7 additions & 4 deletions examples/example_standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$start_time = microtime(true);
$isDev = true;

require_once "../fastDbgPHP.class.php";
require_once "./fastDbgPHP.class.php";

// FastDbgPHP Configuration
FastDbgPHP::setDevelopmentMode($isDev);
Expand All @@ -12,7 +12,8 @@
FastDbgPHP::setInicialTime($start_time);
FastDbgPHP::setProjectName("Project Example");
FastDbgPHP::setDefaultValues(["##GET", "##POST", "##SERVER"]);
FastDbgPHP::setIsExit(false);
FastDbgPHP::setIsExit(true);
// FastDbgPHP::setclickToCopy(false);
FastDbgPHP::setStyles([
"header" => "color: #404040;
font-size: 18px;
Expand Down Expand Up @@ -44,8 +45,10 @@ public function __construct(
"from" => "Brazil"
];
$i = new Person("Maria", 7);
$j = new DateTime();
$k = " Espaços em branco antes e depois ";

fdbg($a, $b, $c, $d, $e, $f, $g, $h, $i);

fdbg($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k);
fdbg('##GETENV');
fdbg();

117 changes: 65 additions & 52 deletions fastDbgPHP.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FastDbgPHP
text-align: right;
padding: 5px 10px;
word-break: break-word;',
'arrays' => 'border: 1px solid #DCDCDC;
'arraysKey' => 'border: 1px solid #DCDCDC;
border-radius: 5px;
background-color: #EEE;
font-size: 12px;
Expand All @@ -60,6 +60,11 @@ class FastDbgPHP
text-align: left;
padding: 5px 10px;
margin: 1px;
word-break: break-word;',
'ArrayDetails' => 'color: #707070;
font-size: 10px;
font-style: italic;
text-align: right;
word-break: break-word;'
];

Expand Down Expand Up @@ -108,7 +113,7 @@ static public function setclickToCopy(bool $clickToCopy): void
*
* @param mixed ... $values
* ##TRACE - Show traceback
* ##GET, ##POST, ##SERVER, ##FILES, ##COOKIE, ##SESSION, ##REQUEST, ##ENV - Show global var
* ##GET, ##POST, ##SERVER, ##FILES, ##COOKIE, ##SESSION, ##REQUEST, ##ENV, ##GETENV - Show global var
* ##EXIT - Finish the code
* ##TIME
*/
Expand Down Expand Up @@ -137,7 +142,7 @@ static public function fdbg(mixed ...$values): void

$hasexit = static::$isExit;

echo '<div style="display: grid; grid-template-columns: 30% 70%;">';
echo '<div style="display: grid; grid-template-columns: 25% 75%;">';
foreach ($values as $value) {
if (is_null($value)) {
$type = get_debug_type($value);
Expand Down Expand Up @@ -173,6 +178,8 @@ static public function fdbg(mixed ...$values): void
}
} elseif ($value == "##REQUEST") {
static::generateDetailRow("🔗 Requests", $_REQUEST);
} elseif ($value == "##GETENV") {
static::generateDetailRow("🔗 Getenv", getenv());
} elseif ($value == "##ENV") {
static::generateDetailRow("🏠 Environment", $_ENV);
} elseif ($value == "##EXIT") {
Expand All @@ -187,17 +194,17 @@ static public function fdbg(mixed ...$values): void
$Mocno = '<a href ="https://github.com/mocno">Mocno</a>';
$fastDbgPHP = '<a href ="https://github.com/LePampim/FastdbgPHP">Fast Debug PHP</a>';



$creditMsg = "$fastDbgPHP developed by $LePampim and $Mocno. ";
if($hasexit)
$creditMsg .= "[❌ exited] ";
if (static::$clickToCopy)
$creditMsg .= "[📑 click to copy] ";

static::generateRowCredit($creditMsg);
echo '<div style="' . static::$styles['info'] . '"></div>';
echo '<div style="' . static::$styles['descriptionCredit'] . '">'.$creditMsg.'</div>';

echo "</div>";

echo '</div>';

if ($hasexit) exit;
Expand All @@ -206,84 +213,94 @@ static public function fdbg(mixed ...$values): void

static private function generateDetailRow(string $info, mixed $description)
{
if (is_string($description))
$info .= " [" . strlen($description) . "]";
elseif (is_array($description))
if (is_array($description))
$info .= " [" . count($description) . "]";

echo '<div style="' . static::$styles['info'] . '">'.$info.'</div>';
echo '<div style="' . static::$styles['description'] . '">';

if (is_string($description)) {
static::generateSimpleTable($description);
static::generateContent($description, static::$styles['descriptionArrays'], true, true);
} elseif (is_array($description)) {
if ($description) {
static::generateArrayTable((array) $description);
} else
static::generateSimpleTable("<i>Empty</i>");
static::generateContent("<i>Empty</i>", static::$styles['descriptionArrays'], true, false);
} elseif (is_object($description))
static::generateArrayTable((array) $description);
else
static::generateSimpleTable($description);
static::generateContent($description, static::$styles['descriptionArrays'], true);

echo '</div>';
}

static private function generateRow(string $info, mixed $description)
{
static::generateContent($info, static::$styles['info']);
echo '<div style="' . static::$styles['description'] . '">';
static::generateSimpleTable($description);
echo '</div>';
}
static private function generateTracebackRow(string $info)
{
static::generateContent($info, static::$styles['info']);
echo '<div style="' . static::$styles['description'] . '">';
echo '<div style="' . static::$styles['descriptionArrays'] . "\"><pre>";
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
echo '</pre></div></div>';
}
static private function generateRowCredit(mixed $description)
{
static::generateContent("", static::$styles['info']);
static::generateContent($description, static::$styles['descriptionCredit']);
}

static private function generateSimpleTable($value)
{
static::generateContent($value, static::$styles['descriptionArrays'], true);
}

static private function generateArrayTable(array $arrays)
{
echo '<div style="display: grid; grid-template-columns: 20% 80%;">';
foreach ($arrays as $key => $value) {
static::generateContent($key, static::$styles['arrays'], true);
static::generateContent($key, static::$styles['arraysKey'], true);
if (is_string($value))
static::generateContent($value, static::$styles['descriptionArrays'], true);
static::generateContent($value, static::$styles['descriptionArrays'], true, true);
else {
if (is_array($value)) {
if ($value)
static::generateArrayTable((array) $value);
else
static::generateContent("", static::$styles['descriptionArrays'], true);
static::generateContent("", static::$styles['descriptionArrays'], true, true);
} elseif (is_object($value)) {
static::generateArrayTable((array) $value);
} else {
static::generateContent($value, static::$styles['descriptionArrays'], true);
static::generateContent($value, static::$styles['descriptionArrays'], true, true);
}
}
}
echo '</div>';
}

static private function generateContent(string $value, string $style, bool $copy = false) {
if ($copy and static::$clickToCopy) {
static private function generateRow(string $info, mixed $description)
{
echo '<div style="' . static::$styles['info'] . '">'.$info.'</div>';
echo '<div style="' . static::$styles['description'] . '">';
static::generateContent($description, static::$styles['descriptionArrays'], true);
echo '</div>';
}

static private function generateTracebackRow(string $info)
{
static::generateContent($info, static::$styles['info'], false);
echo '<div style="' . static::$styles['description'] . '">';
echo '<div style="' . static::$styles['descriptionArrays'] . "\"><pre>";
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
echo '</pre></div></div>';
}

static private function generateContent(string $value, string $style, bool $copy = false, bool $len = false) {

if (trim($value) != $value)
$column = "20px";
else
$column = "";

echo "<div style=\"display: grid; grid-template-columns: auto $column 30px; $style;\">";

if ($copy and static::$clickToCopy)
{
$id = 'idCopy'.static::$buttomId += 1;
echo '<div title="click to copy." style="' . $style . "\" name=\"$id\" id='$id' onclick=\"copyTextFdbg(this.id)\" >$value</div>";
} else
echo '<div style="' . $style . "\"\" >$value</div>";
echo "<div title='click to copy.' name=\"$id\" id='$id' onclick=\"copyTextFdbg(this.id)\">$value</div>";
} else
echo '<div style="' . $style . "\">$value</div>";

if (trim($value) != $value and $style != static::$styles['descriptionCredit'])
echo '<div title="blank spaces at the beginning or end. ['.strlen(trim($value)).'/'.strlen($value).']" >🟧</div>';

if ($len)
echo '<div title="leng." style="' . static::$styles['ArrayDetails'] .'">'.strlen($value).'</div>';
else
echo '<div></div>';

echo '</div>';


}

static private function scriptCopyText (){
Expand All @@ -301,9 +318,5 @@ function copyTextFdbg(copyId) {
}
</script>";
}
static private function CSSSSSSS (){
echo "<style>
.fdbg-
</style>";
}

}

0 comments on commit 3fe2ed2

Please sign in to comment.