Hi internals,
Voting has started today on https://wiki.php.net/rfc/readable_var_representation
and closes on 2021-02-19.
This RFC proposes introducing a new function var_representation
with the following differences from var_export:
-
var_representation()
unconditionally returns a string -
Use
null
instead ofNULL
- the former is recommended by more coding
guidelines (https://www.php-fig.org/psr/psr-2/). -
Change the way indentation is done for arrays/objects.
See ext/standard/tests/general_functions/short_var_export1.phpt
(e.g. always add 2 spaces, never 3 in objects, and put the array start on the
same line as the key) -
Render lists as
"[\n 'item1',\n]"
rather than"array(\n 0 => 'item1',\n)"
Always render empty lists on a single line, render multiline by default when there are 1 or more elements
-
Prepend
\
to class names so that generated code snippets can be used in
namespaces without any issues. -
Support
VAR_REPRESENTATION_SINGLE_LINE
in $flags.
This will use a single-line representation for arrays/objects. -
Escape control characters("\x00"-"\x1f" and "\x7f"(backspace)) inside of double quoted strings
instead of single quoted strings with unescaped control characters mixed with. "\0" .
.
Thanks,
-Tyson