php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62386 Closures require arguments in function header
Submitted: 2012-06-22 00:35 UTC Modified: 2012-06-22 04:19 UTC
From: Daniel dot L dot Nill at gmail dot com Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3Git-2012-06-21 (Git) OS: linux
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: Daniel dot L dot Nill at gmail dot com
New email:
PHP Version: OS:

 

 [2012-06-22 00:35 UTC] Daniel dot L dot Nill at gmail dot com
Description:
------------
There seems to be no reason for this throwing an error, but if I try to 
instantiate an anonymous function that does not have any arguments then I get an 
'Parse error'.  This breaks a lot of closure functionality that could exist.

Test script:
---------------
$anonymous_function = function(){
    echo "hello world<br/>";
};

$anonymous_function();
$anonymous_function;

Expected result:
----------------
hello world
hello world

Actual result:
--------------
Parse error: syntax error, unexpected T_FUNCTION in /index.php(192) : eval()'d 
code on line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-22 02:16 UTC] reeze dot xia at gmail dot com
It's a function but not a class.
We have to use ()to call it
 [2012-06-22 04:19 UTC] Daniel dot L dot Nill at gmail dot com
-Status: Open +Status: Closed
 [2012-06-22 04:19 UTC] Daniel dot L dot Nill at gmail dot com
not sure why closures don't allow variable functions, but it turns out my core 
issue was a versioning issue.  Upon updating php to 5.3.8 this goes away.  Still 
not sure why I was getting a parse error when no arguments where introduced, but 
I'm closing this ticket.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC