On Fri, Nov 4, 2022, at 9:45 AM, Ralf Lang wrote:
> Hi Ilija,
>
> Am 04.11.2022 um 15:25 schrieb Ilija Tovilo:
>> Please let me know if you have any thoughts.
>>
>> Ilija
>
> That new way of accessing class constants dynamically does not really 
> make things more readable for me. Maybe I just need to get used to it, 
> but especially that last example would make my head spin without 
> additional comments:
>
> Foo::{test('foo')}::{test('bar')}; Maybe I miss the use case. What kind 
> of code would benefit 
> from this? Wouldn't just using constant() for dynamically built 
> constant 
> strings be more legible? Maybe in a separate line? In the past I used a 
> lot of flag constants backed by integers. A lot of these use cases have 
> become classes/types in their own right since. When do you use these 
> constants? Just my thoughts.

Dynamically building strings for syntax is almost never more legible. :-)  I 
doubt you'd ever double them up the way some of the examples show.

In practice, the single Class::{$const} or Enum::{$name} would be the most 
common uses, I predict, and those are way nicer to read than the 3x longer 
constant() with string concat.

--Larry Garfield

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

Reply via email to