note 72149 added to language.oop5.interfaces
| From: | Dave at osu1 dot php dot net | Date: | Thu, 04 Jan 2007 18:15:45 +0000 |
| Subject: | note 72149 added to language.oop5.interfaces | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121294@lists.php.net to get a copy of this message | ||
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);
}
}
?>
----
Server IP: 85.116.5.111
Probable Submitter: 88.111.43.168
----
Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php
Edit -- https://master.php.net/note/edit/72149
Del: integrated -- https://master.php.net/note/delete/72149/integrated
Del: useless -- https://master.php.net/note/delete/72149/useless
Del: bad code -- https://master.php.net/note/delete/72149/bad+code
Del: spam -- https://master.php.net/note/delete/72149/spam
Del: non-english -- https://master.php.net/note/delete/72149/non-english
Del: in docs -- https://master.php.net/note/delete/72149/in+docs
Del: other reasons-- https://master.php.net/note/delete/72149
Reject -- https://master.php.net/note/reject/72149
Search -- https://master.php.net/manage/user-notes.php