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'd also like to draw specific attention to the open question, which I am
soliciting feedback on: how should #[\Override] work for enum cases? See
the RFC page for details.
Thanks,
-Daniel
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]
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'd also like to draw specific attention to the open question, which I am
soliciting feedback on: how should#[\Override]work for enum cases? See
the RFC page for details.
I think I'm on the " Always reject using #[\Override] on an enum case,
saying that the attribute does not target enum cases" side here, as
mixing class constants with enum cases sounds like a mismatch to me.
cheers,
Derick
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'd also like to draw specific attention to the open question, which I am soliciting feedback on: how should
#[\Override]work for enum cases? See the RFC page for details.
It's impossible to override an enum case. Enums are final and cannot be extended. So just error if someone tries to use #[\Override] on an enum case as it is non-sensical.
Best regards,
Gina P. Banyard