Bug #78898 [Asn->Csd]: call_user_func(['parent'.. fails while other succeed
Edit report at https://bugs.php.net/bug.php?id=78898&edit=1
ID: 78898
Updated by: nikic@php.net
Reported by: sjon@php.net
Summary: call_user_func(['parent'.. fails while other succeed
-Status: Assigned
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: archLinux
PHP Version: 7.4.0
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6540797f1ef5116d9c806baebc43582980db242d
Log: Fixed bug #78898
Previous Comments:
------------------------------------------------------------------------
[2019-12-03 09:38:31] cmb@php.net
The behavioral change has been introduced with commit 72bf2de[1].
Not sure whether this particular change was intented.
[1] <http://git.php.net/?p=php-src.git;a=commit;h=72bf2def6b718ae9ca243b6a9ab9a3a85d255f96>
------------------------------------------------------------------------
[2019-12-02 12:49:56] sjon@php.net
Description:
------------
when extending a class that has both a protected method, and a __call - certain call_user_func calls
will end up in __call instead of the protected method - see https://3v4l.org/4El6Z
Test script:
---------------
<?php
class A
{
protected function _x()
{
echo "a";
}
public function __call($methodName, array $arguments)
{
throw new Exception("Unknown method.");
}
}
class B extends A
{
public function x()
{
parent::_x(); # works
call_user_func('parent::_x'); # works
call_user_func(['parent', '_x']); # fails
}
}
$b = new B;
$b->x();
Expected result:
----------------
aaa
Actual result:
--------------
aa Exception
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78898&edit=1
Thread (3 messages)