Document that interfaces can be extended + usage example

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@264647 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Kalle Sommer Nielsen 2008-08-11 22:16:23 +00:00
parent b0c200f9e6
commit 2e5dc81daa

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<!-- $Revision: 1.11 $ -->
<sect1 xml:id="language.oop5.interfaces" xmlns="http://docbook.org/ns/docbook">
<title>Object Interfaces</title>
<para>
@ -30,6 +30,12 @@
it would cause ambiguity.
</para>
</note>
<note>
<para>
Interfaces can be extended like classes using the <literal>extend</literal>
operator.
</para>
</note>
</sect2>
<sect2 xml:id="language.oop5.interfaces.examples">
&reftitle.examples;
@ -83,6 +89,46 @@ class BadTemplate implements iTemplate
]]>
</programlisting>
</example>
<example xml:id="language.oop5.interfaces.examples.ex2">
<title>Extendable Interfaces</title>
<programlisting role="php">
<![CDATA[
interface a
{
public function foo();
}
interface b extends a
{
public function baz(Baz $baz);
}
// This will work
class c implements b
{
public function foo()
{
}
public function baz(Baz $baz)
{
}
}
// This will not work and result in a fatal error
class d implements b
{
public function foo()
{
}
public function baz(Foo $foo)
{
}
}
]]>
</programlisting>
</example>
<simpara>
See also the <link linkend="language.operators.type">instanceof</link>
operator.