postmas...@colder.ch wrote:
----- "Nathan Rixham" <nrix...@gmail.com> wrote:

   class Point2DManager {
     public function distanceBetween( Point2D $p1 , Point2D $p2 ) {};
   }
   class Point3DManager extends Point2DManager {
     public function distanceBetween( Point3D $p1 , Point3D $p2 ) {};
   }


This is incorrect. Any class extending Point2DManager should be able to provide 
at least as much functionality as the parent class. In other words, it should 
not tighten the pre-conditions.
In your case, Point3dmanager will no longer be able to handle 2dpoints, which 
is a mistake.

lol, got it - confused myself for a bit there! yes agreed..

incorrect:
  class Parent { function equals(Parent $o) {} }
  class Child extends Parent { function equals(Child $o) {} }

correct:
  class Parent { function equals(Child $o) {} }
  class Child extends Parent { function equals(Parent $o) {} }

sorry about the noise,

nathan

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

Reply via email to