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
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: vovan-ve at yandex dot ru
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 13:01:33 2025 UTC