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,10 +188,10 @@
191
188
<function>list</function>
192
189
</entry>
193
190
<entry>
194
-
<link linkend="control-structures.match">match</link> (as of PHP 8.0)
191
+
&match; (as of PHP 8.0)
195
192
</entry>
196
193
<entry>
197
-
<link linkend="language.namespaces">namespace</link> (as of PHP 5.3)
194
+
<link linkend="language.namespaces">namespace</link>
198
195
</entry>
199
196
<entry>
200
197
<link linkend="language.oop5.basic.new">new</link>
...
...
@@ -219,6 +216,9 @@
219
216
</row>
220
217
<row>
221
218
<entry>
219
+
<link linkend="language.oop5.properties.readonly-properties">readonly</link> (as of PHP 8.1.0) *
220
+
</entry>
221
+
<entry>
222
222
<function>require</function>
223
223
</entry>
224
224
<entry>
...
...
@@ -230,16 +230,16 @@
230
230
<entry>
231
231
<link linkend="language.variables.scope">static</link>
232
232
</entry>
233
+
</row>
234
+
<row>
233
235
<entry>
234
236
<link linkend="control-structures.switch">switch</link>
235
237
</entry>
236
-
</row>
237
-
<row>
238
238
<entry>
239
239
<link linkend="language.exceptions">throw</link>
240
240
</entry>
241
241
<entry>
242
-
<link linkend="language.oop5.traits">trait</link> (as of PHP 5.4)
242
+
<link linkend="language.oop5.traits">trait</link>
243
243
</entry>
244
244
<entry>
245
245
<link linkend="language.exceptions">try</link>
...
...
@@ -247,11 +247,11 @@
247
247
<entry>
248
248
<function>unset</function>
249
249
</entry>
250
+
</row>
251
+
<row>
250
252
<entry>
251
253
<link linkend="language.namespaces">use</link>
252
254
</entry>
253
-
</row>
254
-
<row>
255
255
<entry>
256
256
<link linkend="language.oop5.properties">var</link>
257
257
</entry>
...
...
@@ -262,16 +262,26 @@
262
262
<link linkend="language.operators.logical">xor</link>
263
263
</entry>
264
264
<entry>
265
-
<link linkend="language.generators">yield</link> (as of PHP 5.5)
265
+
<link linkend="language.generators">yield</link>
266
266
</entry>
267
+
</row>
268
+
<row>
267
269
<entry>
268
-
<link linkend="control-structures.yield.from">yield from</link> (as of PHP 7.0)
270
+
<link linkend="control-structures.yield.from">yield from</link>
269
271
</entry>
272
+
<entry></entry>
273
+
<entry></entry>
274
+
<entry></entry>
275
+
<entry></entry>
270
276
</row>
271
277
</tbody>
272
278
</tgroup>
273
279
</table>
274
280

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

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

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

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

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

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

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

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