>
> Hello!
>
> This is my first RFC proposal. I have an idea about introducing autoconst 
> keyword.
> Motivation:
> reduce duplicated code (copy/pasting constant name as value)
> reducing potential typo errors in constant values
>
> instead of defining constants like:
> const FOO = 'FOO';
>
> they could be defined like:
> autoconst FOO; // defines a constant FOO with the value 'FOO'
>
> Also, modifiers could be useful:
> autoconst uppercase foo; // defines a constant foo with value 'FOO'
> autoconst lowercase FOO; // defines a constant FOO with value 'foo';
>
> and maybe:
> autoconst camelcase FOO_BAR; // defines a constant FOO_BAR with value 'fooBar'
> autoconst snakecase fooBar; // defines a constant fooBar with value 'foo_bar'
>
> could be listed like:
> autoconst FOO, BAR, BAZ;
> autoconst lowercase FOO, BAR, BAZ;
>
> What do you think about that? If you like my idea, I would request a karma 
> for creating this RFC in the wiki. Hope you'll like the idea!

Hi Serhii,
With Enums supported in PHP 8.1, I think this pattern of using
constant names with identical values will see fewer use cases.
I also don't think that a proposal to add new common keywords like
`uppercase` / `snakecase`, or adding any magic to constant names
(because PHP 7 supported case-insensitive constants) will be received
well either.

Thanks,
Ayesh.

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

Reply via email to