RE: [PHP-DEV] RfC: rethink OO inheritance strictness
| From: | Jared Williams | Date: | Fri, 21 Jul 2006 11:20:00 +0000 |
| Subject: | RE: [PHP-DEV] RfC: rethink OO inheritance strictness | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-24821@lists.php.net to get a copy of this message | ||
> Hi (Marcus),
>
> unfortunately I'm not very happy with the direction OO
> strictness takes
> in PHP. I'm sure I'm not alone and many people second this feeling.
>
>
> Precisely, let's have a look at the following:
>
> mike@honeybadger:~/build/php-5.2-debug$ cli
> -d"error_reporting=8191" -r 'class c{function f(){}} class d
> extends c{function f($a){}}'
> Strict Standards: Declaration of d::f() should be compatible
> with that of c::f() in Command line code on line 1
>
> mike@honeybadger:~/build/php-unicode-debug$ cli
> -d"error_reporting=8191" -r 'class c{function f(){}} class d
> extends c{function f($a){}}'
> Fatal error: Declaration of d::f() must be compatible with
> that of c::f() in Command line code on line 1
>
>
> I *really* think that this enforcements are no good idea and
> I _beg_ you that we leave this "area" to interfaces.
>
Not sure why this is necessary, why doesn't
Class C
{
function f() { }
}
Class D
{
private $c;
function __construct(C $c) { $this->c = $c; }
function f($a) { }
}
work, with PHP's duck typing?
Jared