Edit report at http://bugs.php.net/bug.php?id=52969&edit=1
ID: 52969 Comment by: + at ni-po 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: @jesse: That comment was completely unnecessary. @all: I couldn't find any documentation on what a bogus bug is. Could somebody tell (or link)? Thanks. Previous Comments: ------------------------------------------------------------------------ [2010-10-04 20:07:18] cataphr...@php.net Yes, perhaps this feature ought to be removed, but the place to discuss it is the internals mailing list. In any case, it certainly wouldn't be removed from PHP 5.3, only trunk, as it would be a breaking change. ------------------------------------------------------------------------ [2010-10-04 19:43:23] jesse_7254 at yahoo dot com A bogus bug is a bogus bug, no matter the opinion of StackOverflow amateurs. ------------------------------------------------------------------------ [2010-10-03 18:28:51] + at ni-po dot com @ircmaxell: No, you don't need to modify all your code and add that line. Or at least you don't need to do so if you don't already have this line in every method: if (!isset($this)) throw new LogicException('Called non-static method statically'); In PHP you can't rely on $this being set. But still you do, because an unset $this is a real edge case. But I still do think that this feature *is* a bug and shall be removed. It is absolutely illogical that $this isn't instanceof self. ------------------------------------------------------------------------ [2010-10-03 00:37:43] gnuffo1 at gmail dot com 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? ------------------------------------------------------------------------ [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... ------------------------------------------------------------------------ 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