appendices/reserved.xml
010542d1dcb9b1d5cd397a77ed580e50de25aca7
...
...
@@ -16,12 +16,9 @@
16
16
<simpara>
17
17
These words have special meaning in PHP. Some of them represent things
18
18
which look like functions, some look like constants, and so on - but
19
-
they're not, really: they are language constructs. You cannot use any
20
-
of the following words as constants, class names, function or method names.
21
-
Using them as variable names is generally OK, but could lead to confusion.
22
-
</simpara>
23
-
<simpara>
24
-
As of PHP 7.0.0 these keywords are allowed as property, constant, and
19
+
they're not, really: they are language constructs.
20
+
The following words cannot be used as constants, class names, or function names.
21
+
They are, however, allowed as property, constant, and
25
22
method names of classes, interfaces and traits, except that
26
23
<literal>class</literal> may not be used as constant name.
27
24
</simpara>
...
...
@@ -52,7 +49,7 @@
52
49
<link linkend="control-structures.break">break</link>
53
50
</entry>
54
51
<entry>
55
-
<link linkend="language.types.callable">callable</link> (as of PHP 5.4)
52
+
<link linkend="language.types.callable">callable</link>
56
53
</entry>
57
54
<entry>
58
55
<link linkend="control-structures.switch">case</link>
...
...
@@ -137,7 +134,10 @@
137
134
<link linkend="language.oop5.final">final</link>
138
135
</entry>
139
136
<entry>
140
-
<link linkend="language.exceptions">finally</link> (as of PHP 5.5)
137
+
<link linkend="language.exceptions">finally</link>
138
+
</entry>
139
+
<entry>
140
+
<link linkend="functions.arrow">fn</link> (as of PHP 7.4)
141
141
</entry>
142
142
<entry>
143
143
<link linkend="control-structures.for">for</link>
...
...
@@ -145,16 +145,16 @@
145
145
<entry>
146
146
&foreach;
147
147
</entry>
148
+
</row>
149
+
<row>
148
150
<entry>
149
151
<link linkend="functions.user-defined">function</link>
150
152
</entry>
151
-
</row>
152
-
<row>
153
153
<entry>
154
154
<link linkend="language.variables.scope">global</link>
155
155
</entry>
156
156
<entry>
157
-
<link linkend="control-structures.goto">goto</link> (as of PHP 5.3)
157
+
<link linkend="control-structures.goto">goto</link>
158
158
</entry>
159
159
<entry>
160
160
<link linkend="control-structures.if">if</link>
...
...
@@ -162,11 +162,11 @@
162
162
<entry>
163
163
<link linkend="language.oop5.interfaces">implements</link>
164
164
</entry>
165
+
</row>
166
+
<row>
165
167
<entry>
166
168
<function>include</function>
167
169
</entry>
168
-
</row>
169
-
<row>
170
170
<entry>
171
171
<function>include_once</function>
172
172
</entry>
...
...
@@ -174,33 +174,36 @@
174
174
<link linkend="language.operators.type">instanceof</link>
175
175
</entry>
176
176
<entry>
177
-
<link linkend="language.oop5.traits.conflict">insteadof</link> (as of PHP 5.4)
177
+
<link linkend="language.oop5.traits.conflict">insteadof</link>
178
178
</entry>
179
179
<entry>
180
180
<link linkend="language.oop5.interfaces">interface</link>
181
181
</entry>
182
+
</row>
183
+
<row>
182
184
<entry>
183
185
<function>isset</function>
184
186
</entry>
185
-
</row>
186
-
<row>
187
187
<entry>
188
188
<function>list</function>
189
189
</entry>
190
190
<entry>
191
-
<link linkend="language.namespaces">namespace</link> (as of PHP 5.3)
191
+
&match; (as of PHP 8.0)
192
+
</entry>
193
+
<entry>
194
+
<link linkend="language.namespaces">namespace</link>
192
195
</entry>
193
196
<entry>
194
197
<link linkend="language.oop5.basic.new">new</link>
195
198
</entry>
199
+
</row>
200
+
<row>
196
201
<entry>
197
202
<link linkend="language.operators.logical">or</link>
198
203
</entry>
199
204
<entry>
200
205
<function>print</function>
201
206
</entry>
202
-
</row>
203
-
<row>
204
207
<entry>
205
208
<link linkend="language.oop5.visibility">private</link>
206
209
</entry>
...
...
@@ -210,20 +213,25 @@
210
213
<entry>
211
214
<link linkend="language.oop5.visibility">public</link>
212
215
</entry>
216
+
</row>
217
+
<row>
218
+
<entry>
219
+
<link linkend="language.oop5.properties.readonly-properties">readonly</link> (as of PHP 8.1.0) *
220
+
</entry>
213
221
<entry>
214
222
<function>require</function>
215
223
</entry>
216
224
<entry>
217
225
<function>require_once</function>
218
226
</entry>
219
-
</row>
220
-
<row>
221
227
<entry>
222
228
<function>return</function>
223
229
</entry>
224
230
<entry>
225
231
<link linkend="language.variables.scope">static</link>
226
232
</entry>
233
+
</row>
234
+
<row>
227
235
<entry>
228
236
<link linkend="control-structures.switch">switch</link>
229
237
</entry>
...
...
@@ -231,16 +239,16 @@
231
239
<link linkend="language.exceptions">throw</link>
232
240
</entry>
233
241
<entry>
234
-
<link linkend="language.oop5.traits">trait</link> (as of PHP 5.4)
242
+
<link linkend="language.oop5.traits">trait</link>
235
243
</entry>
236
-
</row>
237
-
<row>
238
244
<entry>
239
245
<link linkend="language.exceptions">try</link>
240
246
</entry>
241
247
<entry>
242
248
<function>unset</function>
243
249
</entry>
250
+
</row>
251
+
<row>
244
252
<entry>
245
253
<link linkend="language.namespaces">use</link>
246
254
</entry>
...
...
@@ -250,25 +258,30 @@
250
258
<entry>
251
259
<link linkend="control-structures.while">while</link>
252
260
</entry>
253
-
</row>
254
-
<row>
255
261
<entry>
256
262
<link linkend="language.operators.logical">xor</link>
257
263
</entry>
258
264
<entry>
259
-
<link linkend="language.generators">yield</link> (as of PHP 5.5)
260
-
</entry>
261
-
<entry>
262
-
</entry>
263
-
<entry>
265
+
<link linkend="language.generators">yield</link>
264
266
</entry>
267
+
</row>
268
+
<row>
265
269
<entry>
270
+
<link linkend="control-structures.yield.from">yield from</link>
266
271
</entry>
272
+
<entry></entry>
273
+
<entry></entry>
274
+
<entry></entry>
275
+
<entry></entry>
267
276
</row>
268
277
</tbody>
269
278
</tgroup>
270
279
</table>
271
280

