mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added change log entry for is_subclass_of() behavior change using interfaces and new example to demonstrate. Fixes Bug #62969.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@327374 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
773e4a944a
commit
8ce1555616
1 changed files with 58 additions and 0 deletions
|
@ -76,6 +76,13 @@
|
|||
Added <parameter>allow_string</parameter> parameter
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>5.3.7</entry>
|
||||
<entry>
|
||||
Added support for <parameter>class_name</parameter> to work with
|
||||
intrefaces
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>5.0.3</entry>
|
||||
<entry>
|
||||
|
@ -141,6 +148,57 @@ if (is_subclass_of('WidgetFactory_Child', 'WidgetFactory')) {
|
|||
yes, $WFC is a subclass of WidgetFactory
|
||||
no, $WF is not a subclass of WidgetFactory
|
||||
yes, WidgetFactory_Child is a subclass of WidgetFactory
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>is_subclass_of</function> using interface example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Define the Interface
|
||||
interface MyInterface
|
||||
{
|
||||
public function MyFunction();
|
||||
}
|
||||
|
||||
// Define the class implementation of the interface
|
||||
class MyClass implements MyInterface
|
||||
{
|
||||
public function MyFunction()
|
||||
{
|
||||
return "MyClass Implements MyInterface!";
|
||||
}
|
||||
}
|
||||
|
||||
// Instantiate the object
|
||||
$my_object = new MyClass;
|
||||
|
||||
// Works since 5.3.7
|
||||
|
||||
// Test using the object instance of the class
|
||||
if (is_subclass_of($my_object, 'MyInterface')) {
|
||||
echo "Yes, \$my_object is a subclass of MyInterface\n";
|
||||
} else {
|
||||
echo "No, \$my_object is not a subclass of MyInterface\n";
|
||||
}
|
||||
|
||||
// Test using a string of the class name
|
||||
if (is_subclass_of('MyClass', 'MyInterface')) {
|
||||
echo "Yes, MyClass is a subclass of MyInterface\n";
|
||||
} else {
|
||||
echo "No, MyClass is not a subclass of MyInterface\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Yes, $my_object is a subclass of MyInterface
|
||||
Yes, MyClass is a subclass of MyInterface
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
Loading…
Reference in a new issue