On 18/01/2021 21:12, tyson andre wrote:
Thoughts?
(e.g. for the name, short_var_export() seemed more appropriate than 
var_export_short(), pretty_var_export() or canonical_var_export())


While I agree that all the suggestions in this thread would improve var_export, I worry that it is failing a "smell test" that I often apply:

"If you're struggling to come up with the appropriate name for something that you're creating, maybe you're creating the wrong thing."


In this case, the reason it's difficult to name is that PHP already has rather a lot of different ways to produce a human-readable string from a variable. The synopses in the manual aren't particularly enlightening:

- print_r — Prints human-readable information about a variable
- var_dump — Dumps information about a variable
- var_export — Outputs or returns a parsable string representation of a variable

Then there's the slightly more exotic (and rather less useful than it once was) debug_zval_dump; serialization formats that are reasonably human-friendly like json_encode; and any number of frameworks and userland libraries that define their own "dumper" functions because they weren't satisfied with any of the above.

The name of any new function in this crowded space needs to somehow tell the user why they'd use this one over the others - and, indeed, when they *wouldn't* use it over the others.

Should we be aiming for a single function that can take over from some or all of the others, and deprecate them, rather than just adding to the confusion?


Regards,

--
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to