Req #68568 [Nab]: Calling static method causing to call non static method with the same name
Edit report at https://bugs.php.net/bug.php?id=68568&edit=1
ID: 68568
User updated by: walid dot wah at gmail dot com
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 i'm calling
it from a different class which inherits the current class parent and that's why i reported it
Previous Comments:
------------------------------------------------------------------------
[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
Thread (4 messages)