Re: [RFC] Adding a "Stringable" interface to PHP 8
| From: | Aimeos | Norbert Sendetzky | Date: | Tue, 11 Feb 2020 12:10:14 +0000 |
| Subject: | Re: [RFC] Adding a "Stringable" interface to PHP 8 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108467@lists.php.net to get a copy of this message | ||
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.