php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66905 Unable to call after literal array dereference
Submitted: 2014-03-14 11:12 UTC Modified: 2014-10-07 14:20 UTC
From: vovan-ve at yandex dot ru Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.5.10 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
31 - 20 = ?
Subscribe to this entry?

 
 [2014-03-14 11:12 UTC] vovan-ve at yandex dot ru
Description:
------------
PHP 5.4 allows us to make a call after array dereference:

    $a = [function () {  return 42;  }];
    var_dump( $a[0]() );
    // int(42)

PHP 5.5 allows us to dereferende literal array even:

    var_dump([42][0]);
    // int(42)

But combination of this features cause a syntax error.
Test in a sandbox: http://3v4l.org/1CHXs

Test script:
---------------
var_dump([function () {  return 42;  }][0]());

Expected result:
----------------
int(42)

Actual result:
--------------
Parse error: syntax error, unexpected '(' in ...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-07 14:20 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2014-10-07 14:20 UTC] nikic@php.net
Fixed in PHP 7.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 11:01:34 2024 UTC