From: john dot hargrove at sellingsource dot com Operating system: Gentoo Linux 2.6 kernel PHP version: 5.2.0 PHP Bug Type: Scripting Engine problem Bug description: Invokation of non-static method as static issue
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 bug report at http://bugs.php.net/?id=39664&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39664&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39664&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39664&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39664&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39664&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39664&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39664&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39664&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39664&r=support Expected behavior: http://bugs.php.net/fix.php?id=39664&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39664&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39664&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39664&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39664&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39664&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39664&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39664&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39664&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39664&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39664&r=mysqlcfg