Re: [RFC][DISCUSSION] Change var_export() array syntax touse short hand arrays
| From: | Guilliam Xavier | Date: | Wed, 08 Apr 2020 13:46:44 +0000 |
| Subject: | Re: [RFC][DISCUSSION] Change var_export() array syntax touse short hand arrays | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109569@lists.php.net to get a copy of this message | ||
On Wed, Apr 8, 2020 at 3:12 PM Sherif Ramadan <theanomaly.is@gmail.com> wrote:
>
> So to recap on what's been discussed so far, because I plan to bring this
> to a vote next week...
>
> I am updating the RFC to reflect that the change will no longer break
> backwards compatibility. I will be adding an flags argument with the
> following 3 optional bitwise flags for var_export:
>
> - VAR_EXPORT_SHORT_ARRAY [Triggers short-array syntax]
> - VAR_EXPORT_NO_INDEX [Discards numbered indexes in arrays (only if they
> are sequential from 0)]
> - VAR_EXPORT_NO_WHITESPACE [For one-liners]
>
> This complicates the implementation slightly, but I think it brings a
> greater net-benefit.
Hello,
First, thank you for proposing this RFC. I have no strong opinion
either way, but anyway it cannot work as is, because var_export
already has a second optional parameter (bool $return = false). You
could add the flags as a third optional parameter (int $options = 0),
or maybe make it replace (extend) the existing one and add an extra
constant, say VAR_EXPORT_RETURN = 1, so that it can be combined
(although I'm not sure that changing the type from bool to int (or
maybe bool|int) would be BC-compliant...)
Moreover the RFC currently says that var_export([1, 2, 3]) produces
```
array(1, 2, 3)
```
but it actually produces
```
array (
0 => 1,
1 => 2,
2 => 3,
)
```
Regards,
--
Guilliam Xavier