Bug #61569 [Opn->Csd]: Syntax error for calling a closure using array accesor on function call
Edit report at https://bugs.php.net/bug.php?id=61569&edit=1
ID: 61569
Updated by: nikic@php.net
Reported by: oxygenus at gmail dot com
Summary: Syntax error for calling a closure using array
accesor on function call
-Status: Open
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: ANY
PHP Version: master
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Supported in PHP 7.
Previous Comments:
------------------------------------------------------------------------
[2012-04-02 10:26:38] nikic@php.net
I mentioned this some time ago on internals, but it didn't seem like anyone was interested in
this :(
------------------------------------------------------------------------
[2012-03-31 01:51:18] yohgaki@php.net
Changed package to Scripting Engine Problem and OS is irrelevant.
Anyway, will this be supported?
------------------------------------------------------------------------
[2012-03-30 15:36:18] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61569&edit=1
Thread (4 messages)