

Adding Extension Methods to PHP - cdmckay
http://cdmckay.org/blog/2010/04/23/adding-extension-methods-to-php/

======
mattw
As he points out in the article, unlike .NET extension methods, this (clever)
technique requires classes to inherit from a special superclass before you can
add extension methods to them. If you're able to change a class' inheritance
that way, why not add the methods directly to it?

This falls squarely into my "neat idea, no practical use" category, unless
someone can enlighten me with a use case...

~~~
Myrth
One practical use: you want the core files to be easily upgradable by
overwriting over old files, without loosing the customizations.

EDIT: Which means it's useful technique for app developers to allow easy
customizations by others.

EDIT2: By example: Magento's framework is able to add or CHANGE existing
methods without updating core files, which was one of the strongest reasons
for its great success despite various shortcomings.

~~~
mattw
Interesting. Thanks!

