|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70160 string with double colon is callable, but cannot be called
Submitted: 2015-07-28 15:34 UTC Modified: 2015-07-28 19:26 UTC
From: cf0hay at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Variables related
PHP Version: n/a OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cf0hay at gmail dot com
New email:
PHP Version: OS:


 [2015-07-28 15:34 UTC] cf0hay at gmail dot com
callable typehint and is_callable may return true for a string with double colon, but it's not callable with parentheses. On the page

"As of PHP 5.2.3, it is also possible to pass 'ClassName::methodName'"

Well, able to pass, but cannot use.

Occurs in PHP 5.6. PHP 7.0 doesn't have this problem, it works properly.

Test script:
namespace ns {
    class cls{
        static function sfn(){
            return 'OK';

namespace {
    function mycallfn(callable $x){
            return $x();
            return 'FAIL';
    echo mycallfn(["ns\\cls", "sfn"])."\n";
    echo mycallfn("ns\\cls::sfn")."\n";

Expected result:

Actual result:
PHP Fatal error:  Call to undefined function ns\cls::sfn() on line 13


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-28 18:52 UTC]
-Status: Open +Status: Verified -Package: Documentation problem +Package: Variables related -Operating System: 64bit Linux +Operating System: * -PHP Version: 5.6.11 +PHP Version: n/a -Assigned To: +Assigned To: cmb
 [2015-07-28 18:52 UTC]
Actually, this is not a problem regarding the callable type hint
or the passing of callables (which works as expected and
documented), but rather a problem regarding variable functions[1].
If you use `return call_user_func($x);` instead of `return $x;`,
the script works fine. See also request #68475, which has been
implemented for PHP 7, but won't be backported to PHP 5.

Anyhow, the documentation of variable functions is rather
incomplete, which should be changed.

[1] <>
 [2015-07-28 19:23 UTC]
Automatic comment from SVN on behalf of cmb
Log: updated variable function documentation (fixes #70160)
 [2015-07-28 19:26 UTC]
-Status: Verified +Status: Closed
 [2015-07-28 19:26 UTC]
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jul 28 01:01:23 2021 UTC