Alex,

On Tue, Mar 29, 2022 at 10:35 PM Alexandru Pătrănescu <dreal...@gmail.com>
wrote:

> Hey Mark,
>
>
> On Wed, Mar 30, 2022 at 6:03 AM Mark Niebergall <mbnieberg...@gmail.com>
> wrote:
>
>>
>> I have updated the RFC https://wiki.php.net/rfc/typed_class_constants
>> with
>> more details and examples from this thread, and updated the RFC status to
>> Under Discussion. Hopefully the updated RFC helps answer questions and
>> clarifies what the proposal includes.
>>
>
> Thanks for the RFC and the drive here.
> I personally see the benefit and I think it would be a nice addition.
>
> I think you should also update the "Supported types" section.
> Starting with enums, constants can also be objects. Once a good technical
> solution is found, any object would be supported probably
> https://wiki.php.net/rfc/new_in_initializers#future_scope
> I think that only void, never and callable types should not be supported,
> just like on properties.
>
>
I have updated the "Supported types" to list out all types that are
supported and which types are not supported.

Constants cannot be objects since objects are mutable, so typed constants
will not be allowed to be an enum (which is technically an object). A typed
constant _may_ be an enum value though, so the following example will be
valid:

```
enum Fruit
{
    case Apple;
    case Banana;
}

class Colors
{
    protected const string RED = Fruit::Apple;
    protected const string YELLOW = Fruit::Banana;
}
```


>
>> Of note is the "Inheritance and variance" section, which details uses with
>> abstracts and interfaces, plus the "Constant values" section which
>> includes
>> details about errors.
>>
>>
>> >
>> > --
>> > Guilliam Xavier
>> >
>>
>
> Thanks,
> Alex
>

Reply via email to