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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sjon@php.net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC