reference/spl/functions/class-parents.xml
60af8c2b746d51c1556cc2ddc4d4163222347b96
...
...
@@ -10,13 +10,13 @@
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
12
<methodsynopsis>
13
-
<type>array</type><methodname>class_parents</methodname>
14
-
<methodparam><type>mixed</type><parameter>class</parameter></methodparam>
13
+
<type class="union"><type>array</type><type>false</type></type><methodname>class_parents</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 name of the parent classes of
19
-
the given <parameter>class</parameter>.
19
+
the given <parameter>object_or_class</parameter>.
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 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>
...
...
@@ -48,32 +48,7 @@
48
48
<refsect1 role="returnvalues">
49
49
&reftitle.returnvalues;
50
50
<para>
51
-
An array on success, or &false; on error.
52
-
</para>
53
-
</refsect1>
54
-

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

...
...
@@ -91,16 +66,14 @@ class bar extends foo {}
91
66

92
67
print_r(class_parents(new bar));
93
68

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

72
+
spl_autoload_register();
97
73

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

102
-
// use __autoload to load the 'not_loaded' class
74
+
// use autoloading to load the 'not_loaded' class
103
75
print_r(class_parents('not_loaded', true));
76
+

104
77
?>
105
78
]]>
106
79
</programlisting>
...
...
@@ -111,7 +84,10 @@ Array
111
84
(
112
85
[foo] => foo
113
86
)
114
-

87
+
Array
88
+
(
89
+
[foo] => foo
90
+
)
115
91
Array
116
92
(
117
93
[parent_of_not_loaded] => parent_of_not_loaded
...
...
@@ -122,16 +98,27 @@ Array
122
98
</para>
123
99
</refsect1>
124
100

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

125
111
<refsect1 role="seealso">
126
112
&reftitle.seealso;
127
113
<para>
128
114
<simplelist>
129
115
<member><function>class_implements</function></member>
116
+
<member><function>is_a</function></member>
117
+
<member>&instanceof;</member>
130
118
</simplelist>
131
119
</para>
132
120
</refsect1>
133
121
</refentry>
134
-

135
122
<!-- Keep this comment at the end of the file
136
123
Local variables:
137
124
mode: sgml
138
125