Will pay for feature add

php.internals

Sam Barrow

18 years ago
If anyone here is experienced enough to help me, I will pay for a patch to allow for multiple class inheritance (class D extends A, B, C) against PHP 5.3 CVS. Or if you can just help me get started on writing it, I'm sure I could finish myself. I'm just stuck at the basic zend class declaration functions.

Andi Gutmans

18 years ago
Hi Sam, When we designed PHP 5 we intentionally went down the Java-like route of multiple interfaces and single inheritance. This was a major design decision and not something we want to change. From the languages which do support it like C++ you can see how many problems it creates and the workarounds the language needs to support, hence why Java went down a different route. The features you should be looking at are interfaces, single inheritance, and __call(). If there are special needs you have which require some additional functionality you may want to look at building some proxy class in C as a PHP extension but I have yet to see many situations where that's really needed. Andi
> -----Original Message----- > From: Sam Barrow [mailto:sam@sambarrow.com] > Sent: Tuesday, December 25, 2007 12:23 PM > To: PHP Developers Mailing List > Subject: [PHP-DEV] Will pay for feature add > > If anyone here is experienced enough to help me, I will pay for a
patch

Sam Barrow

18 years ago
I understand that this functionality would not be implemented in the PHP release, I was just going to try to get it going for myself, so that I could have my own patch and compile from source when needed. On Tue, 2007-12-25 at 17:39 -0800, Andi Gutmans wrote:

Sara Golemon

18 years ago
Sam Barrow wrote:
> If anyone here is experienced enough to help me, I will pay for a patch > to allow for multiple class inheritance (class D extends A, B, C) > against PHP 5.3 CVS. Or if you can just help me get started on writing > it, I'm sure I could finish myself. I'm just stuck at the basic zend > class declaration functions.
runkit could probably implement this using some composting rules... It doesn't have all the required pieces at the moment, but it's got most of 'em... If you don't care about default values or interfaces, you can probably fill in the rest using ReflectionClass.... -Sara <?php class Foo extends A { } extend_class_from_additional_classes('Foo', array('B','C')); function extend_class_from_additional_classes($destClass, Array $extra) { foreach($extra as $class) { // Transpose methods foreach(get_class_methods($class) as $method) { if (!method_exists($destClass, $method)) { runkit_method_copy($destClass, $method, $class); } } // Transpose Properties // Transpose Constants // Transpose Interfaces /* These bits need a couple more runkit features to make work, but only a couple... */ }