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,7 @@
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>
141
138
</entry>
142
139
<entry>
143
140
<link linkend="functions.arrow">fn</link> (as of PHP 7.4)
...
...
@@ -157,7 +154,7 @@
157
154
<link linkend="language.variables.scope">global</link>
158
155
</entry>
159
156
<entry>
160
-
<link linkend="control-structures.goto">goto</link> (as of PHP 5.3)
157
+
<link linkend="control-structures.goto">goto</link>
161
158
</entry>
162
159
<entry>
163
160
<link linkend="control-structures.if">if</link>
...
...
@@ -177,7 +174,7 @@
177
174
<link linkend="language.operators.type">instanceof</link>
178
175
</entry>
179
176
<entry>
180
-
<link linkend="language.oop5.traits.conflict">insteadof</link> (as of PHP 5.4)
177
+
<link linkend="language.oop5.traits.conflict">insteadof</link>
181
178
</entry>
182
179
<entry>
183
180
<link linkend="language.oop5.interfaces">interface</link>
...
...
@@ -191,17 +188,20 @@
191
188
<function>list</function>
192
189
</entry>
193
190
<entry>
194
-
<link linkend="language.namespaces">namespace</link> (as of PHP 5.3)
191
+
&match; (as of PHP 8.0)
195
192
</entry>
196
193
<entry>
197
-
<link linkend="language.oop5.basic.new">new</link>
194
+
<link linkend="language.namespaces">namespace</link>
198
195
</entry>
199
196
<entry>
200
-
<link linkend="language.operators.logical">or</link>
197
+
<link linkend="language.oop5.basic.new">new</link>
201
198
</entry>
202
199
</row>
203
200
<row>
204
201
<entry>
202
+
<link linkend="language.operators.logical">or</link>
203
+
</entry>
204
+
<entry>
205
205
<function>print</function>
206
206
</entry>
207
207
<entry>
...
...
@@ -213,11 +213,14 @@
213
213
<entry>
214
214
<link linkend="language.oop5.visibility">public</link>
215
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>
216
221
<entry>
217
222
<function>require</function>
218
223
</entry>
219
-
</row>
220
-
<row>
221
224
<entry>
222
225
<function>require_once</function>
223
226
</entry>
...
...
@@ -227,16 +230,16 @@
227
230
<entry>
228
231
<link linkend="language.variables.scope">static</link>
229
232
</entry>
233
+
</row>
234
+
<row>
230
235
<entry>
231
236
<link linkend="control-structures.switch">switch</link>
232
237
</entry>
233
238
<entry>
234
239
<link linkend="language.exceptions">throw</link>
235
240
</entry>
236
-
</row>
237
-
<row>
238
241
<entry>
239
-
<link linkend="language.oop5.traits">trait</link> (as of PHP 5.4)
242
+
<link linkend="language.oop5.traits">trait</link>
240
243
</entry>
241
244
<entry>
242
245
<link linkend="language.exceptions">try</link>
...
...
@@ -244,14 +247,14 @@
244
247
<entry>
245
248
<function>unset</function>
246
249
</entry>
250
+
</row>
251
+
<row>
247
252
<entry>
248
253
<link linkend="language.namespaces">use</link>
249
254
</entry>
250
255
<entry>
251
256
<link linkend="language.oop5.properties">var</link>
252
257
</entry>
253
-
</row>
254
-
<row>
255
258
<entry>
256
259
<link linkend="control-structures.while">while</link>
257
260
</entry>
...
...
@@ -259,18 +262,26 @@
259
262
<link linkend="language.operators.logical">xor</link>
260
263
</entry>
261
264
<entry>
262
-
<link linkend="language.generators">yield</link> (as of PHP 5.5)
263
-
</entry>
264
-
<entry>
265
-
<link linkend="control-structures.yield.from">yield from</link> (as of PHP 7.0)
265
+
<link linkend="language.generators">yield</link>
266
266
</entry>
267
+
</row>
268
+
<row>
267
269
<entry>
270
+
<link linkend="control-structures.yield.from">yield from</link>
268
271
</entry>
272
+
<entry></entry>
273
+
<entry></entry>
274
+
<entry></entry>
275
+
<entry></entry>
269
276
</row>
270
277
</tbody>
271
278
</tgroup>
272
279
</table>
273
280

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

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

384
384
</simpara>
385
385
</listitem>
386
386
</varlistentry>
...
...
@@ -391,46 +391,26 @@
391
391
</simpara>
392
392
</listitem>
393
393
</varlistentry>
394
-
</variablelist>
395
-
</sect2>
396
-

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

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

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

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

433
-
<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>
434
414
<varlistentry>
435
415
<term><classname>ArithmeticError</classname></term>
436
416
<listitem>
...
...
@@ -527,37 +507,37 @@
527
507
<sect1 xml:id="reserved.other-reserved-words">
528
508
<title>List of other reserved words</title>
529
509
<simpara>
530
-
The following words cannot be used to name a class, interface or trait, and
531
-
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.
532
512
</simpara>
533
513
<para>
534
514
<table>
535
515
<title>Reserved words</title>
536
-
<tgroup cols="5">
516
+
<tgroup cols="4">
537
517
<tbody>
538
518
<row>
539
519
<entry>
540
-
int (as of PHP 7)
520
+
int
541
521
</entry>
542
522
<entry>
543
-
float (as of PHP 7)
523
+
float
544
524
</entry>
545
525
<entry>
546
-
bool (as of PHP 7)
526
+
bool
547
527
</entry>
548
528
<entry>
549
-
string (as of PHP 7)
529
+
string
550
530
</entry>
551
531
</row>
552
532
<row>
553
533
<entry>
554
-
true (as of PHP 7)
534
+
true
555
535
</entry>
556
536
<entry>
557
-
false (as of PHP 7)
537
+
false
558
538
</entry>
559
539
<entry>
560
-
null (as of PHP 7)
540
+
null
561
541
</entry>
562
542
<entry>
563
543
void (as of PHP 7.1)
...
...
@@ -570,6 +550,12 @@
570
550
<entry>
571
551
object (as of PHP 7.2)
572
552
</entry>
553
+
<entry>
554
+
mixed (as of PHP 8.0)
555
+
</entry>
556
+
<entry>
557
+
never (as of PHP 8.1)
558
+
</entry>
573
559
</row>
574
560
</tbody>
575
561
</tgroup>
...
...
@@ -577,24 +563,24 @@
577
563
</para>
578
564
<para>
579
565
The following list of words have had soft reservations placed on them.
580
-
Whilst they may still be used as class, interface, and trait names (as well
581
-
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
582
568
used in future versions of PHP.
583
569
</para>
584
570
<para>
585
571
<table>
586
572
<title>Soft reserved words</title>
587
-
<tgroup cols="5">
573
+
<tgroup cols="4">
588
574
<tbody>
589
575
<row>
590
576
<entry>
591
-
resource (as of PHP 7)
577
+
enum
592
578
</entry>
593
579
<entry>
594
-
mixed (as of PHP 7)
580
+
resource
595
581
</entry>
596
582
<entry>
597
-
numeric (as of PHP 7)
583
+
numeric
598
584
</entry>
599
585
<entry>
600
586
</entry>
601
587