rfc:var-export-array-syntax
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:var-export-array-syntax [2020/03/30 02:52] – googleguy | rfc:var-export-array-syntax [2020/04/10 09:24] (current) – typos, examples guilliamxavier | ||
---|---|---|---|
Line 12: | Line 12: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | Instead of | + | This change proposes adding a third optional argument for '' |
- | <code php> | + | - VAR_EXPORT_SHORT_ARRAY |
+ | - VAR_EXPORT_NO_INDEX | ||
+ | - VAR_EXPORT_COMPACT | ||
- | '' | + | '' |
- | <code php>[1, 2, 3]</ | + | Each option can be used alone, and can also be combined with other(s). |
- | This will effect things like '' | ||
- | So the following changes | + | For example, < |
+ | |||
+ | <code php> | ||
+ | array ( | ||
+ | 0 => 1, | ||
+ | 1 => 2, | ||
+ | 2 => 3, | ||
+ | ) | ||
+ | </ | ||
+ | |||
+ | and the new < | ||
+ | |||
+ | <code php> | ||
+ | [ | ||
+ | 0 => 1, | ||
+ | 1 => 2, | ||
+ | 2 => 3, | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | This would affect '' | ||
+ | |||
+ | So the following changes | ||
<code php> | <code php> | ||
Line 30: | Line 53: | ||
var_export($obj); | var_export($obj); | ||
- | |||
/* | /* | ||
- | Gives us: | ||
(object) array( | (object) array( | ||
' | ' | ||
' | ' | ||
) | ) | ||
+ | */ | ||
- | With the new change it would be | + | var_export($obj, |
+ | /* | ||
(object) [ | (object) [ | ||
' | ' | ||
Line 47: | Line 69: | ||
</ | </ | ||
- | The same happens | + | Same for other classes: |
<code php> | <code php> | ||
Line 55: | Line 77: | ||
var_export(new Foo); | var_export(new Foo); | ||
- | |||
/* | /* | ||
- | Gives us: | ||
Foo:: | Foo:: | ||
' | ' | ||
)) | )) | ||
+ | */ | ||
- | With the changes it would be: | + | var_export(new Foo, false, VAR_EXPORT_SHORT_ARRAY); |
+ | /* | ||
Foo:: | Foo:: | ||
' | ' | ||
]) | ]) | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | Using the other bitwise flags you could also do things like... | ||
+ | |||
+ | <code php> | ||
+ | var_export([1, | ||
+ | /* | ||
+ | array ( | ||
+ | 1, | ||
+ | 2, | ||
+ | 3, | ||
+ | ) | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | /* | ||
+ | array (0 => 1, 1 => 2, 2 => 3) | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | and combine them... | ||
+ | |||
+ | <code php> | ||
+ | var_export([1, | ||
+ | /* | ||
+ | [ | ||
+ | 1, | ||
+ | 2, | ||
+ | 3, | ||
+ | ] | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | /* | ||
+ | [0 => 1, 1 => 2, 2 => 3] | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | /* | ||
+ | array (1, 2, 3) | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | /* | ||
+ | [1, 2, 3] | ||
*/ | */ | ||
</ | </ | ||
Line 94: | Line 162: | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | The change only requires changing two lines in '' | + | The change only requires changing two lines in '' |
+ | |||
+ | See https:// | ||
===== Implementation ===== | ===== Implementation ===== | ||
Line 100: | Line 170: | ||
===== References ===== | ===== References ===== | ||
https:// | https:// | ||
+ | |||
https:// | https:// | ||
+ | |||
+ | https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
rfc/var-export-array-syntax.1585536728.txt.gz · Last modified: 2020/03/30 02:52 by googleguy