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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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: Tue May 14 21:01:33 2024 UTC