Bug #78898 [Opn]: call_user_func(['parent'.. fails while other succeed

From: Date: Tue, 03 Dec 2019 09:38:31 +0000
Subject: Bug #78898 [Opn]: call_user_func(['parent'.. fails while other succeed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224019@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78898&edit=1

 ID:                 78898
 Updated by:         cmb@php.net
 Reported by:        sjon@php.net
 Summary:            call_user_func(['parent'.. fails while other succeed
 Status:             Open
 Type:               Bug
 Package:            Class/Object related
 Operating System:   archLinux
 PHP Version:        7.4.0
 Block user comment: N
 Private report:     N

 New Comment:

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>


Previous Comments:
------------------------------------------------------------------------
[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)

« previous php.bugs (#224019) next »