rfc:var-export-array-syntax
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:var-export-array-syntax [2020/03/29 17:48] – googleguy | rfc:var-export-array-syntax [2020/04/09 22:32] – googleguy | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2020-03-29 | * Date: 2020-03-29 | ||
* Author: Sherif Ramadan, googleguy@php.net | * Author: Sherif Ramadan, googleguy@php.net | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 12: | Line 12: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | Instead of <code php> | + | This change proposes 3 new bit-wise optional flags for '' |
+ | |||
+ | - VAR_EXPORT_SHORT_ARRAY | ||
+ | - VAR_EXPORT_NO_INDEX | ||
+ | - VAR_EXPORT_COMPACT | ||
+ | |||
+ | '' | ||
+ | |||
+ | |||
+ | Instead of | ||
+ | |||
+ | <code php> | ||
+ | array ( | ||
+ | 0 => 1, | ||
+ | 1 => 2, | ||
+ | 2 => 3, | ||
+ | ) | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | <code php> | ||
+ | [ | ||
+ | 0 => 1, | ||
+ | 0 => 2, | ||
+ | | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | This will effect things like '' | ||
+ | |||
+ | So the following changes are also in effect: | ||
+ | |||
+ | <code php> | ||
+ | $obj = new stdClass; | ||
+ | $obj-> | ||
+ | $obj-> | ||
+ | |||
+ | var_export($obj); | ||
+ | |||
+ | /* | ||
+ | Gives us: | ||
+ | (object) array( | ||
+ | ' | ||
+ | ' | ||
+ | ) | ||
+ | */ | ||
+ | |||
+ | //With the new change it would be | ||
+ | |||
+ | var_export($obj, | ||
+ | |||
+ | /* | ||
+ | (object) [ | ||
+ | ' | ||
+ | ' | ||
+ | ] | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | The same happens for classes: | ||
+ | |||
+ | <code php> | ||
+ | class Foo { | ||
+ | public $bar = " | ||
+ | } | ||
+ | |||
+ | var_export(new Foo); | ||
+ | |||
+ | /* | ||
+ | Gives us: | ||
+ | Foo:: | ||
+ | ' | ||
+ | )) | ||
+ | */ | ||
+ | |||
+ | |||
+ | //With the changes it would be: | ||
+ | |||
+ | var_export(new Foo, false, VAR_EXPORT_SHORT_ARRAY); | ||
+ | |||
+ | /* | ||
+ | Foo:: | ||
+ | ' | ||
+ | ]) | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | Using the other bitwise flags you can also do things like... | ||
+ | |||
+ | <code php> | ||
+ | var_export([1, | ||
+ | |||
+ | /* | ||
+ | outputs: | ||
+ | |||
+ | [1, 2, 3] | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | |||
+ | /* | ||
+ | outputs: | ||
+ | |||
+ | [0 => 1, 1 => 2, 2 => 3] | ||
+ | */ | ||
+ | |||
+ | var_export([1, | ||
+ | |||
+ | /* | ||
+ | outputs: | ||
+ | |||
+ | [ | ||
+ | 1, | ||
+ | 2, | ||
+ | 3 | ||
+ | ] | ||
+ | */ | ||
+ | |||
+ | |||
+ | </ | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 39: | Line 159: | ||
===== 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 45: | Line 167: | ||
===== References ===== | ===== References ===== | ||
https:// | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
rfc/var-export-array-syntax.txt · Last modified: 2020/04/10 09:24 by guilliamxavier