php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61569 Syntax error for calling a closure using array accesor on function call
Submitted: 2012-03-30 15:36 UTC Modified: 2014-10-12 15:05 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: oxygenus at gmail dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: master OS: ANY
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: oxygenus at gmail dot com
New email:
PHP Version: OS:

 

 [2012-03-30 15:36 UTC] oxygenus at gmail dot com
Description:
------------
Parse error: syntax error, unexpected '(' in C:\phpinfo.php on line 26

26: giveArray($arrFunctions)[0]("Hello world")

Test script:
---------------
<?php
function giveArray($arrSomething)
{
	return $arrSomething;
}

$arrFunctions=[
	0=>function($strSomeParam)
	{
		return $strSomeParam;
	},
];

//this works
var_export(
	giveArray($arrFunctions)[0]
);

//this works
var_export(
	$arrFunctions[0]("Hello world")
);

//this fails compilation with syntax error
var_export(
	giveArray($arrFunctions)[0]("Hello world")
);


Expected result:
----------------
Closure::__set_state(array(
))'Hello world''Hello world'

Actual result:
--------------
Parse error: syntax error, unexpected '(' in C:\phpinfo.php on line 26

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-31 01:51 UTC] yohgaki@php.net
Changed package to Scripting Engine Problem and OS is irrelevant.

Anyway, will this be supported?
 [2012-03-31 01:51 UTC] yohgaki@php.net
-Package: Compile Failure +Package: Scripting Engine problem -Operating System: Windows XP SP3 +Operating System: ANY -PHP Version: 5.4.0 +PHP Version: master
 [2012-04-02 10:26 UTC] nikic@php.net
I mentioned this some time ago on internals, but it didn't seem like anyone was interested in this :(
 [2014-10-12 15:05 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2014-10-12 15:05 UTC] nikic@php.net
Supported in PHP 7.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 03 01:01:29 2025 UTC