Bug #75933 [NEW]: call_user_func_array does not resolve parent for instnaces
| From: | jason at papertower dot com | Date: | Thu, 08 Feb 2018 00:12:12 +0000 |
| Subject: | Bug #75933 [NEW]: call_user_func_array does not resolve parent for instnaces | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213854@lists.php.net to get a copy of this message | ||
From: jason at papertower dot com
Operating system: MacOS 10.13.3
PHP version: 7.1.14
Package: Class/Object related
Bug Type: Bug
Bug description:call_user_func_array does not resolve parent for instnaces
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 bug report at https://bugs.php.net/bug.php?id=75933&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75933&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75933&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75933&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75933&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75933&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75933&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75933&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75933&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75933&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75933&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75933&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75933&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75933&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75933&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75933&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75933&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75933&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75933&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75933&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75933&r=mysqlcfg