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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon May 13 20:01:34 2024 UTC