1 Commits
1.0.1 ... 1.1

Author SHA1 Message Date
User
30de3eb13a 20230818#3 2023-08-18 02:55:26 +03:00
3 changed files with 22 additions and 25 deletions

View File

@@ -10,10 +10,3 @@ composer require --dev rmphp/var-damper
```bash ```bash
composer require --dev rmphp/var-damper:"^1.0" composer require --dev rmphp/var-damper:"^1.0"
``` ```
Dev version contains the latest changes
```bash
composer require --dev rmphp/var-damper:"1.0.x-dev"
```

View File

@@ -12,6 +12,7 @@ class Dumper {
private static string $objhex; private static string $objhex;
private static int $objid = 0; private static int $objid = 0;
private static int $deep = 0; private static int $deep = 0;
private static string $blockTitle = "array";
private static function initObjhex() : void { private static function initObjhex() : void {
self::$objid++; self::$objid++;
@@ -56,7 +57,7 @@ class Dumper {
private static function generateStartLine(): void { private static function generateStartLine(): void {
?> ?>
<div style="position:relative; box-sizing: border-box; width:100%; padding:10px; background: #000000; z-index: 10000; overflow: auto;"> <div style="position:relative; box-sizing: border-box; width:100%; padding:10px; background: #000000; z-index: 10000; overflow: auto; margin-bottom: 10px;">
<?php <?php
} }
@@ -115,18 +116,20 @@ class Dumper {
} }
} }
public static function dump(mixed $value, string $name = ""): void { public static function dump(array $value): void {
foreach ($value as $val){
if(in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)){ if(in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)){
var_dump($value); var_dump($val);
} else { } else {
self::initObjhex(); self::initObjhex();
self::generateCSSBlock(); self::generateCSSBlock();
self::generateStartLine(); self::generateStartLine();
self::generateHTMLBlock($value, $name ?? null); self::generateHTMLBlock($val, self::$blockTitle);
self::generateEndLine(); self::generateEndLine();
self::generateJSBlock(); self::generateJSBlock();
} }
} }
}
public static function addShutdownInfo(array $exData = []) : void { public static function addShutdownInfo(array $exData = []) : void {
register_shutdown_function(function() use ($exData) { register_shutdown_function(function() use ($exData) {
@@ -136,13 +139,14 @@ class Dumper {
$info[] = "Выделено памяти в пике: ".round((memory_get_peak_usage()),2)." байт."; $info[] = "Выделено памяти в пике: ".round((memory_get_peak_usage()),2)." байт.";
$exData['info'] = $info; $exData['info'] = $info;
if(error_get_last()) $exData['errors'] = error_get_last(); if(error_get_last()) $exData['errors'] = error_get_last();
self::dump($exData, "Dump info"); self::$blockTitle = "Dump info";
self::dump([$exData]);
}); });
} }
public static function vdd(mixed $exData) : void { public static function vdd(array $value) : void {
register_shutdown_function(function() use ($exData) { register_shutdown_function(function() use ($value) {
self::dump($exData); self::dump($value);
}); });
exit; exit;
} }

View File

@@ -20,7 +20,7 @@ if (!function_exists('vdd')) {
* @param mixed $value * @param mixed $value
* @return void * @return void
*/ */
function vdd(mixed $value): void { function vdd(mixed ...$value): void {
Dumper::vdd($value); Dumper::vdd($value);
} }
} }
@@ -30,7 +30,7 @@ if (!function_exists('vd')) {
* @param mixed $value * @param mixed $value
* @return void * @return void
*/ */
function vd(mixed $value): void { function vd(mixed ...$value): void {
Dumper::dump($value); Dumper::dump($value);
} }
} }