|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-09-05 12:34 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 23:00:01 2025 UTC |
Description: ------------ Within methods the $this variable seems to leak into the scope of statically called methods. Even when the called static function is in an entirely different class. It only happens when the statically called method is not explicitly defined as static. Reproduce code: --------------- <?php class instance{ var $test = 'test'; function do_thing(){ static_class::func(); } } // happens with and without the abstract keyword abstract class static_class{ function func(){ echo 'output: '.$this->test.'<br/>'; echo 'class: '.get_class( $this ).'<br/>'; echo 'How did I get here?<br/>'; } } $instance = new instance(); $instance->do_thing(); ?> Expected result: ---------------- A warning telling me I shouldn't use $this in a static scope. Or just a notice saying $this is not defined / not an object. Actual result: -------------- output: test<br/> class: instance<br/> How did I get here?<br/>