note 72149 deleted from language.oop5.interfaces by felipe
| From: | felipe@php.net | Date: | Tue, 11 Dec 2007 01:02:07 +0000 |
| Subject: | note 72149 deleted from language.oop5.interfaces by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133348@lists.php.net to get a copy of this message | ||
Note Submitter: Dave
----
vbolshov at rbc dot ru:
<?php
error_reporting(E_ALL | E_STRICT);
interface i {
function f($arg);
}
class c implements i {
function f($arg, $arg2 = null)
{
}
}
?>
> PHP doesn't generate a Fatal Error in this case, although
> the method declaration in the class differs from that in the
> interface. This situation doesn't seem good to me: I'd
> prefer classes being strictly bound to their interfaces.
It wouldn't make sense to prevent this as you can *always* pass more arguments to a function
than it requires, and the function can still use func_get_args() & co. to get them if it wants.
e.g.
<?php
class c implements i {
function f($arg)
{
$args2 = (func_num_args() >= 2 ? func_get_arg(2) : null);
}
}
?>