281
+
<simpara>
282
+
* <literal>readonly</literal> may be used as function name.
283
+
</simpara>
284
+

272
285
<table>
273
286
<title>Compile-time constants</title>
274
287
<tgroup cols="5">
...
...
@@ -278,7 +291,7 @@
278
291
<link linkend="language.constants.predefined">__CLASS__</link>
279
292
</entry>
280
293
<entry>
281
-
<link linkend="language.constants.predefined">__DIR__</link> (as of PHP 5.3)
294
+
<link linkend="language.constants.predefined">__DIR__</link>
282
295
</entry>
283
296
<entry>
284
297
<link linkend="language.constants.predefined">__FILE__</link>
...
...
@@ -295,10 +308,10 @@
295
308
</row>
296
309
<row>
297
310
<entry>
298
-
<link linkend="language.namespaces.nsconstants">__NAMESPACE__</link> (as of PHP 5.3)
311
+
<link linkend="language.namespaces.nsconstants">__NAMESPACE__</link>
299
312
</entry>
300
313
<entry>
301
-
<link linkend="language.constants.predefined">__TRAIT__</link> (as of PHP 5.4)
314
+
<link linkend="language.constants.predefined">__TRAIT__</link>
302
315
</entry>
303
316
<entry>
304
317
</entry>
...
...
@@ -342,8 +355,9 @@
342
355
<term><classname>stdClass</classname></term>
343
356
<listitem>
344
357
<simpara>
345
-
Created by <link linkend="language.types.object.casting">typecasting
346
-
to object</link>.
358
+
A generic empty class created as a result of
359
+
<link linkend="language.types.object.casting">typecasting
360
+
to object</link> or various standard functions.
347
361
</simpara>
348
362
</listitem>
349
363
</varlistentry>
...
...
@@ -355,18 +369,6 @@
355
369
</simpara>
356
370
</listitem>
357
371
</varlistentry>
358
-
</variablelist>
359
-
</sect2>
360
-
361
-
<sect2 xml:id="reserved.classes.php5">
362
-
<title>Predefined classes as of PHP 5</title>
363
-
364
-
<simpara>
365
-
These additional predefined classes were introduced in
366
-
PHP 5.0.0.
367
-
</simpara>
368
-
369
-
<variablelist>
370
372
<varlistentry>
371
373
<term><classname>Exception</classname></term>
372
374
<listitem>
...
...
@@ -378,7 +380,7 @@
378
380
<term><classname>ErrorException</classname></term>
379
381
<listitem>
380
382
<simpara>
381
-
Available since PHP 5.1.0.
383
+

382
384
</simpara>
383
385
</listitem>
384
386
</varlistentry>
...
...
@@ -389,46 +391,26 @@
389
391
</simpara>
390
392
</listitem>
391
393
</varlistentry>
392
-
</variablelist>
393
-
</sect2>
394
-

