Re: [PHP-DEV] RFC: var_export - short syntax for array

2019-08-21 Thread Влад Макин
Thanks for the feedback!  I will back with improved version of RFC.

вт, 20 авг. 2019 г., 23:01 Sara Golemon :

> On Tue, Aug 20, 2019 at 1:05 PM Влад Макин  wrote:
>
>> I would like to propose a little change in var_export function behavior.
>> For today, this function returns string representation of array in old
>> style with “array” keyword:
>>
>> var_export([]); // array()
>>
>> I think it would be better if the function returned array representation
>> in
>> modern square brackets syntax:
>>
>> var_export([]); // []
>>
>> I do like the idea of doing this, and would even be generally okay with
> just making always work that way since the introduction of square bracket
> syntax is really *quite* old.
>
> The only people I could see being bothered by the change in output would
> be automated code-generation suddenly seeing a (potentially quite massive)
> diff as the bracket style changes.  As an example,
> https://github.com/php/web-php/blob/master/include/releases.inc is a 10k
> line var_export() generated list.  I'm actually /not/ bothered by the idea
> of having a big point-in-time flip of that structure, though I'd want to
> make sure all RMs switch versions at the same time, otherwise it could get
> noisy.
>
> Perhaps an option to quell any dissent might be to add a third param
> $options to allow controlling this behavior.
>
> function var_export(mixed $data, bool $return = false, int $options = 0):
> string {}
>
> And you could either pass EXPORT_SHORT_ARRAY or EXPORT_LONG_ARRAY or
> whatever you want to call the constants depending on which behavior you'd
> make default (and honestly, I think we'd make the existing format default).
>
> -Sara
>


[PHP-DEV] RFC: var_export - short syntax for array

2019-08-20 Thread Влад Макин
Hello!

I would like to propose a little change in var_export function behavior.
For today, this function returns string representation of array in old
style with “array” keyword:

var_export([]); // array()

I think it would be better if the function returned array representation in
modern square brackets syntax:

var_export([]); // []

I think now is good time for this change because short syntax is common and
used by almost all linters as well as in examples in code standards like
PSR-2 and PSR-12.

Also this change will make it easier in the future to remove old long
syntax from PHP.

I have already implemented the concept of this feature localy (here is the
diif
).
As you can see, it does not affect a lot of the code.


This change does not break backward compability, becuse it steel returns
valid PHP array. But if it needed, this behaviour can be managed by an
additional optional function parametr.


Looking forward for your comments and suggestions

Sincerely,
Vladislav Makin