php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48581 __invoke in child class
Submitted: 2009-06-17 10:45 UTC Modified: 2009-06-18 14:12 UTC
From: yeti at na-svyazi dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3CVS-2009-06-17 (snap) OS: winxp
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: yeti at na-svyazi dot ru
New email:
PHP Version: OS:

 

 [2009-06-17 10:45 UTC] yeti at na-svyazi dot ru
Description:
------------
__invoke in child class not worked correctly?

Reproduce code:
---------------
class Callable
{
    function __invoke($x) {
        var_dump($x);
    }
}

class A {}

$obj = new Callable;

$a = new A;
$a->c = $obj;

var_dump(is_callable($obj));
var_dump(is_callable($a->c));

$obj(1);
$a->c(2);

Expected result:
----------------
bool(true)
bool(true)
int(1)
int(2)

Actual result:
--------------
bool(true)
bool(true)
int(1)

Fatal error: Call to undefined method A::c() in E:\Work\1.php on line 22
PHP Fatal error:  Call to undefined method A::c() in E:\Work\1.php on line 22


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-18 14:12 UTC] johannes@php.net
$a->c(2); looks for a method c in the object, not a property. This is currently expected behavior. We will consider adding this in later versions.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC