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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue May 14 04:01:30 2024 UTC