Req #68568 [Nab]: Calling static method causing to call non static method with the same name

From: Date: Tue, 09 Dec 2014 19:03:11 +0000
Subject: Req #68568 [Nab]: Calling static method causing to call non static method with the same name
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188981@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68568&edit=1 ID: 68568 Updated by: requinix@php.net Reported by: walid dot wah at gmail dot com Summary: Calling static method causing to call non static method with the same name Status: Not a bug Type: Feature/Change Request Package: Class/Object related Operating System: LINUX ARCHLINUX PHP Version: 5.6.3 Block user comment: N Private report: N New Comment: > the problem that i'm not calling the method statically for the current object True. > i'm calling it from a different class True. > which inherits the current class parent Irrelevant. delete() was inherited so the method is defined. It's a static call because the two classes are not directly related. Not a bug. Previous Comments: ------------------------------------------------------------------------ [2014-12-09 13:15:30] walid dot wah at gmail dot com the problem that i'm not calling the method statically for the current object i'm calling it from a different class which inherits the current class parent and that's why i reported it ------------------------------------------------------------------------ [2014-12-08 19:00:06] requinix@php.net 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 PHP allows you to call a non-static method statically but will warn about it with an E_DEPRECATED. http://3v4l.org/lsngY ------------------------------------------------------------------------ [2014-12-08 14:48:53] walid dot wah at gmail dot com Description: ------------ calling a non existed static method is causing to call the shared parents' non static method Test script: --------------- <?php class Magic { public function delete() { echo "OMG CALLED!!".PHP_EOL; } }; class EmptyClass extends Magic { }; class MethodTest extends Magic { public function omg() { EmptyClass::delete(); } }; $obj = new MethodTest; $obj->omg(); ?> Expected result: ---------------- PHP Fatal error: Call to undefined method EmptyClass::delete() Actual result: -------------- it calls the non static inherited delete() method! ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68568&edit=1

« previous php.bugs (#188981) next »