php.net |  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
Votes:2
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
 [2012-05-20 17:34 UTC] dan dot lugg at gmail dot com
Description:
------------
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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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] felipe@php.net
-Type: Bug +Type: Feature/Change Request
 [2015-01-10 22:56 UTC] requinix@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: requinix
 [2015-01-10 22:56 UTC] requinix@php.net
Fixed in PHP 7. http://3v4l.org/lPHbE
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 09:01:30 2024 UTC