----- "Nathan Rixham" <nrix...@gmail.com> wrote: > Chris Stockton wrote: > > Hello, > > > > On Thu, Aug 19, 2010 at 12:33 PM, Nathan Rixham <nrix...@gmail.com> > wrote: > >> Guys, this is going a bit nuts, let's swap all the Foo and Bar's > for a real > >> example - Zeev I've copied the way you specified above. > > > > I think your misunderstanding his position. To summarize my > > understanding: he clearly states that in such a use case a warning > is > > in order, however currently the warning is overly aggressive. I > think > > in general this is a small fish in the pond but I see his point. > > > > Perhaps I am, I think his example was wrong - if it was an example of > > doing it the wrong way and an example which should trigger a warning > then yes I totally agree. > > To clarify, hopefully - given: > > class Point2D {} > class Point3D extends Point2D {} > > the following is incorrect and should raise a (heavy) warning (Zeev's > > example with class names changed for clarity): > > class Point2DManager { > public function distanceBetween( Point3D $p1 , Point3D $p2 ) {}; > } > class Point3DManager extends Point2DManager { > public function distanceBetween( Point2D $p1 , Point2D $p2 ) {}; > } >
No, this is correct. Even though stupid in this case, it is supposed to be correct. > whilst the following is correct, and should not raise any warning: > > 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. > If we're all saying the same thing then great and apologies for the > confusion. > > Best, > > Nathan > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php