#19376 [Opn->Dup]: Class inheritance problem

From: Date: Fri, 13 Sep 2002 04:45:10 +0000
Subject: #19376 [Opn->Dup]: Class inheritance problem
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-19288@lists.php.net to get a copy of this message
ID: 19376 Updated by: alan_k@php.net Reported By: shamim@poetryunlimited.com -Status: Open +Status: Duplicate Bug Type: Scripting Engine problem Operating System: Linux/Windows NT 4 PHP Version: 4.2.2 New Comment: dupe of http://bugs.php.net/bug.php?id=12622 I'm not sure if it will be fixed.. nobody has commented on 12622 It may be worth posting a question on php-dev, just to get a more definitive answer... Previous Comments: ------------------------------------------------------------------------ [2002-09-12 23:33:07] shamim@poetryunlimited.com Please see bug report http://bugs.php.net/bug.php?id=19384 for further details. You say that static method calls take $this with them? But how can they take them OUT OF the current class? Which $this is in effect in the class of the static method?? What happens if the static method call has it's own variable of the same name or function? I did not see anywhere in the documentation that states that static method calls take $this with them, even out of the current class. I'm confused. How can an object of type A call a static method of class B and have $this taken with it??? This violates class scoping as far as I understand it. I don't see how this would enable multiple inheritance, especially since PHP is supposed to be single inheritance anyway. You're saying this isn't a bug? Isn't that like someone telling me a year ago that &new was necessary and it wouldn't be fixed because it was a feature, and now Zend 2.0 will do it by default??? Suggestions? Where should I take this issue? And where do I find the documentation that clearly describes the expected behavior. Thanks. ------------------------------------------------------------------------ [2002-09-12 23:25:15] alan_k@php.net apologies for the brush of effect. if you could mark the first instance where you think the behaviour is unexpected it would help. I assume you realize that all static method calls take with them the '$this' value of the calling objects (always). It's a feature, and It has a few usefull side effects, like making a sudo multiple inheritance possible... ------------------------------------------------------------------------ [2002-09-12 23:11:42] shamim@poetryunlimited.com Thank you for explaining to me that I did not explain my problem clearly. My question was rhetorical. Having been a systems engineer for the past 15 years, I know that this is an error. I was merely trying to be polite and draw your attention to it. I do not appreciate the unwarranted brush off, nor do I appreciate being told that this was a support request - I don't want to know how to do something. I want something fixed. Thanks. Hopefully you can correct this or alert Zeev that there is a problem in calling static methods from within a class instance when that static method contains the original class as part of its hierarchy. It allows the $this context to be passed from an object to a static method and back, violating class scoping. Please see the other bug report for a more clearer example. Shamim Islam BA BSc P.S. I will be posting this as many places as I can find a forum until someone understands that class scoping is being violated willy nilly. ------------------------------------------------------------------------ [2002-09-12 18:15:37] alan_k@php.net Sorry, but the bug system is not the appropriate forum for asking support questions. Your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php Thank you for your interest in PHP. I cant see any unexpected behaviour here, - however it would help *alot* if you made a shorter example... ------------------------------------------------------------------------ [2002-09-12 13:07:33] shamim@poetryunlimited.com when an object of type test3 calls test3::showMe is the only time this chain should function as displayed, I believe. Thanks. ------------------------------------------------------------------------ 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/19376 -- Edit this bug report at http://bugs.php.net/?id=19376&edit=1

« previous php.bugs (#19288) next »