php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53195 __invoke fails when object is member of another object.
Submitted: 2010-10-28 21:23 UTC Modified: 2010-10-28 22:38 UTC
From: dmgx dot michael at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.3 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dmgx dot michael at gmail dot com
New email:
PHP Version: OS:

 

 [2010-10-28 21:23 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-28 22:38 UTC] felipe@php.net
-Status: Open +Status: Bogus -Package: Class/Object related +Package: Scripting Engine problem
 [2010-10-28 22:38 UTC] felipe@php.net
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
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 04:01:38 2025 UTC