Req #71057 [Opn->Nab]: var_export uses long array syntax, is not PSR-2 compliant
| From: | krakjoe@php.net | Date: | Tue, 08 Dec 2015 14:10:11 +0000 |
| Subject: | Req #71057 [Opn->Nab]: var_export uses long array syntax, is not PSR-2 compliant | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197695@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71057&edit=1
ID: 71057
Updated by: krakjoe@php.net
Reported by: marcus at synchromedia dot co dot uk
Summary: var_export uses long array syntax, is not PSR-2
compliant
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: Arrays related
PHP Version: 5.6.16
Block user comment: N
Private report: N
New Comment:
The justification for short array syntax - that it is short - doesn't matter for generated
code.
What matters is that the output is predictable across PHP versions, for that reason it doesn't
make sense to change the format of the output in order to comply with a PSR that doesn't apply
to internals, and was never meant too.
Definitely, not a bug ...
Previous Comments:
------------------------------------------------------------------------
[2015-12-08 11:20:00] marcus at synchromedia dot co dot uk
Description:
------------
Calling var_export with an array parameter generates PHP code that uses old-style long array syntax
instead of PHP 5.4-style short array syntax.
There are also some spacing issues that mean that the generated code is not PSR-2 compliant (space
after 'array' and 2-space indenting), and I don't see any good reason for that not to
be the case.
It appears that this behaviour occurs in all versions since PHP 5.4, including 7.
Test script:
---------------
var_export(['a' => 0]);
Expected result:
----------------
[
'a' => 0,
]
Actual result:
--------------
array (
'a' => 0,
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71057&edit=1