So ganz ohne Type-Hints find' ich es schon übel um ehrlich zu sein.
Was echt schön wäre, wäre die Möglichkeit, das interface nachträglich restriktiver zu machen. Also aus
|
Quellcode
|
1
2
3
4
|
interface CreatureInterface
{
public function fulfills(ConditionInterface $condition): bool;
}
|
das hier zu machen:
|
Quellcode
|
1
2
3
4
|
interface HumanInterface extends CreatureInterface
{
public function fulfills(HumanConditionInterface $condition): bool;
}
|
oder um den anderen Weg zu gehen, aus
|
Quellcode
|
1
2
3
4
|
interface ConditionInterface
{
public function fulfills(Creature $creature): bool;
}
|
das hier machen zu können
|
Quellcode
|
1
2
3
4
|
interface HumanConditionInterface extends ConditionInterface
{
public function fulfills(Human $human): bool;
}
|
Da Human das Creature interface implementiert, wäre das interface der HumanCondition lediglich restriktiver, aber in gewisser Weise ja immer noch erfüllt. Aber ich glaub es gibt keine Sprache die das erlaubt, oder irre ich mich da?