-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[VarDumper] Add dd() helper == dump() + exit() #26970
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We gave some reasons to not add this function in the past ... but when you receive so many requests from the community to add it, it's time to rethink your decisions. Nicolas, thanks for reconsidering this and for adding the function.
I think there will be a similar number of pros and cons. |
Seeing |
I see no downsides and maintenance isn't an issue 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the potential for harm is very small and the feature has been requested a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Creating a macro in the IDE is part of the doc, not the framework, and not asked as much as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SourceContextProvider must be updated to whitelist dd
as well when looking for the source of the dump. Otherwise, the dump will be reported as coming from inside dd
which is useless.
@kunicmarko20 Not everyone is always developing with an IDE, don't forget the notepad(++), Vim, atom etc developers. Also important to note down, is that the var-dumper can be used as stand-alone. Meaning if devs like the symfony When you're comparing the full feature set of the var-dumper component vs other dumpers, then a dump and die functionality is quite common and desired. It takes a few lines to add the function, but adds a big feeling of completion for the developers that would otherwise have used a I think it's quite nice to have a "full" solution coming from Symfony, making it even better 👍 |
After reading the reasoning behind introducing this function I think it's a good idea in fact and with almost no potential for harm. 👍 |
The feature itself is must have, but not sure about name, confuses a bit. @iltar Can you explain "It's optional"? What if I want |
@nicolas-grekas @DojoGeekRA chrome 65 removed the need for an error code to render the preview that was introduced with 62 https://bugs.chromium.org/p/chromium/issues/detail?id=785050 |
Why not add an optional argument to |
because dump is variadic |
@lyrixx Ah, good point. |
Oh, a enem..., erm, a friend @taylorotwell here? Hey, let's drink coffee? About function, I think that is best to be more verbosity, how
Because |
If people think we need a shortcut then it should be small, |
What a mess of a conversation just for a DX initiative that has been demanded for a long time, and still lots of arguments against. I think this is part of the small changes that can really conciliate lots of dev communities and improve "classic" debug experience as well for people not using complex xdebug setups or full-stack IDEs. I mean, when one debugs using VIM, a simple |
+1 for |
Maybe rename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍿
I don't miss a |
Thank you @nicolas-grekas. |
…s-grekas) This PR was merged into the 4.1-dev branch. Discussion ---------- [VarDumper] Add dd() helper == dump() + exit() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - By popular demand, I feel like we should reconsider our refusal for a `dd()` global helper. For past references, see #26965, #26906, #13657, #17267, #19096. Commits ------- a55916a [VarDumper] Add dd() helper == dump() + die()
Unless they're in command mode 😂 |
Lets be clear, a function/method/class should always have a name that describes it's purpose, it helps the developers and prevents mistakes. dd, a or Foobar are not descriptive (unless you have a Bar named foo Clean Code is about production code and tests, not about simple hacks to find out why something isn't working. Not everyone has the power of a debugger, sometimes the debugger is not able to reach the code (actually happened to me a few time) or doesn't show all details (or the details are to verbose), by using the VarDumper you can easily solve this problem, and having a simple method to dump and prevent further execution is perfectly fine for development and troubleshooting. |
Good job! Thanks @nicolas-grekas |
👍 |
I'm locking the thread because the issue has been resolved. |
By popular demand, I feel like we should reconsider our refusal for a
dd()
global helper.For past references, see #26965, #26906, #13657, #17267, #19096.