You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had this implemented very very early when php-ds was still private, where the structures would echo something similar to JSON. Values that could not be converted to strings had default fallbacks like object(stdClass)#1 and resource(type)#1.
I imagine the above equivalent would echo something like:
{'a': 3, 'b': 2, 'c': 1}
The text was updated successfully, but these errors were encountered:
@nikic to be honest usual semantics of php in this regard is quite inconvenient. Would it be that bad to change it for a more convenient approach by the cost of consistency with the language?
__toString is either an appropriate representation (think PSR-7 response body) or a debug handler. There is no default handler so I'm not even sure what the "usual semantics of PHP" actually are in this context.
Instead of some custom string representation (mentioned above), what about having all structures just convert to their JSON representation, such that echo $structure is equivalent to echo json_encode($structure). That's both an appropriate representation and a debug handler at the same time.
FWIW, structures currently convert to this format: "object(Ds\Map)"
Python example:
I had this implemented very very early when php-ds was still private, where the structures would echo something similar to JSON. Values that could not be converted to strings had default fallbacks like
object(stdClass)#1
andresource(type)#1
.I imagine the above equivalent would echo something like:
The text was updated successfully, but these errors were encountered: