|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64914 get_called_class incorrect after call_user_func to a parent static function
Submitted: 2013-05-24 08:15 UTC Modified: 2020-10-19 09:25 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: e dot nash at dvz-mv dot de Assigned:
Status: Verified Package: Class/Object related
PHP Version: 5.4.15 OS: Win/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: e dot nash at dvz-mv dot de
New email:
PHP Version: OS:


 [2013-05-24 08:15 UTC] e dot nash at dvz-mv dot de
When called from an instance function via call_user_func (or call_user_func_array), the late static binding appears to not recognise an explicit call to a parent static function and propagates the caller as the called class rather than the callee.

When called "directly" the late static binding functions correctly.

To reiterate: there is an inconsistency here between the results with P::test() and call_user_func('P::test') in the test script below. My opinion is that this is a bug.

Tested with the script below in PHP 5.3 and PHP 5.4.15.

If this is the expected behaviour ("feature not a bug") then it should be prominently documented (c.f. bug #47402)

Test script:
abstract class P {
	static public function test() {
		echo get_called_class();
class C extends P {
	public static function runStatic() {
		call_user_func(array('P', 'test'));
	public function run() {
		call_user_func(array('P', 'test'));
$c = new C();

Expected result:
Console output:

Actual result:
Console output:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-24 09:24 UTC] e dot nash at dvz-mv dot de
Forgot to add:
static::test() in both runStatic() and run() produces the output C, as would be expected through the LSB.
 [2018-07-11 20:10 UTC] dev at mike dot pp dot ua
Still not fixed in PHP (cli) (built: Jun 22 2018 08:45:49) ( NTS ).

Seems like the call_user_func() (and call_user_func_array()) works the same way as the forward_static_call().
 [2020-10-19 09:25 UTC]
-Status: Open +Status: Verified
 [2020-10-19 09:25 UTC]
Confirmed: <>.

It seems to me that CUF/CUFA needed to use the calling scope of
the passed callable instead of the called scope.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Sep 29 14:05:55 2022 UTC