Bug #53195 [Opn->Bgs]: __invoke fails when object is member of another object.

From: Date: Thu, 28 Oct 2010 20:38:41 +0000
Subject: Bug #53195 [Opn->Bgs]: __invoke fails when object is member of another object.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155608@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53195&edit=1 ID: 53195 Updated by: felipe@php.net Reported by: dmgx dot michael at gmail dot com Summary: __invoke fails when object is member of another object. -Status: Open +Status: Bogus Type: Bug -Package: Class/Object related +Package: Scripting Engine problem Operating System: Windows PHP Version: 5.3.3 Block user comment: N New Comment: This is the expected behavior. And it is not exclusively related to parent object... But all $this->closure. See http://wiki.php.net/rfc/closures/object-extension Previous Comments: ------------------------------------------------------------------------ [2010-10-28 21:23:39] dmgx dot michael at gmail dot com Description: ------------ The magic invoke function fails to trigger if an object belongs to another object. Test script: --------------- class A { public function __invoke() { echo 'hello from A '; } } class B { protected $a; public function __invoke() { echo 'hello from B '; $this->a = new A(); $this->a(); } } $b = new B(); $b(); Expected result: ---------------- hello from B hello from A Actual result: -------------- hello from B Fatal error: Call to undefined method B::a() in C:\xampp\gazelle\tools\htdocs\testing.php on line 15 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53195&edit=1

« previous php.bugs (#155608) next »