Edit report at http://bugs.php.net/bug.php?id=52969&edit=1
ID: 52969
Comment by: gnuffo1 at gmail dot com
Reported by: ircmaxell at yahoo dot com
Summary: This defined in static call from within another
class
Status: Bogus
Type: Bug
Package: Class/Object related
Operating System: linux
PHP Version: 5.3.3
Block user comment: N
New Comment:
Does it really mean you must put that line in every method? It's not
like you ever accidentally had a problem with it before is it?
Previous Comments:
------------------------------------------------------------------------
[2010-10-02 21:05:25] ircmaxell at yahoo dot com
Close it if you wish, but I do honestly believe this is a major bug...
This means that you cannot trust that $this is an instance of the class
it's
used in. So does that mean that we must add:
($this instanceof self) or throw new Exception('called from another
class');
to all of our methods?
Remember, any sufficiently advanced bug is indistinguishable from a
feature (no
matter if it is documented or not). But don't be afraid to call it what
it
really is... Just because it's documented, doesn't mean it isn't a
bug...
Again, IMHO...
------------------------------------------------------------------------
[2010-10-02 20:07:43] [email protected]
Closing as bogus. As you have pointed out, this is documented.
------------------------------------------------------------------------
[2010-10-02 15:51:04] gnuffo1 at gmail dot com
It has been pointed out to me that this is actually documented:
http://us2.php.net/manual/en/language.oop5.basic.php
Under example 2 and specifically the lines:
$b = new B();
$b->bar();
------------------------------------------------------------------------
[2010-10-02 15:33:50] php at rwasmus dot nl
Can reproduce across architectures & versions from 5.2.9 onward, IMHO
opinion, just an E_STRICT error in between is understating the scripters
design flaw. Some existing code may rely on it, so a real fix may hurt
some packages, but at the very least I'd increase the errors severity.
------------------------------------------------------------------------
[2010-10-02 15:33:00] ircmaxell at yahoo dot com
Oh, and $this is an object of class Test2 within Test1::getName()...
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=52969
--
Edit this bug report at http://bugs.php.net/bug.php?id=52969&edit=1