Hello all, I hope the subject is not misleading. Please look at the following code:
<?php class A { } class B extends A { } interface C { function foo(A $a); } class D implements C { public function foo(B $b) { } } This code produces a "Fatal error: Declaration of D::foo() must be compatible with C::foo(A $a) in /xyz/inheritance.php on line 10" (see http://3v4l.org/l2M0f). I don't get the reason for that behavior (and I could not find any documentation about that, at least not at http://php.net/manual/en/language.oop5.typehinting.php). I have already found https://bugs.php.net/bug.php?id=42330 but Derick's response does not help me and the linked file cannot be accessed anymore. I'd say that it is absolutely legal to define a more specialized type in a child or implementing class, or would this have any bad side effects? Thanks and best regards Christian