Enhancement: Allow dd() to accept multiple variables · Issue #19399 · cakephp/cakephp · GitHub
Skip to content

Enhancement: Allow dd() to accept multiple variables #19399

@vishal2931

Description

@vishal2931

Description

Feature Request

It would be useful if dd() accepted multiple variables in a single call:

dd($users, $posts, $request);                                                                                                                                              
                                                          
Currently you have to chain multiple debug() calls and then manually die:                                                                                                  
                                                                                                                                                                           
debug($users);                                                                                                                                                             
debug($posts);                                                                                                                                                             
dd($request);                                             

Problem

The challenge is that the current signature is:

function dd(mixed $var, ?bool $showHtml = null): void

PHP requires the variadic parameter to be last, so moving to mixed ...$vars would require removing $showHtml. Options to consider:

  1. Remove $showHtml : it defaults to null. This is a breaking change.
  2. Move $showHtml first : dd(?bool $showHtml = null, mixed ...$vars), also a breaking change for existing dd($var, true/false) callers.

Looking for feedback on the preferred approach before submitting a PR.

CakePHP Version

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions