php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63111 is_callable() lies for abstract static method
Submitted: 2012-09-18 15:07 UTC Modified: 2012-09-18 16:09 UTC
From: vovan-ve at yandex dot ru Assigned: dmitry (profile)
Status: Closed Package: Class/Object related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2012-09-18 15:07 UTC] vovan-ve at yandex dot ru
Description:
------------
The function is_callable() says, that abstract static method _IS_ callable. But it is abstract, it has no body.

    abstract class Foo {
        abstract static function bar();
    }
    # PHP Strict Standards: Static function Foo::bar() should not be abstract
    # is Foo::bar() callable?
    var_dump( is_callable(array("Foo", "bar")) );
    # bool(true)
    # O_o Ok, let's try...
    Foo::bar();
    # Fatal error: Cannot call abstract method Foo::bar()

Yes, I see a Strict. Anyway, is_callable() lies. I have checked this in 5.3.10, 5.3.6 and 5.2.17.

Test script:
---------------
abstract class Foo {
    abstract static function bar();
}

var_dump( is_callable(array("Foo", "bar")) );
Foo::bar();


Expected result:
----------------
bool(false)
Fatal error

Actual result:
--------------
bool(true)
Fatal error

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-18 15:57 UTC] laruence@php.net
-Assigned To: +Assigned To: dmitry
 [2012-09-18 15:57 UTC] laruence@php.net
hmm, dmitry could you please look at this? thanks
 [2012-09-18 16:09 UTC] laruence@php.net
seems similar with #36635
 [2012-09-21 11:17 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2012-09-21 11:17 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4db74b7f1981bf19805e815f983c50d93df2c26a
Log: Fixed bug #63111 (is_callable() lies for abstract static method)
 [2014-10-07 23:22 UTC] stas@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=4db74b7f1981bf19805e815f983c50d93df2c26a
Log: Fixed bug #63111 (is_callable() lies for abstract static method)
 [2014-10-07 23:33 UTC] stas@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=4db74b7f1981bf19805e815f983c50d93df2c26a
Log: Fixed bug #63111 (is_callable() lies for abstract static method)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC