Bug #75933 [Opn]: call_user_func_array does not resolve parent for instances
| From: | jason at papertower dot com | Date: | Thu, 08 Feb 2018 00:14:25 +0000 |
| Subject: | Bug #75933 [Opn]: call_user_func_array does not resolve parent for instances | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213855@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75933&edit=1
ID: 75933
User updated by: jason at papertower dot com
Reported by: jason at papertower dot com
-Summary: call_user_func_array does not resolve parent for
instnaces
+Summary: call_user_func_array does not resolve parent for
instances
Status: Open
Type: Bug
Package: Class/Object related
Operating System: MacOS 10.13.3
PHP Version: 7.1.14
Block user comment: N
Private report: N
New Comment:
Fixed typo in summary
Previous Comments:
------------------------------------------------------------------------
[2018-02-08 00:12:11] jason at papertower dot com
Description:
------------
When working within a child class, attempting to call a parent instance method using
call_user_func_array is impossible. The function will always interpret the callable as a static
method, rather than an instance.
I apologize if this is in the wrong place or if not enough information was provided. It seems like a
simple, reproducible bug. It makes sense, as I'm not sure how the function would discern the
parent. Perhaps there needs to be an explicit equivalent of $this but for the parent?
Test script:
---------------
class Parent {
function A() {}
}
class Child extends Parent {
function B() {
call_user_func_array('parent::A');
}
}
$child = new Child();
$child->B();
Expected result:
----------------
I would expect the code to be the equivalent of running parent::A() within the method, resolving
based on context whether the parent is an instance or class.
Actual result:
--------------
An error is throwing saying the callable is not a valid callback as a non-static method was
expected, and an instance method should not be called statically.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75933&edit=1