On Wed, Aug 19, 2026, at 5:35 AM, Eloi Montanes wrote:
> Given that this RFC proposal would add support for class constant
> declaration, I don't see a problem on adding constants to interfaces.
> In this case, class constant declaration would look something like:
> ```PHP
> interface I {
> public const string CONSTANT_NAME;
> ...
> }
>
> abstract class C {
> abstract public const string CONSTANT_NAME;
> ...
> }
>
> trait T {
> abstract public const string CONSTANT_NAME;
> ...
> }
> ```
Note that interfaces already support defined constants on them, so if you want
to support abstract constants you may need an `abstract` keyword anyway.
Depends on what the parser will let you do.
> What I do find rather curious is that interfaces don't already have any
> support for static properties. Is there a reason for this?
> If no one opposes, I'll be include support for class constant
> declaration in interfaces to the RFC.
We thought about it when building interface property support as part of
property hooks. We didn't do it for two main reasons.
1. The use cases are pretty slim, as you ought to be using object properties
95% of the time. In the rare case that you are using a static property as a
metadata declaration mechanism, we already have attributes which are more
powerful anyway.
2. Static properties are way harder to deal with in the engine, because
reasons, and we didn't want to spend the effort on something so niche.
Even if you're OK with #1, you'll still run into #2, I imagine. (I don't
recall details, but Ilija may.)
--Larry Garfield