Re: RFC [Concept] - Interface Properties

From: Date: Sun, 28 May 2023 09:33:13 +0000
Subject: Re: RFC [Concept] - Interface Properties
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-120414@lists.php.net to get a copy of this message
On 28 May 2023 01:09:39 BST, David Gebler <davidgebler@gmail.com> wrote: > >I would say getters and setters don't [as a rule-of-thumb] really belong on >interfaces, since they by definition relate to properties of an object and >properties are by definition an implementation detail. I don't follow. If a property is public, then code outside the class can rely on being able to access it. That seems to me to be a contract between the class and its users, not an implementation detail - e.g. removing the property, or changing its type, would be a compatibility break. A property can also be inherited from a base class, at which point there is a contract that all descendants of that base class will have the property available. So it seems logical that that contract could also be included in an interface. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#120414) next »