Req #68568 [Opn->Nab]: Calling static method causing to call non static method with the same name
| From: | requinix@php.net | Date: | Mon, 08 Dec 2014 19:00:07 +0000 |
| Subject: | Req #68568 [Opn->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-188965@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: Open
+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:
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
Previous Comments:
------------------------------------------------------------------------
[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