diff --git a/src/Illuminate/Collections/Enumerable.php b/src/Illuminate/Collections/Enumerable.php index a561488e8a59..0ed485161098 100644 --- a/src/Illuminate/Collections/Enumerable.php +++ b/src/Illuminate/Collections/Enumerable.php @@ -184,9 +184,10 @@ public function dd(...$args); /** * Dump the collection. * + * @param mixed ...$args * @return $this */ - public function dump(); + public function dump(...$args); /** * Get the items that are not present in the given items. diff --git a/src/Illuminate/Collections/Traits/EnumeratesValues.php b/src/Illuminate/Collections/Traits/EnumeratesValues.php index f9614963ae36..4c9439d85eab 100644 --- a/src/Illuminate/Collections/Traits/EnumeratesValues.php +++ b/src/Illuminate/Collections/Traits/EnumeratesValues.php @@ -12,7 +12,6 @@ use Illuminate\Support\Enumerable; use Illuminate\Support\HigherOrderCollectionProxy; use JsonSerializable; -use Symfony\Component\VarDumper\VarDumper; use Traversable; use UnexpectedValueException; use UnitEnum; @@ -53,7 +52,7 @@ */ trait EnumeratesValues { - use Conditionable; + use Conditionable, Dumpable; /** * Indicates that the object's string representation should be escaped when __toString is invoked. @@ -195,31 +194,15 @@ public function some($key, $operator = null, $value = null) return $this->contains(...func_get_args()); } - /** - * Dump the items and end the script. - * - * @param mixed ...$args - * @return never - */ - public function dd(...$args) - { - $this->dump(...$args); - - exit(1); - } - /** * Dump the items. * + * @param mixed ...$args * @return $this */ - public function dump() + public function dump(...$args) { - (new Collection(func_get_args())) - ->push($this->all()) - ->each(function ($item) { - VarDumper::dump($item); - }); + dump($this->all(), ...$args); return $this; } diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 0b6c87ac8d9f..749a480eba49 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -21,6 +21,7 @@ use Illuminate\Support\Collection; use Illuminate\Support\LazyCollection; use Illuminate\Support\Str; +use Illuminate\Support\Traits\Dumpable; use Illuminate\Support\Traits\ForwardsCalls; use Illuminate\Support\Traits\Macroable; use InvalidArgumentException; @@ -29,7 +30,7 @@ class Builder implements BuilderContract { - use BuildsQueries, ExplainsQueries, ForwardsCalls, Macroable { + use BuildsQueries, Dumpable, ExplainsQueries, ForwardsCalls, Macroable { __call as macroCall; } @@ -3871,25 +3872,20 @@ public function cloneWithoutBindings(array $except) /** * Dump the current SQL and bindings. * + * @param mixed ...$args * @return $this */ - public function dump() + public function dump(...$args) { - dump($this->toSql(), $this->getBindings()); + dump( + $this->toSql(), + $this->getBindings(), + ...$args, + ); return $this; } - /** - * Die and dump the current SQL and bindings. - * - * @return never - */ - public function dd() - { - dd($this->toSql(), $this->getBindings()); - } - /** * Handle dynamic method calls into the method. * diff --git a/src/Illuminate/Http/Concerns/InteractsWithInput.php b/src/Illuminate/Http/Concerns/InteractsWithInput.php index 36dcec2fef4f..20150719db3d 100644 --- a/src/Illuminate/Http/Concerns/InteractsWithInput.php +++ b/src/Illuminate/Http/Concerns/InteractsWithInput.php @@ -5,13 +5,15 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Date; +use Illuminate\Support\Traits\Dumpable; use SplFileInfo; use stdClass; use Symfony\Component\HttpFoundation\InputBag; -use Symfony\Component\VarDumper\VarDumper; trait InteractsWithInput { + use Dumpable; + /** * Retrieve a server variable from the request. * @@ -606,19 +608,6 @@ protected function retrieveItem($source, $key, $default) return $this->$source->get($key, $default); } - /** - * Dump the request items and end the script. - * - * @param mixed ...$keys - * @return never - */ - public function dd(...$keys) - { - $this->dump(...$keys); - - exit(1); - } - /** * Dump the items. * @@ -629,7 +618,7 @@ public function dump($keys = []) { $keys = is_array($keys) ? $keys : func_get_args(); - VarDumper::dump(count($keys) > 0 ? $this->only($keys) : $this->all()); + dump(count($keys) > 0 ? $this->only($keys) : $this->all()); return $this; } diff --git a/src/Illuminate/Support/Carbon.php b/src/Illuminate/Support/Carbon.php index c1a665c7d0f8..1dcbae319b77 100644 --- a/src/Illuminate/Support/Carbon.php +++ b/src/Illuminate/Support/Carbon.php @@ -5,12 +5,13 @@ use Carbon\Carbon as BaseCarbon; use Carbon\CarbonImmutable as BaseCarbonImmutable; use Illuminate\Support\Traits\Conditionable; +use Illuminate\Support\Traits\Dumpable; use Ramsey\Uuid\Uuid; use Symfony\Component\Uid\Ulid; class Carbon extends BaseCarbon { - use Conditionable; + use Conditionable, Dumpable; /** * {@inheritdoc} @@ -33,27 +34,4 @@ public static function createFromId($id) ? static::createFromInterface(Ulid::fromString($id)->getDateTime()) : static::createFromInterface(Uuid::fromString($id)->getDateTime()); } - - /** - * Dump the instance and end the script. - * - * @param mixed ...$args - * @return never - */ - public function dd(...$args) - { - dd($this, ...$args); - } - - /** - * Dump the instance. - * - * @return $this - */ - public function dump() - { - dump($this); - - return $this; - } } diff --git a/src/Illuminate/Support/Stringable.php b/src/Illuminate/Support/Stringable.php index 0cb76068e396..b2053151bf89 100644 --- a/src/Illuminate/Support/Stringable.php +++ b/src/Illuminate/Support/Stringable.php @@ -6,14 +6,14 @@ use Closure; use Illuminate\Support\Facades\Date; use Illuminate\Support\Traits\Conditionable; +use Illuminate\Support\Traits\Dumpable; use Illuminate\Support\Traits\Macroable; use Illuminate\Support\Traits\Tappable; use JsonSerializable; -use Symfony\Component\VarDumper\VarDumper; class Stringable implements JsonSerializable, ArrayAccess { - use Conditionable, Macroable, Tappable; + use Conditionable, Dumpable, Macroable, Tappable; /** * The underlying string value. @@ -1128,27 +1128,16 @@ public function toHtmlString() /** * Dump the string. * + * @param mixed ...$args * @return $this */ - public function dump() + public function dump(...$args) { - VarDumper::dump($this->value); + dump($this->value, ...$args); return $this; } - /** - * Dump the string and end the script. - * - * @return never - */ - public function dd() - { - $this->dump(); - - exit(1); - } - /** * Get the underlying string value. * diff --git a/src/Illuminate/Support/Traits/Dumpable.php b/src/Illuminate/Support/Traits/Dumpable.php new file mode 100644 index 000000000000..448b5ba62c17 --- /dev/null +++ b/src/Illuminate/Support/Traits/Dumpable.php @@ -0,0 +1,32 @@ +dump(...$args); + + dd(); + } + + /** + * Dump the given arguments. + * + * @param mixed ...$args + * @return $this + */ + public function dump(...$args) + { + dump($this, ...$args); + + return $this; + } +} diff --git a/src/Illuminate/Testing/Fluent/Concerns/Debugging.php b/src/Illuminate/Testing/Fluent/Concerns/Debugging.php index e655556cf939..98726fbbdbbd 100644 --- a/src/Illuminate/Testing/Fluent/Concerns/Debugging.php +++ b/src/Illuminate/Testing/Fluent/Concerns/Debugging.php @@ -2,8 +2,12 @@ namespace Illuminate\Testing\Fluent\Concerns; +use Illuminate\Support\Traits\Dumpable; + trait Debugging { + use Dumpable; + /** * Dumps the given props. * @@ -17,17 +21,6 @@ public function dump(string $prop = null): self return $this; } - /** - * Dumps the given props and exits. - * - * @param string|null $prop - * @return never - */ - public function dd(string $prop = null): void - { - dd($this->prop($prop)); - } - /** * Retrieve a prop within the current scope using "dot" notation. * diff --git a/src/Illuminate/Testing/TestResponse.php b/src/Illuminate/Testing/TestResponse.php index 3fa40418d61a..4146ea4bff71 100644 --- a/src/Illuminate/Testing/TestResponse.php +++ b/src/Illuminate/Testing/TestResponse.php @@ -15,6 +15,7 @@ use Illuminate\Support\Carbon; use Illuminate\Support\Collection; use Illuminate\Support\Str; +use Illuminate\Support\Traits\Dumpable; use Illuminate\Support\Traits\Macroable; use Illuminate\Support\Traits\Tappable; use Illuminate\Support\ViewErrorBag; @@ -32,7 +33,7 @@ */ class TestResponse implements ArrayAccess { - use Concerns\AssertsStatusCodes, Tappable, Macroable { + use Concerns\AssertsStatusCodes, Dumpable, Tappable, Macroable { __call as macroCall; } @@ -1423,18 +1424,6 @@ protected function session() return $session; } - /** - * Dump the content from the response and end the script. - * - * @return never - */ - public function dd() - { - $this->dump(); - - exit(1); - } - /** * Dump the headers from the response and end the script. *