Re: [PHP-DEV] [RFC] Adding a "Stringable" interface to PHP 8

This is only part of a thread. view whole thread
  108467
February 11, 2020 12:10 norbert@aimeos.com (Aimeos | Norbert Sendetzky)
Am 11.02.20 um 12:58 schrieb Nikita Popov:
> Just so someone has mentioned it... is "Stringable" really the best name > for this interface? Reddit really didn't like it ;) Some possible > alternatives: ToString, HasToString, CastsToString.
I would vote for "Stringable" because PHP already has interfaces like Throwable, Countable, Traversable, Serializable and so on :-)
> Something to keep in mind is that there has been a recent proposal for > "Arrayable" as well, and that had very different semantics (not about > __toArray() at all).
I came up with the proposal of an Arrayable interface whose intention is in fact very close to Stringable (can be used like an array and converted to array vs. can be converted to string) But time doesn't seem to be ripe for Arrayable because the __toArray() RFC isn't accepted yet and there needs to be more discussion if Arrayable should only contain __toArray() or if it should extend from Countable and Traversable too.