Jonathan Bond-Caron wrote:
On Fri Aug 20 06:54 AM,  Jean-Sébastien H.  wrote:
No it's wrong.

A Child is a Parent so we must be able to pass a Parent to the method
equals() defined on Child.

The declaration of the parent functions must always be valid in the children.


Maybe my OO theory is wrong but I was under the impression that the only way to 
enforce a signature is using an abstract class or interface?

php allows it:
PHP 5.2.13 with Suhosin-Patch 0.9.7 (cli) (built: Aug 14 2010 16:39:00) PHP 5.3.99-dev (cli) (built: Aug 20 2010 07:45:44)

<?php

 class P { function dot(Child $o) { echo "."; } }
 class Child extends P { function dot(P $o) { echo "."; } }

 $t = new Child;
 $t->dot( new P );
$t->dot( new Child ); class P2 { function dot (P2 $o) { echo "."; } } class Child2 extends P2 { function dot(Child $o) { echo "."; } }

 $t = new Child;
 $t->dot( new P );
$t->dot( new Child );
?>

perhaps you mean..

  $t = new Child2;
  $t->dot( new P2 );
  $t->dot( new Child2 );

:)

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to