# Will pay for feature add

- Thread: https://externals.io/message/34250
- Original archive: https://news-web.php.net/php.internals/34250
- Started by Sam Barrow on 2007-12-25T20:23:24+00:00
- Messages: 4
- 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

---

## #34250 — Sam Barrow — 2007-12-25T20:23:24+00:00

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

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.

---

## #34252 — Andi Gutmans — 2007-12-26T01:39:02+00:00

URL: https://externals.io/message/34250#34252 · In reply to: #34250

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
> 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.

---

## #34253 — Sam Barrow — 2007-12-26T02:53:51+00:00

URL: https://externals.io/message/34250#34253 · In reply to: #34252

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.


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

---

## #34254 — Sara Golemon — 2007-12-26T04:06:10+00:00

URL: https://externals.io/message/34250#34254 · In reply to: #34250

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... */
}
