Re: [RFC] [Discussion] `#[\Override]` for class constants
| From: | Rowan Tommins [IMSoP] | Date: | Tue, 31 Mar 2026 07:29:12 +0000 |
| Subject: | Re: [RFC] [Discussion] `#[\Override]` for class constants | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130506@lists.php.net to get a copy of this message | ||
On 31 March 2026 00:36:42 BST, Daniel Scherzer <daniel.e.scherzer@gmail.com> wrote:
>Hi internals,
>
>I'd like to start the discussion for a new RFC about adding support for
>
#[\Override] for class constants.
>
>* RFC: https://wiki.php.net/rfc/override_constants
>* Implementation: https://github.com/php/php-src/pull/20478
I will probably abstain on this, because I've never fully understood the rationale for this
attribute, but one point that might be worth spelling out is that by nature constants are static,
which makes it slightly harder to accidentally reference an overridden definition.
"Foo::BAR" and "self::BAR" are both guaranteed to reference the expected
definition; only less common forms like "static::BAR" and "$this::BAR" will look
up on a sub-class.
Rowan Tommins
[IMSoP]