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,11 +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. This parameter is optional if called
27
-
from the object's method.
26
+
The tested object or class name.
28
27
</para>
29
28
</listitem>
30
29
</varlistentry>
...
...
@@ -35,41 +34,44 @@
35
34
&reftitle.returnvalues;
36
35
<para>
37
36
Returns the name of the parent class of the class of which
38
-
<parameter>object</parameter> is an instance or the name.
37
+
<parameter>object_or_class</parameter> is an instance or the name.
39
38
</para>
40
-
<note>
41
-
<para>
42
-
If the object does not have a parent or the class given does not exist &false; will be returned.
43
-
</para>
44
-
</note>
45
39
<para>
46
-
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.
47
42
</para>
48
43
</refsect1>
44
+

49
45
<refsect1 role="changelog">
50
46
&reftitle.changelog;
51
-
<para>
52
-
<informaltable>
53
-
<tgroup cols="2">
54
-
<thead>
55
-
<row>
56
-
<entry>&Version;</entry>
57
-
<entry>&Description;</entry>
58
-
</row>
59
-
</thead>
60
-
<tbody>
61
-
<row>
62
-
<entry>5.1.0</entry>
63
-
<entry>
64
-
If called without parameter outside object, this function would have
65
-
returned &null; with a warning, but now returns &false;.
66
-
</entry>
67
-
</row>
68
-
</tbody>
69
-
</tgroup>
70
-
</informaltable>
71
-
</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>
72
73
</refsect1>
74
+

73
75
<refsect1 role="examples">
74
76
&reftitle.examples;
75
77
<para>
...
...
@@ -79,22 +81,22 @@
79
81
<![CDATA[
80
82
<?php
81
83

82
-
class dad {
83
-
function dad()
84
+
class Dad {
85
+
function __construct()
84
86
{
85
87
// implements some logic
86
88
}
87
89
}
88
90

89
-
class child extends dad {
90
-
function child()
91
+
class Child extends Dad {
92
+
function __construct()
91
93
{
92
94
echo "I'm " , get_parent_class($this) , "'s son\n";
93
95
}
94
96
}
95
97

96
-
class child2 extends dad {
97
-
function child2()
98
+
class Child2 extends Dad {
99
+
function __construct()
98
100
{
99
101
echo "I'm " , get_parent_class('child2') , "'s son too\n";
100
102
}
...
...
@@ -109,8 +111,8 @@ $bar = new child2();
109
111
&example.outputs;
110
112
<screen>
111
113
<![CDATA[
112
-
I'm dad's son
113
-
I'm dad's son too
114
+
I'm Dad's son
115
+
I'm Dad's son too
114
116
]]>
115
117
</screen>
116
118
</example>
117
119