Bug #61569 [Opn]: 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: yohgaki@php.net
Reported by: oxygenus at gmail dot com
Summary: Syntax error for calling a closure using array
accesor on function call
Status: Open
Type: Bug
-Package: Compile Failure
+Package: Scripting Engine problem
-Operating System: Windows XP SP3
+Operating System: ANY
-PHP Version: 5.4.0
+PHP Version: master
Block user comment: N
Private report: N
New Comment:
Changed package to Scripting Engine Problem and OS is irrelevant.
Anyway, will this be supported?
Previous Comments:
------------------------------------------------------------------------
[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)