Skip to content

Commit 960964b

Browse files
Added Kint as another var_dump tool.
Adds extra functions for Kint: dd() ddd()
1 parent 8942937 commit 960964b

File tree

4 files changed

+129
-10
lines changed

4 files changed

+129
-10
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"php": "^5.6 || ^7",
99
"composer/installers": "^1",
1010
"filp/whoops": "^2.3",
11-
"symfony/var-dumper": "^3.4"
11+
"symfony/var-dumper": "^3.4",
12+
"kint-php/kint": "^3.1"
1213
},
1314
"require-dev": {
1415
"php": "^5.6 || ^7",

composer.lock

Lines changed: 72 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

debug-toolkit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ function _get_plugin_root_dir() {
5555
// Load the files and Composer.
5656
require_once __DIR__ . '/vendor/autoload.php';
5757
require_once __DIR__ . '/src/setup.php';
58-
require_once __DIR__ . '/src/vardumper-functions.php';
58+
require_once __DIR__ . '/src/functions.php';
5959

6060
_setup_plugin();

src/vardumper-functions.php renamed to src/functions.php

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?php
22
/**
3-
* VarDumper Functions - used in your code:
3+
* Kint and VarDumper Functions.
4+
*
5+
* VarDumper functions:
46
* vdump()
57
* vd()
68
* vdd()
79
* vddd()
810
*
9-
* Note: The `v` prefix separates it from the Kint version.
11+
* Note: The `v` prefix separates it from the Kint version.
12+
*
13+
* Kint functions:
14+
* dd()
15+
* ddd()
1016
*
1117
* @package KnowTheCode\DebugToolkit
1218
* @since 1.0.0
@@ -23,7 +29,7 @@
2329

2430
if ( ! function_exists( 'vdump' ) ) {
2531
/**
26-
* Dumps the given variable(s).
32+
* VarDumper: Dumps the given variable(s).
2733
*
2834
* @since 1.0.0
2935
*
@@ -36,14 +42,35 @@ function vdump( $var ) {
3642

3743
if ( ! function_exists( 'vd' ) ) {
3844
/**
39-
* Dumps the given variable(s).
45+
* VarDumper: Dumps the given variable.
4046
*
4147
* @since 1.0.0
4248
*
4349
* @param mixed $var Variable to dump.
4450
*/
4551
function vd( $var ) {
46-
VarDumper_Helpers::dump( $var, __FUNCTION__ );
52+
VarDumper_Helpers::dump( $var );
53+
}
54+
}
55+
56+
if ( ! function_exists( 'dd' ) ) {
57+
/**
58+
* Kint: Dumps the given variable(s) and then ends the execution of the program.
59+
*
60+
* @since 1.0.0
61+
*
62+
* @param mixed $var Variable to dump.
63+
*/
64+
function dd( $var ) {
65+
$vars = func_get_args();
66+
67+
if ( count( $vars ) > 1 ) {
68+
call_user_func_array( [ Kint::class, 'dump' ], $vars );
69+
} else {
70+
Kint::dump( $var );
71+
}
72+
73+
die();
4774
}
4875
}
4976

@@ -60,9 +87,30 @@ function vdd( $var ) {
6087
}
6188
}
6289

90+
if ( ! function_exists( 'ddd' ) ) {
91+
/**
92+
* Kint: Dumps the given variable and then ends the execution of the program.
93+
*
94+
* @since 1.0.0
95+
*
96+
* @param mixed $var Variable to dump.
97+
*/
98+
function ddd( $var ) {
99+
$vars = func_get_args();
100+
101+
if ( count( $vars ) > 1 ) {
102+
call_user_func_array( [ Kint::class, 'dump' ], $vars );
103+
} else {
104+
Kint::dump( $var );
105+
}
106+
107+
die();
108+
}
109+
}
110+
63111
if ( ! function_exists( 'vddd' ) ) {
64112
/**
65-
* Dumps the given variable(s) and then ends the execution of the program.
113+
* VarDumper: Dumps the given variable and then ends the execution of the program.
66114
*
67115
* @since 1.0.0
68116
*

0 commit comments

Comments
 (0)