Re: RFC [Concept] - Interface Properties
| From: | Nick Humphries | Date: | Sun, 28 May 2023 07:18:27 +0000 |
| Subject: | Re: RFC [Concept] - Interface Properties | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120411@lists.php.net to get a copy of this message | ||
> Interface properties are already included in the Property Hooks RFC,
> which should be going to a vote soon-ish. We hope it passes, of
> course. :-)
From what I could see, simple interface properties are not going to be
implemented by this RFC (awesome work on the RFC too, it has my full
support!). While I would be happy for it to be expanded and included,
it would increase the risk of the RFC failing. Having interface properties
as a separate RFC might enable a more robust discussion about this the
specific issue.
For context, C# & Swift (via protocols) support interface properties using
a property hook style setup, while Typescript, Kotlin and Dart allow for
public properties to be defined without property hooks.
Languages that prefer duck typing (Python, Ruby, JavaScript) obviously
don't support interfaces at all.
Java and PHP being the odd ones out that support interfaces and don't
have property support.
> Creating the getters leads to enormous amount of boilerplate code.
We are experiencing similar frustrations within our team. Most of the
time we've resorted to using @property annotations to avoid the
boilerplate, however PHPStan has recently started to disallow this on
interfaces.
> I don't want to get into a debate about principles of OOP and design
> practices, this list isn't the place for it. I don't want to sidetrack the
> discussion. I suppose what an interface should conceptually be in PHP is
> necessarily relevant to whether or not one supports this proposal, though..
Agreed, I think the key question for this RFC to progress is "Should an OOP
language interface support public properties".
- Nick