Hi,
just forwarding this (with some little correction in the sample code) to
the dev list as the discussion seems not to be finished ;)
The only thing I don't like is the BC breakage from 5.1 => 5.2. Maybe an
idea of a strict mode like Lukas mentioned is some alternative.
Richard Lynch <mailto:ceo@l-i-e.com> wrote on Tuesday, August 01, 2006
8:52 PM:
> On Fri, July 21, 2006 6:05 am, Soenke Ruempler wrote:
>> 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 ;)
>
> Errrr. Isn't that what an interface is supposed to be for?...
For object aggregation it is - yes.
> To define a "pattern" which implementations much adhere to?
Checkout the template method pattern.
Or in general, hooks for subclasses:
class A {
public function doSomething() {
$this->someHook('blah');
}
protected function someHook($someString) { // Empty hook
}
}
class B extends A {
protected function someHook($someString) {
echo $someString;
}
}
$c = new B;
$c->doSomething();
Now A relies on B's correct definition of method someHook().
> Why are you cramming that into a class definition, when no other
> language does that?
Other languages have parameter polymorphism where you can declare the
same method several times with different parameters. PHP doesn't.
-soenke