|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62078 Closure instantiation and chaining
Submitted: 2012-05-20 17:34 UTC Modified: 2015-01-10 22:56 UTC
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: dan dot lugg at gmail dot com Assigned: requinix (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.4.3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
21 + 25 = ?
Subscribe to this entry?

 [2012-05-20 17:34 UTC] dan dot lugg at gmail dot com
When you "instantiate" a closure through the function(){} syntax, you cannot chain 
the closure method bindTo() from the instantiation. While this is trivial, 
considering static Closure::bind(), it seems inconsistent with efforts to allow 
method invocation on instantiation of other objects.

Test script:
$function = (function(){ /* ... */ })->bindTo($object);

Expected result:
$function should contain the instantiated and re-bound closure.

Actual result:
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-20 17:36 UTC] dan dot lugg at gmail dot com
I apologize if the bug category is not correct; there didn't appear to be a "Syntax" category or related.
 [2012-05-20 17:38 UTC]
-Type: Bug +Type: Feature/Change Request
 [2015-01-10 22:56 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: requinix
 [2015-01-10 22:56 UTC]
Fixed in PHP 7.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 14:01:29 2024 UTC