> 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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to