|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36635 is_callable returns true for interfaces
Submitted: 2006-03-06 20:15 UTC Modified: 2006-03-06 20:48 UTC
From: slafontaine at avance dot info Assigned: helly (profile)
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.2 OS: *
Private report: No CVE-ID: None
 [2006-03-06 20:15 UTC] slafontaine at avance dot info
When you use is_callable to check if a method is callable on an interface, it returns true which might be because Classes and Interfaces share the same namespace.

Reproduce code:
interface MyInterface
    function callableFunc();

if (is_callable(array("MyInterface", "callableFunc"))) {
    print("Is callable!");
    call_user_func(array("MyInterface", "callableFunc"));
} else {
    print("Is NOT callable!");

Expected result:
Is NOT callable!

Actual result:
Is callable!

Fatal error:  Cannot call abstract method MyInterface::callableFunc() in path/to/file on line ###


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-06 20:48 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

The method is indeed callable - if you had an object. And that's the whole issue, try it with abstract methods in abstract classes, that's the same. And that's just because is_callable doesn't verify the scope.

Perhaps we should verify that you actually have an object specified if that is necessary. But that would be a bigger BC break i guess.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 05 09:01:27 2024 UTC