note 113793 added to language.oop5.interfaces
| From: | tkostantinov | Date: | Mon, 02 Dec 2013 22:58:20 +0000 |
| Subject: | note 113793 added to language.oop5.interfaces | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197726@lists.php.net to get a copy of this message | ||
Implementation must be strict, subtypes are not allowed.
"The class implementing the interface must use the EXACT SAME METHOD SIGNATURES as are defined
in the interface. Not doing so will result in a fatal error. "
<?php
interface I
{
function foo(stdClass $arg);
}
class Test extends stdClass
{
}
class Implementation implements I
{
function foo(Test $arg)
{
}
}
?>
Result:
Fatal error: Declaration of InterfaceImplementation::foo() must be compatible with I::foo(stdClass
$arg) in test.php on line XY
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/language.oop5.interfaces.php
Edit -- https://master.php.net/note/edit/113793
Del: integrated -- https://master.php.net/note/delete/113793/integrated
Del: useless -- https://master.php.net/note/delete/113793/useless
Del: bad code -- https://master.php.net/note/delete/113793/bad+code
Del: spam -- https://master.php.net/note/delete/113793/spam
Del: non-english -- https://master.php.net/note/delete/113793/non-english
Del: in docs -- https://master.php.net/note/delete/113793/in+docs
Del: other reasons-- https://master.php.net/note/delete/113793
Reject -- https://master.php.net/note/reject/113793
Search -- https://master.php.net/manage/user-notes.php