reference/classobj/functions/get-parent-class.xml
7cec82fec28b339913fe98e990e7b01f4bb97476
...
...
@@ -8,8 +8,8 @@
8
8
<refsect1 role="description">
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
-
<type>string</type><methodname>get_parent_class</methodname>
12
-
<methodparam choice="opt"><type>mixed</type><parameter>object</parameter></methodparam>
11
+
<type class="union"><type>string</type><type>false</type></type><methodname>get_parent_class</methodname>
12
+
<methodparam choice="opt"><type class="union"><type>object</type><type>string</type></type><parameter>object_or_class</parameter></methodparam>
13
13
</methodsynopsis>
14
14
<para>
15
15
Retrieves the parent class name for object or class.
...
...
@@ -20,10 +20,10 @@
20
20
<para>
21
21
<variablelist>
22
22
<varlistentry>
23
-
<term><parameter>object</parameter></term>
23
+
<term><parameter>object_or_class</parameter></term>
24
24
<listitem>
25
25
<para>
26
-
The tested object or class name
26
+
The tested object or class name.
27
27
</para>
28
28
</listitem>
29
29
</varlistentry>
...
...
@@ -34,55 +34,44 @@
34
34
&reftitle.returnvalues;
35
35
<para>
36
36
Returns the name of the parent class of the class of which
37
-
<parameter>object</parameter> is an instance or the name.
37
+
<parameter>object_or_class</parameter> is an instance or the name.
38
38
</para>
39
-
<note>
40
-
<para>
41
-
If the object does not have a parent &false; will be returned.
42
-
</para>
43
-
</note>
44
39
<para>
45
-
If called without parameter outside object, this function returns &false;.
40
+
If the object does not have a parent or the given class does not exist,
41
+
&false; will be returned.
46
42
</para>
47
43
</refsect1>
44
+

48
45
<refsect1 role="changelog">
49
46
&reftitle.changelog;
50
-
<para>
51
-
<informaltable>
52
-
<tgroup cols="2">
53
-
<thead>
54
-
<row>
55
-
<entry>&Version;</entry>
56
-
<entry>&Description;</entry>
57
-
</row>
58
-
</thead>
59
-
<tbody>
60
-
<row>
61
-
<entry>Before 5.1.0</entry>
62
-
<entry>
63
-
If called without parameter outside object, this function would have
64
-
returned &null; with a warning.
65
-
</entry>
66
-
</row>
67
-
<row>
68
-
<entry>Since 5.0.0</entry>
69
-
<entry>
70
-
The <parameter>object</parameter> parameter is optional if called
71
-
from the object's method.
72
-
</entry>
73
-
</row>
74
-
<row>
75
-
<entry>Since 4.0.5</entry>
76
-
<entry>
77
-
If <parameter>object</parameter> is a string, returns the name of the
78
-
parent class of the class with that name.
79
-
</entry>
80
-
</row>
81
-
</tbody>
82
-
</tgroup>
83
-
</informaltable>
84
-
</para>
47
+
<informaltable>
48
+
<tgroup cols="2">
49
+
<thead>
50
+
<row>
51
+
<entry>&Version;</entry>
52
+
<entry>&Description;</entry>
53
+
</row>
54
+
</thead>
55
+
<tbody>
56
+
<row>
57
+
<entry>8.3.0</entry>
58
+
<entry>
59
+
Calling <function>get_parent_class</function> without an argument now emits an
60
+
<constant>E_DEPRECATED</constant> warning;
61
+
previously, calling this function inside a class returned the name of that class.
62
+
</entry>
63
+
</row>
64
+
<row>
65
+
<entry>8.0.0</entry>
66
+
<entry>
67
+
The <parameter>object_or_class</parameter> parameter now only accepts objects or valid class names.
68
+
</entry>
69
+
</row>
70
+
</tbody>
71
+
</tgroup>
72
+
</informaltable>
85
73
</refsect1>
74
+

86
75
<refsect1 role="examples">
87
76
&reftitle.examples;
88
77
<para>
...
...
@@ -92,22 +81,22 @@
92
81
<![CDATA[
93
82
<?php
94
83

95
-
class dad {
96
-
function dad()
84
+
class Dad {
85
+
function __construct()
97
86
{
98
87
// implements some logic
99
88
}
100
89
}
101
90

102
-
class child extends dad {
103
-
function child()
91
+
class Child extends Dad {
92
+
function __construct()
104
93
{
105
94
echo "I'm " , get_parent_class($this) , "'s son\n";
106
95
}
107
96
}
108
97

109
-
class child2 extends dad {
110
-
function child2()
98
+
class Child2 extends Dad {
99
+
function __construct()
111
100
{
112
101
echo "I'm " , get_parent_class('child2') , "'s son too\n";
113
102
}
...
...
@@ -122,8 +111,8 @@ $bar = new child2();
122
111
&example.outputs;
123
112
<screen>
124
113
<![CDATA[
125
-
I'm dad's son
126
-
I'm dad's son too
114
+
I'm Dad's son
115
+
I'm Dad's son too
127
116
]]>
128
117
</screen>
129
118
</example>
...
...
@@ -135,6 +124,7 @@ I'm dad's son too
135
124
<simplelist>
136
125
<member><function>get_class</function></member>
137
126
<member><function>is_subclass_of</function></member>
127
+
<member><function>class_parents</function></member>
138
128
</simplelist>
139
129
</para>
140
130
</refsect1>
141
131