# RfC: rethink OO inheritance strictness

- Thread: https://externals.io/message/25100
- Original archive: https://news-web.php.net/php.internals/25100
- Started by Soenke Ruempler on 2006-08-02T06:36:48+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #25100 — Soenke Ruempler — 2006-08-02T06:36:48+00:00

URL: https://externals.io/message/25100#25100

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:

> 
> > […]
> 
> 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
