# RfC: rethink OO inheritance strictness

- Thread: https://externals.io/message/25150
- Original archive: https://news-web.php.net/php.internals/25150
- Started by Matthias Pigulla on 2006-08-02T21:09:28+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #25150 — Matthias Pigulla — 2006-08-02T21:09:28+00:00

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

> From: Soenke Ruempler [mailto:ruempler@topconcepts.com] 

> BUT let derived constructors change parameters
> a) as constructors are never called from the parent, but 
> optionally from a child class, it's completely valid IHMO 
> b) constructors are usally not used in object aggregation / 
> setters, but called only _ONCE_ at object creation => the 
> creating code knows the exact (sub-)class and it's constructor.

You gave the reason why the restrictions don't apply for constructors
(also not in PHP) and probably nobody will change that for "academic
reasons" :)

Constructors are the special case in OOP as you can call constructors
only by instantiating classes. When using them you always refer to a
concrete class and never have to deal with polymorphic subtypes (of
course constructors can be overloaded in languages that support it). 

Thus constructors are a place where differences between subtypes tend to
pile up so that the LSP holds for the rest of the inherited methods.

If you *want* to enforce constructor signatures PHP allows for defining
them in interfaces which makes no sense from the academic pov, but may
be useful when using the PHP feature of "new $classname($arg)" where you
want to make sure first that "$classname instanceof
ISomehowConstructable" (where instanceof must take a string as the first
operand and work accordingly).

Regards,
Matthias
