reference/classobj/functions/class-alias.xml
194d020921b4f2bc7616ac9eacabe362e89752ef
...
...
@@ -9,22 +9,28 @@
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
11
<type>bool</type><methodname>class_alias</methodname>
12
-
<methodparam><type>string</type><parameter>original</parameter></methodparam>
12
+
<methodparam><type>string</type><parameter>class</parameter></methodparam>
13
13
<methodparam><type>string</type><parameter>alias</parameter></methodparam>
14
14
<methodparam choice="opt"><type>bool</type><parameter>autoload</parameter><initializer>&true;</initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
17
Creates an alias named <parameter>alias</parameter>
18
-
based on the user defined class <parameter>original</parameter>.
18
+
based on the user defined class <parameter>class</parameter>.
19
19
The aliased class is exactly the same as the original class.
20
20
</para>
21
+
<note>
22
+
<simpara>
23
+
As of PHP 8.3.0, <function>class_alias</function> also supports
24
+
creating an alias of an PHP internal class.
25
+
</simpara>
26
+
</note>
21
27
</refsect1>
22
28
<refsect1 role="parameters">
23
29
&reftitle.parameters;
24
30
<para>
25
31
<variablelist>
26
32
<varlistentry>
27
-
<term><parameter>original</parameter></term>
33
+
<term><parameter>class</parameter></term>
28
34
<listitem>
29
35
<para>
30
36
The original class.
...
...
@@ -43,7 +49,8 @@
43
49
<term><parameter>autoload</parameter></term>
44
50
<listitem>
45
51
<para>
46
-
Whether to autoload if the original class is not found.
52
+
Whether to <link linkend="language.oop5.autoload">autoload</link>
53
+
if the original class is not found.
47
54
</para>
48
55
</listitem>
49
56
</varlistentry>
...
...
@@ -57,6 +64,28 @@
57
64
</para>
58
65
</refsect1>
59
66

67
+
<refsect1 role="changelog">
68
+
&reftitle.changelog;
69
+
<informaltable>
70
+
<tgroup cols="2">
71
+
<thead>
72
+
<row>
73
+
<entry>&Version;</entry>
74
+
<entry>&Description;</entry>
75
+
</row>
76
+
</thead>
77
+
<tbody>
78
+
<row>
79
+
<entry>8.3.0</entry>
80
+
<entry>
81
+
<function>class_alias</function> now supports creating an alias of an internal class.
82
+
</entry>
83
+
</row>
84
+
</tbody>
85
+
</tgroup>
86
+
</informaltable>
87
+
</refsect1>
88
+

60
89
<refsect1 role="examples">
61
90
&reftitle.examples;
62
91
<para>
...
...
@@ -66,23 +95,23 @@
66
95
<![CDATA[
67
96
<?php
68
97

69
-
class foo { }
98
+
class Foo { }
70
99

71
-
class_alias('foo', 'bar');
100
+
class_alias('Foo', 'Bar');
72
101

73
-
$a = new foo;
74
-
$b = new bar;
102
+
$a = new Foo;
103
+
$b = new Bar;
75
104

76
105
// the objects are the same
77
106
var_dump($a == $b, $a === $b);
78
107
var_dump($a instanceof $b);
79
108

80
109
// the classes are the same
81
-
var_dump($a instanceof foo);
82
-
var_dump($a instanceof bar);
110
+
var_dump($a instanceof Foo);
111
+
var_dump($a instanceof Bar);
83
112

84
-
var_dump($b instanceof foo);
85
-
var_dump($b instanceof bar);
113
+
var_dump($b instanceof Foo);
114
+
var_dump($b instanceof Bar);
86
115

87
116
?>
88
117
]]>
...
...
@@ -102,6 +131,18 @@ bool(true)
102
131
</example>
103
132
</para>
104
133
</refsect1>
134
+
<refsect1 role="notes">
135
+
&reftitle.notes;
136
+
<note>
137
+
<para>
138
+
Class names are case-insensitive in PHP, and this is reflected in this
139
+
function. Aliases created by <function>class_alias</function> are declared
140
+
in lowercase. This means that for a class
141
+
<literal>MyClass</literal>, the <code>class_alias('MyClass', 'MyClassAlias')</code>
142
+
call will declare a new class alias named <literal>myclassalias</literal>.
143
+
</para>
144
+
</note>
145
+
</refsect1>
105
146
<refsect1 role="seealso">
106
147
&reftitle.seealso;
107
148
<para>
...
...
@@ -112,7 +153,6 @@ bool(true)
112
153
</para>
113
154
</refsect1>
114
155
</refentry>
115
-

116
156
<!-- Keep this comment at the end of the file
117
157
Local variables:
118
158
mode: sgml
119
159