NYCPHP Meetup

NYPHP.org

[nycphp-talk] Multi-Inheritance in PHP 5

George Schlossnagle george at omniti.com
Sun Oct 10 20:00:17 EDT 2004


On Oct 10, 2004, at 6:14 PM, csnyder wrote:

> The example was simplistic of course.
>
> Let's say football::kickBall() is a complex method that needs to be
> updated every time some external API changes (welcome to the world of
> .NET, right?).
>
> You have fifteeen diverse classes that you want to add kickBall()
> functionality to.
>
> Unless you want to copy-and-paste through fifteen source files every
> time the damn football API changes, you have to jump through some kind
> of hoop:
>
> 1) you refactor all of your classes to extend the football class
> 2) you implement football::kickBall() as a static method
> 3) you use classkit_method_copy()

4) you can use the delegation pattern and delegate that method to the 
class that implements it.  I don't see any real benefit for using 
classkit() for this.  When using it to emulate multiple inheritance, 
you lose all the is_a() information on a class, which is one of the 
major benefits of inheritance over delegation.

George




More information about the talk mailing list