all,
previously, on this list and elsewhere, i have raised the topic of
interface inheritance, lamenting that php is void of the feature.
to my utter amazement i discovered that php does in fact support
interface inheritance, reading through some of Marcus Boergers'
code in SPL.. i noticed RecursiveIterator extends Iterator, which
is an internal interface (part of the zend engine), so i thought to
myself, perhaps only internal interfaces can be extended, but
then a quick test proved my suspicions wrong. in fact, interfaces
can even extend multiple parent interfaces, just like java (*ducks*).
here is the sample code so you can see for yourself:
<?php
interface Somethingable {
public function doSomething();
}
interface Crazyfiable {
public function getCrazy();
}
interface Extendable extends Somethingable, Crazyfiable {
public function extend();
}
class SuperClass implements Extendable {
public function doSomething() {
echo 'i did something ..' . PHP_EOL;
}
public function extend() {
echo 'i extended something..' . PHP_EOL;
}
public function getCrazy() {
echo 'im a crazy bastard now!' . PHP_EOL;
}
}
/*
* TEST HERE
*/
$sc = new SuperClass();
$sc->doSomething();
$sc->extend();
$sc->getCrazy();
?>
and the output:
[EMAIL PROTECTED] /usr/share/php5/splExperiment/tests $ php
testInterfaceInheritence.php
i did something ..
i extended something..
im a crazy bastard now!
i for one am quite excited. heres to happy adventures in oop-land w/ php!
-nathan