> Le 21 juin 2022 à 23:33, shinji igarashi <s...@sj-i.dev> a écrit :
> 
> Hello everyone!
> 
> I'd like to start a discussion on an RFC to allow defining constants in 
> traits.
> https://wiki.php.net/rfc/constants_in_traits
> 
> I'm looking forward to your feedback, including corrections on English 
> wordings.
> 
> Thanks!
> 
> --
> Shinji Igarashi
> 


Hi,

Some time ago, I migrated part of some class implementation into a trait, and I 
was surprised that it resulted in a syntax error, because constants were not 
supported in traits. In my case, I could trivially resolve the issue by 
morphing the (private) constant into a static property (semantically less 
correct, but pragmatically simpler); but I was feeling that it is yet one more 
inconsistency of PHP: Why on earth are static properties supported, but not 
constants?

So, this is a welcome addition (or, rather, a welcome correction of an 
oversight).

—Claude

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to