is_callable returns true even if method does not exist in parent class
| Bug #48899 | is_callable returns true even if method does not exist in parent class | ||||
|---|---|---|---|---|---|
| Submitted: | 2009-07-12 23:25 UTC | Modified: | 2009-07-15 01:11 UTC | ||
| From: | hm at mkjc dot net | Assigned: | felipe (profile) | ||
| Status: | Closed | Package: | Scripting Engine problem | ||
| PHP Version: | 5.3.0 | OS: | Windows Vista x64 | ||
| Private report: | No | CVE-ID: | None | ||
[2009-07-12 23:25 UTC] hm at mkjc dot net
Description:
------------
is_callable returns "true" for methods that are not present in the parent class, but in the child class, even if you use the "parent" keyword.
Earlier php versions correctly returned false, since the method is missing in the parent class.
Perhaps it has something to do with the changes in conjunction with late static binding.
Reproduce code:
---------------
<?php
class ParentClass {
}
class ChildClass extends ParentClass {
public function testIsCallable() {
var_dump(is_callable(array($this, 'parent::testIsCallable')));
}
}
$child = new ChildClass();
$child->testIsCallable();
?>
Expected result:
----------------
bool(false)
Actual result:
--------------
bool(true)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-07-15 01:11 UTC] felipe@php.net