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

This is only part of a thread. view whole thread
  108475
February 11, 2020 12:58 guilliam.xavier@gmail.com (Guilliam Xavier)
On Tue, Feb 11, 2020 at 1:12 PM Nicolas Grekas
grekas+php@gmail.com> wrote:
> > > > > 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. > > > > Naming things... > I'm not sure reddit is the way to lobby php-internals... > I proposed Stringable because it is the most consistent to me: > Traversable, Serializable, Countable, Throwable, JsonSerializable > all are related to some special engine behavior, which this ones also is.
But one could argue that "string" is not a verb like "traverse", "serialize", "count", "throw" etc. Potential alternatives would be Stringifyable (or Stringifiable?), StringCastable, StringConvertible... (Even though I personally have no problem with "Stringable") -- Guilliam Xavier
  108477
February 11, 2020 13:11 michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=)
wt., 11 lut 2020 o 13:59 Guilliam Xavier xavier@gmail.com>
napisał(a):

> On Tue, Feb 11, 2020 at 1:12 PM Nicolas Grekas > grekas+php@gmail.com> wrote: > > > > > > > > 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. > > > > > > > Naming things... > > I'm not sure reddit is the way to lobby php-internals... > > I proposed Stringable because it is the most consistent to me: > > Traversable, Serializable, Countable, Throwable, JsonSerializable > > all are related to some special engine behavior, which this ones also is. > > But one could argue that "string" is not a verb like "traverse", > "serialize", "count", "throw" etc. > Potential alternatives would be Stringifyable (or Stringifiable?), > StringCastable, StringConvertible... > (Even though I personally have no problem with "Stringable") > > Maybe StringObject? We do already have ArrayObject.
BR, -- Michał Brzuchalski
  108478
February 11, 2020 13:13 guilliam.xavier@gmail.com (Guilliam Xavier)
On Tue, Feb 11, 2020 at 2:11 PM Michał Brzuchalski
brzuchalski@gmail.com> wrote:
> > wt., 11 lut 2020 o 13:59 Guilliam Xavier xavier@gmail.com> napisał(a): >> >> On Tue, Feb 11, 2020 at 1:12 PM Nicolas Grekas >> grekas+php@gmail.com> wrote: >> > >> > > >> > > 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. >> > > >> > >> > Naming things... >> > I'm not sure reddit is the way to lobby php-internals... >> > I proposed Stringable because it is the most consistent to me: >> > Traversable, Serializable, Countable, Throwable, JsonSerializable >> > all are related to some special engine behavior, which this ones also is. >> >> But one could argue that "string" is not a verb like "traverse", >> "serialize", "count", "throw" etc. >> Potential alternatives would be Stringifyable (or Stringifiable?), >> StringCastable, StringConvertible... >> (Even though I personally have no problem with "Stringable") >> > > Maybe StringObject? We do already have ArrayObject.
But ArrayObject is not a interface (ArrayAccess is). -- Guilliam Xavier
  108481
February 11, 2020 13:20 norbert@aimeos.com (Aimeos | Norbert Sendetzky)
Am 11.02.20 um 14:11 schrieb Michał Brzuchalski:
>>> Traversable, Serializable, Countable, Throwable, JsonSerializable >>> all are related to some special engine behavior, which this ones also is. >> >> But one could argue that "string" is not a verb like "traverse", >> "serialize", "count", "throw" etc. >> Potential alternatives would be Stringifyable (or Stringifiable?), >> StringCastable, StringConvertible... >> (Even though I personally have no problem with "Stringable") >> > Maybe StringObject? We do already have ArrayObject.
A StringObject would need to offer the same methods that are available for strings (even if ArrayObject doesn't do that completely). Even if "string" isn't a verb, it matches the intended meaning: serialize -> Serializeable -> can be serialized count -> Countable -> can be counted throw -> Throwable -> can be thrown If I take the alternatives into account, I would still opt for "Stringable" because it's: - easy to spell - easy to remember - shorter than the alternatives - matches exactly the intended meaning - consistent with the other PHP class nameings
  108482
February 11, 2020 14:13 ben@benramsey.com (Ben Ramsey)
> On Feb 11, 2020, at 07:20, Aimeos | Norbert Sendetzky <norbert@aimeos.com> wrote: > > Am 11.02.20 um 14:11 schrieb Michał Brzuchalski: >>>> Traversable, Serializable, Countable, Throwable, JsonSerializable >>>> all are related to some special engine behavior, which this ones also is. >>> >>> But one could argue that "string" is not a verb like "traverse", >>> "serialize", "count", "throw" etc. >>> Potential alternatives would be Stringifyable (or Stringifiable?), >>> StringCastable, StringConvertible... >>> (Even though I personally have no problem with "Stringable") >>> >> Maybe StringObject? We do already have ArrayObject. > > A StringObject would need to offer the same methods that are available > for strings (even if ArrayObject doesn't do that completely). > > Even if "string" isn't a verb, it matches the intended meaning: > serialize -> Serializeable -> can be serialized > count -> Countable -> can be counted > throw -> Throwable -> can be thrown > > If I take the alternatives into account, I would still opt for > "Stringable" because it's: > - easy to spell > - easy to remember > - shorter than the alternatives > - matches exactly the intended meaning > - consistent with the other PHP class nameings
In English, pretty much any noun can be used as a verb. Also, string does have a verb form. It can mean “to thread on or as if on a string” or “to put together (words, ideas, etc.) like objects threaded on a string” or “to form into strings.” In computing, a string is a series of characters that have been strung together. https://www.merriam-webster.com/dictionary/string :-) Cheers, Ben