#50003 [NEW]: Allow constructions like func()[0]

From: Date: Mon, 26 Oct 2009 18:45:24 +0000
Subject: #50003 [NEW]: Allow constructions like func()[0]
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-143969@lists.php.net to get a copy of this message
From:             melfar at gmail dot com
Operating system: agnostic
PHP version:      5.3.0
PHP Bug Type:     Feature/Change Request
Bug description:  Allow constructions like func()[0]

Description:
------------
PHP parser doesn't allow for array index operation to be used on a 
result of a function call.  I propose a patch to allow such a 
construction.

Reproduce code:
---------------
<?php
  function car_brands() {
    return array("chevy", "hummer");
  }
  print car_brands()[1] . "\n";
?>


Expected result:
----------------
"hummer"



Actual result:
--------------
Parse error: syntax error, unexpected '[' in test.php on line 5

-- 
Edit bug report at http://bugs.php.net/?id=50003&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=50003&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=50003&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=50003&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=50003&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50003&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=50003&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=50003&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=50003&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=50003&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=50003&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=50003&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=50003&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=50003&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=50003&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50003&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50003&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=50003&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=50003&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=50003&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=50003&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=50003&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#143969) next »