[9.x] Register cutInternals
casters for particularly noisy objects
#44514
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a much smaller version of #44408 that addresses the major pain point of using
dd()
in Laravel—dumping an object that holds a reference to the container (or another potentially large object that you don't actually care about from a debugging context).By default, Symfony registers the
StubCaster::cutInternals
caster for many internal classes, including the Symfony container and event dispatcher. This caster cuts down the object when dumping, but only if it's nested. This PR registers that same caster for a couple of Laravel interfaces that tend to be very large.For example, currently if you were to call
dd()
on an instance of theRouter
, your output will include include about 500 lines showing theDispatcher
and another 500 lines showing theContainer
before you get anywhere near the$routes
or other values that you're likely trying to view.After this PR, those 1000 lines are collapsed to:
The
cutInternals
caster only applies if the object is nested, though. So if you calldd()
directly on the container or event dispatcher, the entire object will be dumped.This feels like 70% of the benefits of Laravel Dumper for about 1% of the maintenance cost.