Skip to content

Commit e435897

Browse files
authored
6.x: adjust dd() to be variadic (#19445)
adjust dd() to be variadic
1 parent 75fb882 commit e435897

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/Error/functions.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,11 @@ function stackTrace(array $options = []): void
8787
* Only runs if debug mode is enabled.
8888
* It will otherwise just continue code execution and ignore this function.
8989
*
90-
* @param mixed $var Variable to show debug information for.
91-
* @param bool|null $showHtml If set to true, the method prints the debug data in a browser-friendly way.
90+
* @param mixed ...$vars Variables to show debug information for.
9291
* @return void
9392
* @link https://book.cakephp.org/5/en/development/debugging.html#basic-debugging
9493
*/
95-
function dd(mixed $var, ?bool $showHtml = null): void
94+
function dd(mixed ...$vars): void
9695
{
9796
if (!Configure::read('debug')) {
9897
return;
@@ -104,7 +103,9 @@ function dd(mixed $var, ?bool $showHtml = null): void
104103
'file' => $trace[0]['file'],
105104
];
106105

107-
Debugger::printVar($var, $location, $showHtml);
106+
foreach ($vars as $var) {
107+
Debugger::printVar($var, $location);
108+
}
108109
die(1);
109110
}
110111

src/Error/functions_global.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,11 @@ function stackTrace(array $options = []): void
9090
* Only runs if debug mode is enabled.
9191
* It will otherwise just continue code execution and ignore this function.
9292
*
93-
* @param mixed $var Variable to show debug information for.
94-
* @param bool|null $showHtml If set to true, the method prints the debug data in a browser-friendly way.
93+
* @param mixed ...$vars Variables to show debug information for.
9594
* @return void
9695
* @link https://book.cakephp.org/5/en/development/debugging.html#basic-debugging
9796
*/
98-
function dd(mixed $var, ?bool $showHtml = null): void
97+
function dd(mixed ...$vars): void
9998
{
10099
if (!Configure::read('debug')) {
101100
return;
@@ -107,7 +106,9 @@ function dd(mixed $var, ?bool $showHtml = null): void
107106
'file' => $trace[0]['file'],
108107
];
109108

110-
Debugger::printVar($var, $location, $showHtml);
109+
foreach ($vars as $var) {
110+
Debugger::printVar($var, $location);
111+
}
111112
die(1);
112113
}
113114
}

0 commit comments

Comments
 (0)