From: francois dot levasseur at gmail dot com Operating system: Gentoo Linux (2.6) PHP version: 5.1.1 PHP Bug Type: Class/Object related Bug description: Call a public function like a static function with a bogus $this var
Description: ------------ I can call a public function like a static function from another class. The variable "$this" refers to the caller. Reproduce code: --------------- <?php class testA{ private $var; public function __construct(){ $this->var = 'Hello'; } public function getVar(){ return $this->var; } public function test(){ return $this->getVar(); } } class testB{ public function test(){ // Should not work! echo testA::test(); } } $myTestB = new testB(); $myTestB->test(); ?> Expected result: ---------------- Error because class testB called a static function that does not exists. Actual result: -------------- Call the static method "getVar()" in class testB. $this refers to testB. PHP Fatal error: Call to undefined method testB::getVar() in /var/www/svnhome/kronos/kronoscrm/test.php on line 15 Fatal error: Call to undefined method testB::getVar() in /var/www/svnhome/kronos/kronoscrm/test.php on line 15 -- Edit bug report at http://bugs.php.net/?id=35831&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35831&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35831&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35831&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=35831&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35831&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35831&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35831&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35831&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35831&r=support Expected behavior: http://bugs.php.net/fix.php?id=35831&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35831&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35831&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35831&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35831&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35831&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35831&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35831&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35831&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35831&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35831&r=mysqlcfg