reference/classobj/functions/get-class.xml
4f36c26a72c40b16e955c3c1c88041910932d0bf
...
...
@@ -9,7 +9,7 @@
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
11
<type>string</type><methodname>get_class</methodname>
12
-
<methodparam choice="opt"><type>object</type><parameter>object</parameter><initializer>&null;</initializer></methodparam>
12
+
<methodparam choice="opt"><type>object</type><parameter>object</parameter></methodparam>
13
13
</methodsynopsis>
14
14
<para>
15
15
Gets the name of the class of the given <parameter>object</parameter>.
...
...
@@ -23,8 +23,16 @@
23
23
<term><parameter>object</parameter></term>
24
24
<listitem>
25
25
<para>
26
-
The tested object. This parameter may be omitted when inside a class.
26
+
The tested object.
27
27
</para>
28
+
<note>
29
+
<simpara>
30
+
Explicitly passing &null; as the <parameter>object</parameter> is no
31
+
longer allowed as of PHP 7.2.0 and emits an <constant>E_WARNING</constant>.
32
+
As of PHP 8.0.0, a <classname>TypeError</classname> is emitted when
33
+
&null; is used.
34
+
</simpara>
35
+
</note>
28
36
</listitem>
29
37
</varlistentry>
30
38
</variablelist>
...
...
@@ -34,12 +42,7 @@
34
42
&reftitle.returnvalues;
35
43
<para>
36
44
Returns the name of the class of which <parameter>object</parameter> is an
37
-
instance. Returns &false; if <parameter>object</parameter> is not an
38
-
object.
39
-
</para>
40
-
<para>
41
-
If <parameter>object</parameter> is omitted when inside a class, the
42
-
name of that class is returned.
45
+
instance.
43
46
</para>
44
47
<para>
45
48
If the <parameter>object</parameter> is an instance of a class which exists
...
...
@@ -50,7 +53,13 @@
50
53
&reftitle.errors;
51
54
<para>
52
55
If <function>get_class</function> is called with anything other than an
53
-
object, an <constant>E_WARNING</constant> level error is raised.
56
+
object, <classname>TypeError</classname> is raised. Prior to PHP 8.0.0,
57
+
an <constant>E_WARNING</constant> level error was raised.
58
+
</para>
59
+
<para>
60
+
If <function>get_class</function> is called with no arguments from outside a class,
61
+
an <classname>Error</classname> is thrown. Prior to PHP 8.0.0,
62
+
an <constant>E_WARNING</constant> level error was raised.
54
63
</para>
55
64
</refsect1>
56
65
<refsect1 role="changelog">
...
...
@@ -66,11 +75,29 @@
66
75
</thead>
67
76
<tbody>
68
77
<row>
69
-
<entry>5.3.0</entry>
78
+
<entry>8.3.0</entry>
79
+
<entry>
80
+
Calling <function>get_class</function> without an argument now emits an
81
+
<constant>E_DEPRECATED</constant> warning;
82
+
previously, calling this function inside a class returned the name of that class.
83
+
</entry>
84
+
</row>
85
+
<row>
86
+
<entry>8.0.0</entry>
87
+
<entry>
88
+
Calling this function from outside a class, without any arguments,
89
+
will now throw an <classname>Error</classname>.
90
+
Previously, an <constant>E_WARNING</constant> was raised
91
+
and the function returned &false;.
92
+
</entry>
93
+
</row>
94
+
<row>
95
+
<entry>7.2.0</entry>
70
96
<entry>
71
-
&null; became the default value for <parameter>object</parameter>,
72
-
so passing &null; to <parameter>object</parameter> now has the same
73
-
result as not passing any value.
97
+
Prior to this version the default value for <parameter>object</parameter>
98
+
was &null; and it had the same effect as not passing any value. Now
99
+
&null; has been removed as the default value for <parameter>object</parameter>,
100
+
and is no longer a valid input.
74
101
</entry>
75
102
</row>
76
103
</tbody>
...
...
@@ -181,6 +208,7 @@ string(11) "Foo\Bar\Baz"
181
208
<member><function>get_called_class</function></member>
182
209
<member><function>get_parent_class</function></member>
183
210
<member><function>gettype</function></member>
211
+
<member><function>get_debug_type</function></member>
184
212
<member><function>is_subclass_of</function></member>
185
213
</simplelist>
186
214
</para>
187
215