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:
Sherif Ramadan 2012-08-30 03:17:16 +00:00
parent 773e4a944a
commit 8ce1555616

View file

@ -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>