Re: RfC: rethink OO inheritance strictness

php.internals

Richard Quadling

20 years ago
Ah. I see the difference. I'm expecting overloading. Hmmm. Even with that though, overloading is the desired effect. On 21/07/06, Soenke Ruempler <ruempler@topconcepts.com> wrote:
> Richard Quadling <mailto:rquadling@googlemail.com> wrote on Friday, July > 21, 2006 12:28 PM: > > > Shouldn't be necessary. As there are 2 different methods, they should > > be allowed different parameter signatures. If you want to extend a > > method but hide original implementation, you can't change the > > parameter signature. I'm on the opposite side of the fence to you it > > seems! > > But that's not the nature of polymorphism and the predictness and > consistency of an API. For example - think of object aggregation: > > public function setBlub(A $a) { > $this->_a = $a; > } > > Now because of my consistent API of class A and all derived classes I > exactly know the methods and parameters, even if B (as child class of A) > is passed to "setBlub()". > > So maybe from your POV it's two different methods (and yes, it IS > *technically*). But from OOP and API design view it is polymorphism and > consistency, if I didn't failed all OOP lessons and design pattern books > ;) > > -soenke >
-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&amp;r=213474731 "Standing on the shoulders of some very clever giants!"

Sönke Ruempler

20 years ago
Richard Quadling <mailto:rquadling@googlemail.com> wrote on Friday, July 21, 2006 1:16 PM:
> Ah. I see the difference. I'm expecting overloading. Hmmm. Even with > that though, overloading is the desired effect.
But PHP has no parameter overloading, only overloading with interceptor methods. IMHO what you do is "misusing" OOP polymorphism as parameter overloading. For clearness of your class interface / public API, why don't you just use another method that accepts other parameters than the parent's one. Another possibilty / workaround is no method parameters in declaration and to use func_get_args(). -soenke

Richard Quadling

20 years ago
Good points. I think I'll leave Michael to answer that. He wants it changed. I'm just saying that overloading would be a valid solution. On 21/07/06, Soenke Ruempler <ruempler@topconcepts.com> wrote:
> Richard Quadling <mailto:rquadling@googlemail.com> wrote on Friday, July > 21, 2006 1:16 PM: > > > Ah. I see the difference. I'm expecting overloading. Hmmm. Even with > > that though, overloading is the desired effect. > > But PHP has no parameter overloading, only overloading with interceptor > methods. IMHO what you do is "misusing" OOP polymorphism as parameter > overloading. For clearness of your class interface / public API, why > don't you just use another method that accepts other parameters than the > parent's one. > > Another possibilty / workaround is no method parameters in declaration > and to use func_get_args(). > > -soenke >
-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&amp;r=213474731 "Standing on the shoulders of some very clever giants!"