On Thu, Dec 5, 2024, at 5:16 PM, Christoph M. Becker wrote: > On 05.12.2024 at 22:49, Máté Kocsis wrote: > >>> I'm not sure I like the `Interface` suffix on the `UriInterface` >>> interface. Just `Uri\Uri` would be equally expressive. >> >> Yes, I was expecting this debate :) To be honest, I never liked interfaces >> without an "Interface" >> suffix, and my dislike didn't go away when I had to use such an interface >> somewhere, because it >> was difficult for me to find out what the symbol I was typing actually >> referred to. > > By the same argument, you could come up with code like > > <?php > class User { > const defaultGroupNameConstant = "users"; > private string $nameVariable; > public function getNameMethod() {…} > … > } > ?> > >> But apart from my personal >> experiences, I prefer to stay with "UriInterface" because the 2 most well >> known internal PHP interfaces >> also have the same suffix (DateTimeInterface, SessionInterface), and this >> name definitely conveys that >> people should not try to instantiate it. > > DateTimeInterface has been introduced after there had already been > DateTime. Otherwise, we would likely have DateTime, DateTimeMutable and > DateTimeImmutable. (Or only DateTime as immutable class.) > > SessionHandler/SessionHandlerInterface have been bad naming choices, in > my opinion. The interface could have been SessionHandler, and the class > DefaultSessionHandler (and should have been final). I dislike these > Interface and Implementation (or abbreviations of these) suffixes. > > Christoph
I used to be in favor of *Interface, but over time realized how useless it was. :-) I have stopped doing it in my own code and my code reads way better. Also, the majority of PHP's built in interfaces (Traversable, Countable, etc.) are not suffixed, AFAIK, so it's better to avoid it for consistency. As noted, DateTimeInterface is a special case outlier. --Larry Garfield