|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-05-24 09:24 UTC] e dot nash at dvz-mv dot de
[2018-07-11 20:10 UTC] dev at mike dot pp dot ua
[2020-10-19 09:25 UTC] cmb@php.net
-Status: Open
+Status: Verified
[2020-10-19 09:25 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 03:00:02 2025 UTC |
Description: ------------ 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() { P::test(); call_user_func('P::test'); call_user_func(array('P', 'test')); } public function run() { P::test(); call_user_func('P::test'); call_user_func(array('P', 'test')); } } C::runStatic(); $c = new C(); $c->run(); Expected result: ---------------- Console output: PPPPPP Actual result: -------------- Console output: PPPPCC