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 16:02] – 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:: | ||
' | ' | ||
Line 69: | Line 91: | ||
</ | </ | ||
- | ===== Backward Incompatible Changes ===== | + | Using the other bitwise flags you could also do things like... |
- | There shouldn' | + | |
- | However, there are some tests that test the output of '' | + | <code php> |
+ | var_export([1, 2, 3], false, VAR_EXPORT_NO_INDEX); | ||
+ | /* | ||
+ | array ( | ||
+ | 1, | ||
+ | 2, | ||
+ | 3, | ||
+ | ) | ||
+ | */ | ||
- | I hope that's clear. | + | var_export([1, |
+ | /* | ||
+ | array (0 => 1, 1 => 2, 2 => 3) | ||
+ | */ | ||
+ | </ | ||
- | In the event that this RFC is voted through I will, however, be updating these tests. | + | and combine them... |
+ | |||
+ | <code php> | ||
+ | var_export([1, 2, 3], false, VAR_EXPORT_SHORT_ARRAY | VAR_EXPORT_NO_INDEX); | ||
+ | /* | ||
+ | [ | ||
+ | 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] | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | ===== Backward Incompatible Changes ===== | ||
+ | There shouldn' | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 110: | Line 172: | ||
https:// | https:// | ||
+ | |||
+ | https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
rfc/var-export-array-syntax.1585584140.txt.gz · Last modified: 2020/03/30 16:02 by googleguy