|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-06-01 15:43 UTC] 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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
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