php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50647 Short array notation
Submitted: 2010-01-04 11:46 UTC Modified: 2010-01-04 16:11 UTC
From: robert_xp at gmx dot net Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.3.1 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-01-04 11:46 UTC] robert_xp at gmx dot net
Description:
------------
A nice improvement for PHP would be a short hand notation for arrays. You can find more details here: http://www.xarg.org/2009/12/php-hacking/

Reproduce code:
---------------
//old:
$arr = array(1, 2, array(5 => "foo", 3.14159), 9);

//new:
$arr = [1, 2, [5 => "foo", 3.14159], 9];

Expected result:
----------------
In both cases the result of $arr should be the same.

Actual result:
--------------
Compile-error

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-04 12:27 UTC] aharvey@php.net
This has already gone through the RFC process and been declined, per http://wiki.php.net/rfc/shortsyntaxforarrays
 [2010-01-04 15:32 UTC] robert_xp at gmx dot net
Grml...Sorry, I didn't saw this before. I read the mailing lists, but I couldn't find a justification why this feature is declined. Most userspace votes were positive, and I added this feature independent from these discussions - maybe open another vote with more parts?
 [2010-01-04 16:11 UTC] aharvey@php.net
If you really, really, really want to reopen that can of worms, take it to the Internals mailing list. At best, you'll get a few suggestions to write a fresh RFC for possible inclusion in PHP 6. More likely, you'll get pointed to the same link I've pointed you to.

If you do this, bear in mind that it's been discussed many times over the years, and has been rejected each and every time. To whit, a possibly complete list of previous mailing list discussions back to the start of 2006:

December 2008: http://marc.info/?l=php-internals&m=122956025230147&w=2

May 2008: http://marc.info/?l=php-internals&m=121142241913674&w=2

January 2008: http://marc.info/?l=php-internals&m=120000917517840&w=2 and http://marc.info/?l=php-internals&m=119995972028293&w=2

February 2007: http://marc.info/?l=php-internals&m=117057393530217&w=2

January 2006: http://marc.info/?l=php-internals&m=113851593906799&w=2

The (extremely lengthy) May 2008 discussion was the one that led to the RFC.

In short, this is pretty much in the same boat as being able to directly dereference array returned from functions, or ifsetor, or taint support, or some of the other regularly requested features that don't spring to mind at 12:07 on a Tuesday morning: it comes up on a regular basis, and while you and I may or may not agree with the decisions that have been made, they've been made, and I don't know that anyone will thank you for reopening a debate that's been had many times over.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Mar 05 20:01:24 2021 UTC