php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51281 Json-like alternative syntax for arrays
Submitted: 2010-03-12 09:18 UTC Modified: 2010-03-15 03:33 UTC
From: olamedia at gmail dot com Assigned:
Status: Wont fix Package: Arrays related
PHP Version: 5.3.2 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: olamedia at gmail dot com
New email:
PHP Version: OS:

 

 [2010-03-12 09:18 UTC] olamedia at gmail dot com
Description:
------------
Json-like alternative syntax for arrays feature request.
It's much shorter, and don't have conflicts with current tokens.

Test script:
---------------
$a = [1,2];
$a = ['a':1,'b':2];
$a = array('a':1,'b':2);
$a = array('a'=>1,'b'=>2);
$a = ['a'=>1,'b'=>2];


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-12 09:31 UTC] olamedia at gmail dot com
Changing package
 [2010-03-12 12:34 UTC] olamedia at gmail dot com
Found in wiki a declined patch: http://wiki.php.net/rfc/shortsyntaxforarrays
But I really want
$a = [[],[],[],[],[]]
instead of
$a = array(array(),array(),array(),array(),array());
 [2010-03-15 03:33 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 [2010-03-15 03:33 UTC] aharvey@php.net
Since you've already found the declined RFC that covered this, I'll simply quote 
what I wrote in bug #50647:

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 you've already found.

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 2007:

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

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC