Re: function overriding and class inheritance
| From: | Paweł Stradomski | Date: | Tue, 29 May 2007 23:06:02 +0000 |
| Subject: | Re: function overriding and class inheritance | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-29907@lists.php.net to get a copy of this message | ||
Emil Ivanov wrote:
> class C1 {}
> class C2 extends C1 {}
>
> abstract class Work1 {
> public function f1(C1 $c);
> }
>
> class Work2 extends Work1 {
> public function f1(C2 $c);
> }
Strange thing is I don't get any error message here, although there definitely
should be one.
PHP 5.2.2-pl1-gentoo (cli) (built: May 21 2007 12:36:57)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
And regarding your code - it should work the other way round - you can only
loose preconditions and tighten postconditions, which is a result of
substituion rule already mentioned by Stanislav.
--
Paweł Stradomski