Bug in 5.3 __invoke() magic method?
| From: | Nathan Nobbe | Date: | Wed, 29 Sep 2010 19:44:13 +0000 |
| Subject: | Bug in 5.3 __invoke() magic method? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-49801@lists.php.net to get a copy of this message | ||
Hi,
Started using 5.3 and stumbled into what appears to be a bug with the
__invoke() magic method. It works fine if used in an object for a class
defining __invoke() is stored in a local variable, however when storing said
object as an instance variable, a fatal is raised. See my example below.
<?php
class A
{
public function __invoke()
{
echo __CLASS__ . PHP_EOL;
}
}
class B
{
private $a = null;
public function __construct()
{
$this->a = new A();
$this->a();
}
}
$a = new A();
$a();
$b = new B();
?>
Output:
A
Fatal error: Call to undefined method B::a() in
/Users/quickshiftin/gitRepos/timberline/ct-rip/test-callable.php on line 17
Expected Output:
A
A
thx,
-nathan