Re: [PHP-DEV] RFC: autoconst

2021-08-02 Thread Pierre
Le 01/08/2021 à 17:59, Serhii Smirnov a écrit I was more interested in autoconst keyword that reduces copy/pasting constant name as it's value. camelcase and snakecase is an addition. A real example why I wanted to use autoconst: on the past project, we had class that holds constants with the

Re: [PHP-DEV] RFC: autoconst

2021-08-01 Thread Serhii Smirnov
Thank you! Seems like Enum covers this case. вс, 1 авг. 2021 г., 21:58 Rowan Tommins : > On 01/08/2021 16:59, Serhii Smirnov wrote: > > class Features > > { > > const FEATURE_FLAG_WITH_SOME_LONG_NAME = > > 'feature_flag_with_some_long_name'; > > const FEATURE_SOME_ANOTHER_COOL_FEATURE = >

Re: [PHP-DEV] RFC: autoconst

2021-08-01 Thread Rowan Tommins
On 01/08/2021 16:59, Serhii Smirnov wrote: class Features {     const FEATURE_FLAG_WITH_SOME_LONG_NAME = 'feature_flag_with_some_long_name';     const FEATURE_SOME_ANOTHER_COOL_FEATURE = 'feature_some_another_cool_feature'; } That looks like it falls into my first category: the actual value

Re: [PHP-DEV] RFC: autoconst

2021-08-01 Thread Serhii Smirnov
> 1 авг. 2021 г., в 17:08, Rowan Tommins написал(а): > > On 01/08/2021 12:21, Serhii Smirnov wrote: >> instead of defining constants like: >> const FOO = 'FOO'; >> >> they could be defined like: >> autoconst FOO; // defines a constant FOO with the value 'FOO' > > > While I've certainly seen

Re: [PHP-DEV] RFC: autoconst

2021-08-01 Thread Rowan Tommins
On 01/08/2021 12:21, Serhii Smirnov wrote: instead of defining constants like: const FOO = 'FOO'; they could be defined like: autoconst FOO; // defines a constant FOO with the value 'FOO' While I've certainly seen constants like this in the past, I think they mostly fall into two categories:

Re: [PHP-DEV] RFC: autoconst

2021-08-01 Thread Serhii Smirnov
I am surprised that you called this proposal makes code less readable. Which code is more readable: const SOME_LONG_NAMED_CONSTATN_FROM_ENVIRONMENT = 'SOME_LONG_NAMED_COSNTATN_FROM_ENVIRONMENT'; or autoconst SOME_LONG_NAMED_CONSTATN_FROM_ENVIRONMENT; ? Also, could you see a typo error in the c

Re: [PHP-DEV] RFC: autoconst

2021-08-01 Thread Max Semenik
вс, 1 авг. 2021 г., 14:22 Serhii Smirnov : > instead of defining constants like: > const FOO = 'FOO'; > > they could be defined like: > autoconst FOO; // defines a constant FOO with the value 'FOO' Sorry, but I'm not a fan of this proposal. Features should not be aiming at minor savings of keyst

Re: [PHP-DEV] RFC: autoconst

2021-08-01 Thread Ayesh Karunaratne
> > 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

[PHP-DEV] RFC: autoconst

2021-08-01 Thread Serhii Smirnov
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: