Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VarDumper] Add dd() helper == dump() + exit() #26970

Merged
merged 1 commit into from Apr 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Symfony/Component/VarDumper/Resources/functions/dump.php
Expand Up @@ -30,3 +30,16 @@ function dump($var, ...$moreVars)
return $var;
}
}

if (!function_exists('dd')) {
function dd($var, ...$moreVars)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the name of the function something that could be reconsidered? I get that it's easy to type, but it is not descriptive at all. Something like dumpDie() would only be 5 more keystrokes (assuming no IDE with autocompletion is used), but would be a lot better in showing its intention.

Luckily, it looks like Php Inspections (EA Extended) will recognize this as a debug statement. Still, I think naming functions dd does not fit the Symfony philosophy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only in this case it's imo DX microoptimalization, that is worth it as you may write it thousand times a day...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote for dumpAndExitPhpSession personally. Much more descriptive. Seriously though, this is about developer convenience and happiness. It might not be descriptive at first, but once you know what is it, it makes a lot of sense and you'll save collectively many thousands of unnecessary keystrokes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dumpd()? So it's easy to switch to die or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This should never be committed => so other co-workers could not find it strange or not really descriptive
  2. In order to learn this new feature, you have to read the doc / blog post / this PR.

So basically, the name is not so important. So, IMHO, we should keep it small and simple

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at previous proposals, almost all of them proposed dd(). It feels like a strong indication this is the name we should settle for.

{
VarDumper::dump($var);

foreach ($moreVars as $var) {
VarDumper::dump($var);
}

exit(1);
}
}