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
<https://github.com/php/php-src/compare/master...Zlob:modernize_var_export_function>).
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

Reply via email to