-
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
[11.x] Adds Dumpable
concern
#47122
[11.x] Adds Dumpable
concern
#47122
Conversation
edited: What about a way to customize what gets dumped without having to override the dump method? -public function dump(...$args) {
- dump($this->something, ...$args);
-
- return $this;
-}
+public function toDump() {
+ return $this->something;
+} |
This is my biggest annoyance when dumping models with As for naming, what about |
FYI, this package does just that: https://github.com/glhd/laravel-dumper (I don't know how well it works / is annoying, never used it) |
public function dd(...$args) | ||
{ | ||
$this->dump(...$args); | ||
|
||
dd(); | ||
} |
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.
public function dd(...$args) | |
{ | |
$this->dump(...$args); | |
dd(); | |
} | |
public function dd(...$args) | |
{ | |
dd(...$args); | |
} |
What is... the point? |
@taylorotwell, @nunomaduro looking at how much upvotes the last comment has, it would be great to reconsider it or to have more feedback |
@BafS Well, the methods already existed on all these classes. The PR only cleans up the code base by moving them to a single file instead of having to redefine them on each class. |
That's true but having a trait means opening the door to have many classes implementing it, plugins or libraries using the illuminate "support" (OP wrote "Furthermore, users and package authors have the option to include this concern in their own code easily"). It doesn't bring anything and it's painful to see a famous framework bloating classes with traits, even more when it's debug only. |
@BafS わかりみが深い |
This pull request is currently under development and introduces a fresh
Dumpable
concern (or trait), which replaces the existingdd
anddump
methods in a majority of our classes. Furthermore, users and package authors have the option to include this concern in their own code easily, thereby including these debugging methods in their classes:Please take note that this pull request is specifically aimed at Laravel
11.x
. As it involves modifications to the signature of certain methods. To ensure consistency across the entire code base, the addition of ...$args to these debugging methods was added. For the sake of precaution, I would prefer to target the11.x
version and explicitly mention this in the upgrade guide.