#36635 [Opn->Bgs]: is_callable returns true for interfaces
| From: | helly@php.net | Date: | Mon, 06 Mar 2006 19:48:05 +0000 |
| Subject: | #36635 [Opn->Bgs]: is_callable returns true for interfaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-93983@lists.php.net to get a copy of this message | ||
ID: 36635
Updated by: helly@php.net
Reported By: slafontaine at avance dot info
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
-Operating System: Windows XP
+Operating System: *
PHP Version: 5.1.2
-Assigned To:
+Assigned To: helly
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
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.
Previous Comments:
------------------------------------------------------------------------
[2006-03-06 20:15:14] slafontaine at avance dot info
Description:
------------
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 ###
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36635&edit=1