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

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

« previous php.internals (#108481) next »