[PHP-DEV] Allow properties to be defined on interface

Hi internals,

With read-only properties, we no longer need to define getter methods when we can take advantage of them.

However, there is still one problem here from a convenience standpoint. That is if we use an interface, we still need to define a getter method.

This was mentioned by @sakurairo in X

Therefore, I propose to allow public properties to be defined on the interface (It does not matter whether it is read-only or not).

I would like to hear your feedback.
Also, if a similar discussion has taken place before, I would appreciate it if you could let me know.

Regards.

Saki

On Thu, Mar 28, 2024, at 3:03 PM, Saki Takamachi wrote:

Hi internals,

With read-only properties, we no longer need to define getter methods
when we can take advantage of them.

However, there is still one problem here from a convenience standpoint.
That is if we use an interface, we still need to define a getter method.

This was mentioned by @sakurairo in X

Therefore, I propose to allow public properties to be defined on the
interface (It does not matter whether it is read-only or not).

I would like to hear your feedback.
Also, if a similar discussion has taken place before, I would
appreciate it if you could let me know.

Regards.

Saki

This functionality is included in the Property Hooks RFC, which will be going to a vote just as soon as Ilija finishes polishing up the test suite for it. (I think he wants to get it into a "commit as soon as the vote passes" state before we call the vote, even though that's not process-required.)

https://wiki.php.net/rfc/property-hooks#interfaces

--Larry Garfield

Le 28 mars 2024 à 16:03, Saki Takamachi <saki@sakiot.com> a écrit :

Therefore, I propose to allow public properties to be defined on the interface (It does not matter whether it is read-only or not).

Hi,

For information, the question of properties on interfaces is covered by the currently discussed RFC “Property hooks”: PHP: rfc:property-hooks

—Claude