php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78898 call_user_func(['parent'.. fails while other succeed
Submitted: 2019-12-02 12:49 UTC Modified: 2019-12-04 08:37 UTC
From: sjon@php.net Assigned: nikic (profile)
Status: Closed Package: Class/Object related
PHP Version: 7.4.0 OS: archLinux
Private report: No CVE-ID: None
 [2019-12-02 12:49 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-03 09:38 UTC] 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-04 08:37 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2019-12-04 08:42 UTC] nikic@php.net
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
 [2019-12-04 08:42 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Aug 10 15:01:25 2020 UTC