#30355 [Opn->Asn]: Weird Behaviour calling non-static method statically

From: Date: Fri, 08 Oct 2004 06:55:40 +0000
Subject: #30355 [Opn->Asn]: Weird Behaviour calling non-static method statically
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-67267@lists.php.net to get a copy of this message
ID: 30355 Updated by: derick@php.net Reported By: info at rhalff dot com -Status: Open +Status: Assigned Bug Type: Zend Engine 2 problem Operating System: linux PHP Version: 5.0.2 -Assigned To: +Assigned To: helly New Comment: Marcus, can you explain why there is no bug here? Previous Comments: ------------------------------------------------------------------------ [2004-10-07 22:51:52] info at rhalff dot com Description: ------------ I think the behaviour below is allready known and it can be fixed declaring the method 'static', however I still think this is a bug. The script should fail instead of continuing incorrect behaviour. Related to Bug #9005, #12622, #20089, #25220, #29206 Because $this behaviour was allready there in 2001, I thought $this would be a good reminder $this feature is still present in 5.0.2 Reproduce code: --------------- <?php class A { public function test() { $this->setValue('huh?'); } public function test2() { $this->nonExistent(); } } class B { public function test() { A::test(); } public function setValue($v) { echo "$v"; } public function test2() { A::test2(); } } $B = new B; $B->test(); $B->test2(); ?> Expected result: ---------------- script should fail, cannot call a non-static method statically. Actual result: -------------- huh? Fatal error: Call to undefined method B::nonExistent() in /var/www/hosts/gedicht.nu/docs/static/test.php on line 12 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30355&edit=1

« previous php.bugs (#67267) next »