reference/spl/functions/class-implements.xml
60af8c2b746d51c1556cc2ddc4d4163222347b96
...
...
@@ -10,13 +10,13 @@
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
12
<methodsynopsis>
13
-
<type>array</type><methodname>class_implements</methodname>
14
-
<methodparam><type>mixed</type><parameter>class</parameter></methodparam>
13
+
<type class="union"><type>array</type><type>false</type></type><methodname>class_implements</methodname>
14
+
<methodparam><type class="union"><type>object</type><type>string</type></type><parameter>object_or_class</parameter></methodparam>
15
15
<methodparam choice="opt"><type>bool</type><parameter>autoload</parameter><initializer>&true;</initializer></methodparam>
16
16
</methodsynopsis>
17
17
<para>
18
18
This function returns an array with the names of the interfaces that the
19
-
given <parameter>class</parameter> and its parents implement.
19
+
given <parameter>object_or_class</parameter> and its parents implement.
20
20
</para>
21
21
</refsect1>
22
22

...
...
@@ -25,7 +25,7 @@
25
25
<para>
26
26
<variablelist>
27
27
<varlistentry>
28
-
<term><parameter>class</parameter></term>
28
+
<term><parameter>object_or_class</parameter></term>
29
29
<listitem>
30
30
<para>
31
31
An object (class instance) or a string (class or interface name).
...
...
@@ -36,8 +36,8 @@
36
36
<term><parameter>autoload</parameter></term>
37
37
<listitem>
38
38
<para>
39
-
Whether to allow this function to load the class automatically through
40
-
the <function>__autoload</function> magic method.
39
+
Whether to <link linkend="language.oop5.autoload">autoload</link>
40
+
if not already loaded.
41
41
</para>
42
42
</listitem>
43
43
</varlistentry>
...
...
@@ -49,32 +49,7 @@
49
49
<refsect1 role="returnvalues">
50
50
&reftitle.returnvalues;
51
51
<para>
52
-
An array on success, or &false; on error.
53
-
</para>
54
-
</refsect1>
55
-

56
-
<refsect1 role="changelog">
57
-
&reftitle.changelog;
58
-
<para>
59
-
<informaltable>
60
-
<tgroup cols="2">
61
-
<thead>
62
-
<row>
63
-
<entry>&Version;</entry>
64
-
<entry>&Description;</entry>
65
-
</row>
66
-
</thead>
67
-
<tbody>
68
-
<row>
69
-
<entry>5.1.0</entry>
70
-
<entry>
71
-
Added the option to pass the <parameter>class</parameter> parameter as
72
-
a string. Added the <parameter>autoload</parameter> parameter.
73
-
</entry>
74
-
</row>
75
-
</tbody>
76
-
</tgroup>
77
-
</informaltable>
52
+
An array on success, or &false; when the given class doesn't exist.
78
53
</para>
79
54
</refsect1>
80
55

...
...
@@ -92,15 +67,12 @@ class bar implements foo {}
92
67

93
68
print_r(class_implements(new bar));
94
69

95
-
// since PHP 5.1.0 you may also specify the parameter as a string
70
+
// you may also specify the parameter as a string
96
71
print_r(class_implements('bar'));
97
72

73
+
spl_autoload_register();
98
74

99
-
function __autoload($class_name) {
100
-
require_once $class_name . '.php';
101
-
}
102
-

103
-
// use __autoload to load the 'not_loaded' class
75
+
// use autoloading to load the 'not_loaded' class
104
76
print_r(class_implements('not_loaded', true));
105
77

106
78
?>
...
...
@@ -113,7 +85,10 @@ Array
113
85
(
114
86
[foo] => foo
115
87
)
116
-

88
+
Array
89
+
(
90
+
[foo] => foo
91
+
)
117
92
Array
118
93
(
119
94
[interface_of_not_loaded] => interface_of_not_loaded
...
...
@@ -124,17 +99,28 @@ Array
124
99
</para>
125
100
</refsect1>
126
101

102
+
<refsect1 role="notes">
103
+
&reftitle.notes;
104
+
<note>
105
+
<simpara>
106
+
To check that an object implements an interface, &instanceof;
107
+
or the <function>is_a</function> function should be used instead.
108
+
</simpara>
109
+
</note>
110
+
</refsect1>
111
+

127
112
<refsect1 role="seealso">
128
113
&reftitle.seealso;
129
114
<para>
130
115
<simplelist>
131
116
<member><function>class_parents</function></member>
132
117
<member><function>get_declared_interfaces</function></member>
118
+
<member><function>is_a</function></member>
119
+
<member>&instanceof;</member>
133
120
</simplelist>
134
121
</para>
135
122
</refsect1>
136
123
</refentry>
137
-

138
124
<!-- Keep this comment at the end of the file
139
125
Local variables:
140
126
mode: sgml
141
127