ID: 39664 Updated by: [EMAIL PROTECTED] Reported By: john dot hargrove at sellingsource dot com Status: Bogus Bug Type: Scripting Engine problem Operating System: Gentoo Linux 2.6 kernel PHP Version: 5.2.0 New Comment:
Yes, it's some kind of a left-over of PHP4, but it is necessary to keep BC with the code written with PHP4 in mind. I guess we can/will change it in PHP6, but in 5.x it should remain as it is. Previous Comments: ------------------------------------------------------------------------ [2006-11-28 22:23:53] john dot hargrove at sellingsource dot com Given that this has been around since PHP4, and the manual not being especially clear about it, and there not really having been a clear answer as to why this is considered intended functionality. Is it right to say that this is a side effect of static method calls being resolved at compile time, and not necessarily so much intended as it is a very difficult to fix side effect? I'm not trying to stir the pot, I just want to make sure we're on the same page as far as this being Bogus, as well as anyone else who reads this bug report. ------------------------------------------------------------------------ [2006-11-28 19:13:57] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php ------------------------------------------------------------------------ [2006-11-28 19:03:04] john dot hargrove at sellingsource dot com Description: ------------ PHP5 allows you to invoke a non-static method as static if you have E_STRICT disabled through the Class::Method() syntax which is intended functionality. I believe this bug may actually be a throwback to PHP4 functionality, but it results in funky error reporting in PHP5. If you make a static call to a non-static method, from an instance of another class, the $this variable is in scope from the calling instance. This breaks visibility and scope rules. Note that I saw all the PHP4 bug reports for this marked as bogus for reasons that made sense, but did not see a PHP5 bug marked similarly. The only reason I can see for this is compatibility? Also of note is that the method is aware of being out of the context of an object if called from the global scope. This only occurs from the context of an object (which makes sense). Reproduce code: --------------- <?php class A { private $private_var; public function Tester() { echo $this->private_var; } } class B { public function TesterBlah() { A::Tester(); } } $b = new B(); $b->TesterBlah(); ?> Expected result: ---------------- Fatal error: Using $this when not in object context in /root/bug/test.php on line 8 Actual result: -------------- Notice: Undefined property: B::$private_var in /root/bug/test.php on line 8 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39664&edit=1