Bug #62208 [Opn->Nab]: is_callable() returning false if method name is the same as the class name
| From: | felipe@php.net | Date: | Sun, 03 Jun 2012 14:23:27 +0000 |
| Subject: | Bug #62208 [Opn->Nab]: is_callable() returning false if method name is the same as the class name | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-170997@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62208&edit=1
ID: 62208
Updated by: felipe@php.net
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
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Ubuntu 12.04
PHP Version: 5.4.3
Block user comment: N
Private report: N
New Comment:
Reeze is right. Thanks.
Previous Comments:
------------------------------------------------------------------------
[2012-06-01 16:32:12] reeze dot xia at gmail dot com
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
------------------------------------------------------------------------
[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