395
-
<sect2 xml:id="reserved.classes.closure">
396
-
<title>Closure</title>
397
-
398
-
<simpara>
399
-
The predefined final class <classname>Closure</classname> was introduced
400
-
in PHP 5.3.0. It is used for representing <link
401
-
linkend="functions.anonymous">anonymous functions</link>.
402
-
</simpara>
403
-
<simpara>
404
-
For more information, see its <link linkend="class.closure">class
405
-
page</link>.
406
-
</simpara>
407
-
</sect2>
408
-

409
-
<sect2 xml:id="reserved.classes.generator">
410
-
<title>Generator</title>
411
-
412
-
<simpara>
413
-
The predefined final class <classname>Generator</classname> was introduced
414
-
in PHP 5.5.0. It is used for representing <link
415
-
linkend="language.generators">generators</link>.
416
-
</simpara>
417
-
<simpara>
418
-
For more information, see its <link linkend="class.generator">class
419
-
page</link>.
420
-
</simpara>
421
-
</sect2>
422
-

423
-
<sect2 xml:id="reserved.classes.php7">
424
-
<title>Predefined interfaces and classes as of PHP 7</title>
425
-

426
-
<simpara>
427
-
These additional predefined interfaces and classes were introduced in
428
-
PHP 7.0.0.
429
-
</simpara>
430
-

431
-
<variablelist>
394
+
<varlistentry>
395
+
<term><classname>Closure</classname></term>
396
+
<listitem>
397
+
<simpara>
398
+
The predefined final class <classname>Closure</classname>
399
+
is used for representing <link
400
+
linkend="functions.anonymous">anonymous functions</link>.
401
+
</simpara>
402
+
</listitem>
403
+
</varlistentry>
404
+
<varlistentry>
405
+
<term><classname>Generator</classname></term>
406
+
<listitem>
407
+
<simpara>
408
+
The predefined final class <classname>Generator</classname>
409
+
is used for representing <link
410
+
linkend="language.generators">generators</link>.
411
+
</simpara>
412
+
</listitem>
413
+
</varlistentry>
432
414
<varlistentry>
433
415
<term><classname>ArithmeticError</classname></term>
434
416
<listitem>
...
...
@@ -525,37 +507,37 @@
525
507
<sect1 xml:id="reserved.other-reserved-words">
526
508
<title>List of other reserved words</title>
527
509
<simpara>
528
-
The following words cannot be used to name a class, interface or trait, and
529
-
they are also prohibited from being used in namespaces.
510
+
The following words cannot be used to name a class, interface or trait.
511
+
Prior to PHP 8.0, they are also prohibited from being used in namespaces.
530
512
</simpara>
531
513
<para>
532
514
<table>
533
515
<title>Reserved words</title>
534
-
<tgroup cols="5">
516
+
<tgroup cols="4">
535
517
<tbody>
536
518
<row>
537
519
<entry>
538
-
int (as of PHP 7)
520
+
int
539
521
</entry>
540
522
<entry>
541
-
float (as of PHP 7)
523
+
float
542
524
</entry>
543
525
<entry>
544
-
bool (as of PHP 7)
526
+
bool
545
527
</entry>
546
528
<entry>
547
-
string (as of PHP 7)
529
+
string
548
530
</entry>
549
531
</row>
550
532
<row>
551
533
<entry>
552
-
true (as of PHP 7)
534
+
true
553
535
</entry>
554
536
<entry>
555
-
false (as of PHP 7)
537
+
false
556
538
</entry>
557
539
<entry>
558
-
null (as of PHP 7)
540
+
null
559
541
</entry>
560
542
<entry>
561
543
void (as of PHP 7.1)
...
...
@@ -568,6 +550,12 @@
568
550
<entry>
569
551
object (as of PHP 7.2)
570
552
</entry>
553
+
<entry>
554
+
mixed (as of PHP 8.0)
555
+
</entry>
556
+
<entry>
557
+
never (as of PHP 8.1)
558
+
</entry>
571
559
</row>
572
560
</tbody>
573
561
</tgroup>
...
...
@@ -575,24 +563,24 @@
575
563
</para>
576
564
<para>
577
565
The following list of words have had soft reservations placed on them.
578
-
Whilst they may still be used as class, interface, and trait names (as well
579
-
as in namespaces), usage of them is highly discouraged since they may be
566
+
Whilst they may still be used as class, interface, and trait names
567
+
usage of them is highly discouraged since they may be
580
568
used in future versions of PHP.
581
569
</para>
582
570
<para>
583
571
<table>
584
572
<title>Soft reserved words</title>
585
-
<tgroup cols="5">
573
+
<tgroup cols="4">
586
574
<tbody>
587
575
<row>
588
576
<entry>
589
-
resource (as of PHP 7)
577
+
enum
590
578
</entry>
591
579
<entry>
592
-
mixed (as of PHP 7)
580
+
resource
593
581
</entry>
594
582
<entry>
595
-
numeric (as of PHP 7)
583
+
numeric
596
584
</entry>
597
585
<entry>
598
586
</entry>
599
587