php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51326 Closure must be used as object property
Submitted: 2010-03-18 21:21 UTC Modified: 2010-03-21 19:47 UTC
From: frederic dot hardy at mageekbox dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.2 OS: FreeBSD 7.1
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: frederic dot hardy at mageekbox dot net
New email:
PHP Version: OS:

 

 [2010-03-18 21:21 UTC] frederic dot hardy at mageekbox dot net
Description:
------------
If a class instance has a closure as property, PHP must call $this->closure->__invoke() instead of say that method class::closure() does not exist.

Test script:
---------------
<?php

class foo
{
   protected $closure = null;

   function __construct(\closure $closure)
   {
      $this->closure = $closure;
   }

   function callClosure()
   {
      return $this->closure('Closure::__invoke() was called');
   }
}

$foo = new foo(function($string) { echo $string; });

$foo->callClosure();

?>

Expected result:
----------------
Closure::__invoke() was called

Actual result:
--------------
Call to undefined method foo::closure() in /path/to/script.php on line 14

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-19 00:58 UTC] felipe@php.net
-Package: *General Issues +Package: Scripting Engine problem
 [2010-03-21 19:47 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-03-21 19:47 UTC] johannes@php.net
The whole "object handling" of closures was held back in order to get 5.3out. The next major version of PHP (5.4 / 6.0) will most likely add better oo support. During the discussions this aspect will be discussed,no need for an additional bug report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:29 2024 UTC