-
Notifications
You must be signed in to change notification settings - Fork 314
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
How to make the dumper produce guaranteed-valid PHP strings? #568
Comments
The dumper doesn't produce valid anything, and isn't really meant to :) It has "object literals", which definitely aren't valid PHP. It folds nested properties and array values into It's meant to show you what something is in a way that's easy to understand. You should think of it as analogous to |
So perhaps there could be a config option to have |
There is a It would be pretty easy to make it work even when using PsySH interactively. Unfortunately, it's also pretty easy to make it explode. Returning a moderately complex object makes a mess of everything. For example, if the return value is a PsySH Configuration object, it spits out 200 warnings about circular references, and 60,000+ lines of worthless PHP code. And since PsySH is a REPL, even when you don't want to dump return values, you often end up doing it 😕 |
Given the problems mentioned, I'm not super comfortable handing people a footgun like that. It might be that we could special case strings, specifically, to have valid output rather than pretty output. cc @nicolas-grekas, who is a good person to ask! |
I think it's
CliDumper::dumpString()
which is responsible for the likes of these?Neither of those outputs are valid PHP strings, and I would like them to be.
e.g.
That
dumpString()
method itself seems pretty hard-coded in this respect, and I couldn't see anything in the manual other than thecasters
pointer; but based on the upstream description I'm not sure that's actually relevant to simple string values?It looks like a bit of a rabbit hole, so I thought I'd ask for directions...
The text was updated successfully, but these errors were encountered: