Edit report at https://bugs.php.net/bug.php?id=61569&edit=1

 ID:                 61569
 Comment by:         ni...@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:            Scripting Engine problem
 Operating System:   ANY
 PHP Version:        master
 Block user comment: N
 Private report:     N

 New Comment:

I mentioned this some time ago on internals, but it didn't seem like anyone was 
interested in this :(


Previous Comments:
------------------------------------------------------------------------
[2012-03-31 01:51:18] yohg...@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

Reply via email to