Edit report at https://bugs.php.net/bug.php?id=62208&edit=1
ID: 62208
Comment by: reeze dot xia at gmail dot com
Reported by: cidahf at live dot co dot uk
Summary: is_callable() returning false if method name is the
same as the class name
Status: Open
Type: Bug
Package: *General Issues
Operating System: Ubuntu 12.04
PHP Version: 5.4.3
Block user comment: N
Private report: N
New Comment:
This is not a bug.
The method the same as class name is legacy class constructor,
when check like is_callable(array('ClassName', 'classname') means
check whether ClassName:classname() is callable, but the constructor
didn't allow call statically. if you do that, a fatal error will raise.
you could call it as instance method:
is_callable(array(new Test, 'test')) => true;
Thanks
Previous Comments:
------------------------------------------------------------------------
[2012-06-01 15:43:55] cidahf at live dot co dot uk
Description:
------------
Using the is_callable function to check the existence of a method using a
string
identifier for the class fails to work as expected when the method name is the
same as the class name.
Normally, I would use method_exists(), but it doesn't account for whether or
not
the method is accessible.
This bug does not seem to occur on 5.2.5 (tested on codepad).
My exact PHP version is "5.4.3-4~precise+1"
Test script:
---------------
<?php
class Test
{
public function test ()
{
}
}
var_dump (is_callable (array ('Test', 'test')));
Expected result:
----------------
bool(true)
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62208&edit=1