|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75853 Unexpected fatal error invoking static method as callables
Submitted: 2018-01-21 19:10 UTC Modified: 2021-09-02 13:26 UTC
From: marcospassos dot com at gmail dot com Assigned: nikic (profile)
Status: Assigned Package: Class/Object related
PHP Version: 7.2.2RC1 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: marcospassos dot com at gmail dot com
New email:
PHP Version: OS:


 [2018-01-21 19:10 UTC] marcospassos dot com at gmail dot com
An unrecoverable error occurs when a static method is called as a callable, in the form of [ClassName::class, 'parent::staticMethod'], which is a perfectly valid form of callable. The same does not occur invoking the callable through call_user_func, call_user_func_array or ReflectionMethod::invoke.

Test script:

Expected result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-21 19:37 UTC]
This is one of the times I'm want to see some rationale as to why the bug is with `callable` and not with everything else. You are statically using child's symbol but statically referring to the parent method? If it was dynamic there *might* be a use-case for that but at least directly as written I don't see the value. Is there some use I'm missing?
 [2018-01-21 22:25 UTC] marcospassos dot com at gmail dot com
I can't see any real use case for this. However, my point is that type-hinting against a callable should ensure that the argument is a function/method, so there is a problem in the pseudo-type checking mechanism indeed.
 [2018-01-22 00:40 UTC]
> which is a perfectly valid form of callable.

Other than, "it kind of works some of the time", what's the justification for saying that it's a valid form of callable? i.e. is it in the manual anywhere?
 [2018-01-22 00:46 UTC] marcospassos dot com at gmail dot com
From manual:

// Type 5: Relative static class method call (As of PHP 5.3.0)
class A {
    public static function who() {
        echo "A\n";

class B extends A {
    public static function who() {
        echo "B\n";

call_user_func(array('B', 'parent::who')); // A
 [2018-01-22 15:06 UTC]
Also note that not only `parent::` is_callable() , but actually
any parent class of the class designated by the first array
element. E.g. <>.  In my opionion that's
rather dubious, but we may not be able to change this for BC
 [2021-09-02 13:26 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: nikic
 [2021-09-02 13:26 UTC] would resolve this inconsistency by dropping support.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 06:01:29 2024 UTC