-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.6] Another blade helper @dd() #22293
Conversation
*/ | ||
protected function compileDd($args) | ||
{ | ||
return "<?php dd{$args}; ?>"; |
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.
Would not be it good if we make it like <?php call_user_func_array('dd', $args); ?>
?
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.
Better to have dd(...$args)
actually.
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 because of $args
is a string, that olso contains parentheses symbols.
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.
This is literally making a string containing the dd()
function - not actually running the function.
$args
is a string as passed by blade. So you cant do things like dd(...$args)
or call_user_func_array
etc - because that turns @dd($var1, $var2)
into <?php dd(...($var1, $var)); ?>
. This is how blade directives work. 🤷♂️
It works perfectly as is (I've tested it against live code). This is just a shortcut for the dd()
function and therefore it already runs dd(...$args)
under the hood.
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.
Okay, 👍 Then please make changes in the doc block that $args
param is an array... It will pass an array and compiler will convert it into <?php dd(...$args); ?>
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.
@Modelizer - its not an array. It's a string. That's what Blade passes and generates.
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.
then please make it $arg
it's making me crazy because $args
is always use for an array 😅
The idea is great! ;) |
Thanks, but 👎. I don't see the need for this, the original code you posted there looks fine. |
Going to hold off on this for now. :) |
Eh, it's fine I guess but let's not get carried away 😄 |
it feels like we're getting carried away. I personally am against the |
I'd have to side with @browner12 here. What's the benefit of using Same with |
For me, semantically I think Although For |
Actually the purpose of helpers like ( |
Following on from
@csrf
and@method
blade helpers - the other one I find myself wanting is@dd
.If you've ever had to debug a silly view issue, you might have done
{{ dd($var) }}
in the past to track it down.Now you can just do
@dd($var)
which is much quicker and easier IMO. Can also do@dd($var1, $var2)
etc.