|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-09-08 09:34 UTC] wkonkel at gmail dot com
Description: ------------ When a static function is called in the scope of an extended class, the static function still thinks it's being called in the scope of the base class. I found a similar bug at http://bugs.php.net/bug.php?id=30828 which was fixed in 5.0.5, but the problem still remains. Reproduce code: --------------- <? class baseClass { static function do_get_class() { return get_class(); } static function do_backtrace() { $backtrace = debug_backtrace(); return $backtrace[0]['class']; } } class extendedBaseClass extends baseClass { } echo extendedBaseClass::do_get_class() . "<br>"; echo extendedBaseClass::do_backtrace() . "<br>"; ?> Expected result: ---------------- extendedBaseClass extendedBaseClass Actual result: -------------- baseClass baseClass PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 21:00:01 2025 UTC |
Hi I've mailed the patch to the internals mailing list, hoping it would be taken into consideration. two new functions have been added: get_scope() and is_static(). Example of solution to the above code after patching: <? class baseClass { static function do_get_scope() { return get_scope(); } static function do_backtrace() { $backtrace = debug_backtrace(); return $backtrace[0]['scope']; } } class extendedBaseClass extends baseClass { } echo extendedBaseClass::do_get_scope() . "<br>"; echo extendedBaseClass::do_backtrace() . "<br>"; ?> Expected result: ---------------- extendedBaseClass extendedBaseClass Actual result: -------------- extendedBaseClass extendedBaseClass