*STILL* No Multiple Inheritance in PHP!

This is maddening. There have been requests for multiple inheritance in PHP since I started using it in mid 1999. Of course, in mid-1999, I didn’t really care. There wasn’t much written in PHP that was any good, so I was writing little scripts of glue code to tie pieces of HTML together and the like. I wasn’t working on anything big. Now, like 8 years later, I *am* working on a big project, and I *need* multiple inheritance, and it’s *still* not there!

Here’s my dilemma: I wrote an extension for Moodle 1.5.x. Not that it’s really important, but I implemented a new assignment type geared toward Computer Science departments. The current release of Moodle is 1.8. In looking at a new built-in assignment type in 1.8, I’m noticing that it does roughly 85% of what I need it to do. Further, in looking at the code, it appears that the remaining 15% wouldn’t be difficult to implement.

“I’ll just make my assignment type inherit from this new built-in one, write a couple of new methods (the code for which can be ripped almost verbatim from my old 1.5.x code), and I’ll be on my way!”

Wrong. The shiny new built-in assignment type extends the base assignment class, and that’s the whole inheritance story in PHP. Even though 90% of what I need is in that new built-in class, I can’t base my class on it, because *it* already inherits from another class.

Now, I make no claims of *being* a computer scientist, so my question is simply this:

“Am I missing something here, or does it seem moronic to keep debating the usefulness of this particular feature instead of just implementing it?”

For the record, I don’t mean for this to be a rhetorical question. If you have an answer or comment (besides “it’s open source, just implement it yourself”), I’d love to hear it.

Technorati Tags: , , , , , , , ,

Social Bookmarks:

  • samb0057

    I’m thinking of trying to write a patch for PHP to allow this, are you interested?

  • http://m0j0.wordpress.com/ m0j0

    I’m the wrong guy to ask, really. If it was a patch to allow multiple inheritance that was not accepted into the standard language distribution, I wouldn’t be very likely to use it, and even if I were there are plenty of clients where I wouldn’t be allowed to use it. I’m sure there are lots of folks in the PHP community at large who would be interested. I’m sure the Moodle development community would probably like to see it, so I’d start looking for larger groups of people in order to gain momentum behind this idea – assuming there isn’t already some momentum – in which case, I’d try to take advantage of that if at all possible.

    Good luck!!!