mirror of
https://github.com/php/php-langspec.git
synced 2026-03-23 23:02:07 +01:00
Extract grammar
Grammar is now defined in <!-- GRAMMAR --> blocks. The actually displayed grammar will be auto-generated.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/.commit-template
|
||||
*.swp
|
||||
|
||||
@@ -3,6 +3,25 @@
|
||||
A PHP *program* consists of one or more source files, known formally as
|
||||
*scripts*.
|
||||
|
||||
<!-- GRAMMAR
|
||||
script:
|
||||
script-section
|
||||
script script-section
|
||||
|
||||
script-section:
|
||||
text? start-tag statement-list? end-tag? text?
|
||||
|
||||
start-tag:
|
||||
'<?php'
|
||||
'<?='
|
||||
|
||||
end-tag:
|
||||
'?>'
|
||||
|
||||
text:
|
||||
"arbitrary text not containing any of" start-tag "sequences"
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>script:</i>
|
||||
<i>script-section</i>
|
||||
|
||||
@@ -119,6 +119,25 @@ the requirements of a numeric string, and whose trailing characters are
|
||||
non-numeric. A *non-numeric string* is a string that is not a numeric
|
||||
string.
|
||||
|
||||
<!-- GRAMMAR
|
||||
str-numeric::
|
||||
str-whitespace? sign? str-number
|
||||
|
||||
str-whitespace::
|
||||
str-whitespace? str-whitespace-char
|
||||
|
||||
str-whitespace-char::
|
||||
new-line
|
||||
"Space character (U+0020)"
|
||||
"Horizontal-tab character (U+0009)"
|
||||
"Vertical-tab character (U+000B)"
|
||||
"Form-feed character (U+000C)"
|
||||
|
||||
str-number::
|
||||
digit-sequence
|
||||
floating-literal
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>str-numeric::</i>
|
||||
<i>str-whitespace<sub>opt</sub> sign<sub>opt</sub> str-number</i>
|
||||
|
||||
@@ -266,6 +266,21 @@ $b = &colors[100]; // a VSlot for $b is created which points to the array
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
function-static-declaration:
|
||||
'static' static-variable-name-list ';'
|
||||
|
||||
static-variable-name-list:
|
||||
static-variable-declaration
|
||||
static-variable-name-list ',' static-variable-declaration
|
||||
|
||||
static-variable-declaration:
|
||||
variable-name function-static-initializer?
|
||||
|
||||
function-static-initializer:
|
||||
'=' constant-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>function-static-declaration:</i>
|
||||
static <i>static-variable-name-list</i> ;
|
||||
@@ -350,6 +365,15 @@ echo "\$fs = $fs\n"; // $fs = 3
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
global-declaration:
|
||||
'global' variable-name-list ';'
|
||||
|
||||
variable-name-list:
|
||||
simple-variable
|
||||
variable-name-list ',' simple-variable
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>global-declaration:</i>
|
||||
global <i>variable-name-list</i> ;
|
||||
|
||||
@@ -43,13 +43,19 @@ successive indented line contains a possible expansion of the
|
||||
non-terminal given as a sequence of non-terminal or terminal symbols.
|
||||
For example, the production:
|
||||
|
||||
<!-- GRAMMAR
|
||||
single-line-comment-example::
|
||||
'//' input-characters?
|
||||
'#' input-characters?
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>single-line-comment::</i>
|
||||
// input-characters<sub>opt</sub>
|
||||
# input-characters<sub>opt</sub>
|
||||
</pre>
|
||||
|
||||
defines the lexical grammar production *single-line-comment* as being
|
||||
defines the lexical grammar production *single-line-comment-example* as being
|
||||
the terminals `//` or `#`, followed by an optional *input-characters*. Each
|
||||
expansion is listed on a separate line.
|
||||
|
||||
@@ -57,6 +63,13 @@ Although alternatives are usually listed on separate lines, when there
|
||||
is a large number, the shorthand phrase “one of” may precede a list of
|
||||
expansions given on a single line. For example,
|
||||
|
||||
<!-- GRAMMAR
|
||||
hexadecimal-digit-example:: one of
|
||||
'0' '1' '2' '3' '4' '5' '6' '7' '8' '9'
|
||||
'a' 'b' 'c' 'd' 'e' 'f'
|
||||
'A' 'B' 'C' 'D' 'E' 'F'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>hexadecimal-digit:: one of</i>
|
||||
0 1 2 3 4 5 6 7 8 9
|
||||
@@ -73,6 +86,17 @@ script. Each script must conform to this production.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
input-file::
|
||||
input-element
|
||||
input-file input-element
|
||||
|
||||
input-element::
|
||||
comment
|
||||
white-space
|
||||
token
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>input-file::</i>
|
||||
<i>input-element</i>
|
||||
@@ -109,6 +133,31 @@ Two forms of comments are supported: *delimited comments* and
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
comment::
|
||||
single-line-comment
|
||||
delimited-comment
|
||||
|
||||
single-line-comment::
|
||||
'//' input-characters?
|
||||
'#' input-characters?
|
||||
|
||||
input-characters::
|
||||
input-character
|
||||
input-characters input-character
|
||||
|
||||
input-character::
|
||||
"Any source character except" new-line
|
||||
|
||||
new-line::
|
||||
"Carriage-return character (U+000D)"
|
||||
"Line-feed character (U+000A)"
|
||||
"Carriage-return character (U+000D) followed by line-feed character (U+000A)"
|
||||
|
||||
delimited-comment::
|
||||
'/*' "No characters or any source character sequence except */" '*/'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>comment::</i>
|
||||
<i>single-line-comment</i>
|
||||
@@ -161,6 +210,17 @@ new-line, space and horizontal tab characters.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
white-space::
|
||||
white-space-character
|
||||
white-space white-space-character
|
||||
|
||||
white-space-character::
|
||||
new-line
|
||||
"Space character (U+0020)"
|
||||
"Horizontal-tab character (U+0009)"
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>white-space::</i>
|
||||
<i>white-space-character</i>
|
||||
@@ -189,6 +249,17 @@ There are several kinds of source *tokens*:
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
token::
|
||||
variable-name
|
||||
name
|
||||
keyword
|
||||
integer-literal
|
||||
floating-literal
|
||||
string-literal
|
||||
operator-or-punctuator
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>token::</i>
|
||||
<i>variable-name</i>
|
||||
@@ -214,6 +285,40 @@ There are several kinds of source *tokens*:
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
variable-name::
|
||||
'$' name
|
||||
|
||||
namespace-name::
|
||||
name
|
||||
namespace-name '\' name
|
||||
|
||||
namespace-name-as-a-prefix::
|
||||
'\'
|
||||
'\'? namespace-name '\'
|
||||
'namespace' '\'
|
||||
'namespace' '\' namespace-name '\'
|
||||
|
||||
qualified-name::
|
||||
namespace-name-as-a-prefix? name
|
||||
|
||||
name::
|
||||
name-nondigit
|
||||
name name-nondigit
|
||||
name digit
|
||||
|
||||
name-nondigit::
|
||||
nondigit
|
||||
"one of the characters U+0080–U+00ff"
|
||||
|
||||
nondigit:: one of
|
||||
'_'
|
||||
'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm'
|
||||
'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z'
|
||||
'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M'
|
||||
'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>variable-name::</i>
|
||||
$ <i>name</i>
|
||||
@@ -307,6 +412,18 @@ cannot be used as a name.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
keyword:: one of
|
||||
'abstract' 'and' 'array' 'as' 'break' 'callable' 'case' 'catch' 'class' 'clone'
|
||||
'const' 'continue' 'declare' 'default' 'die' 'do' 'echo' 'else' 'elseif' 'empty'
|
||||
'enddeclare' 'endfor' 'endforeach' 'endif' 'endswitch' 'endwhile' 'eval' 'exit'
|
||||
'extends' 'final' 'finally' 'for' 'foreach' 'function' 'global'
|
||||
'goto' 'if' 'implements' 'include' 'include_once' 'instanceof'
|
||||
'insteadof' 'interface' 'isset' 'list' 'namespace' 'new' 'or' 'print' 'private'
|
||||
'protected' 'public' 'require' 'require_once' 'return' 'static' 'switch'
|
||||
'throw' 'trait' 'try' 'unset' 'use' 'var' 'while' 'xor' 'yield' 'yield from'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>keyword:: one of</i>
|
||||
abstract and array as break callable case catch class clone
|
||||
@@ -335,6 +452,53 @@ The source code representation of a value is called a *literal*.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
integer-literal::
|
||||
decimal-literal
|
||||
octal-literal
|
||||
hexadecimal-literal
|
||||
binary-literal
|
||||
|
||||
decimal-literal::
|
||||
nonzero-digit
|
||||
decimal-literal digit
|
||||
|
||||
octal-literal::
|
||||
'0'
|
||||
octal-literal octal-digit
|
||||
|
||||
hexadecimal-literal::
|
||||
hexadecimal-prefix hexadecimal-digit
|
||||
hexadecimal-literal hexadecimal-digit
|
||||
|
||||
hexadecimal-prefix:: one of
|
||||
'0x' '0X'
|
||||
|
||||
binary-literal::
|
||||
binary-prefix binary-digit
|
||||
binary-literal binary-digit
|
||||
|
||||
binary-prefix:: one of
|
||||
'0b' '0B'
|
||||
|
||||
digit:: one of
|
||||
'0' '1' '2' '3' '4' '5' '6' '7' '8' '9'
|
||||
|
||||
nonzero-digit:: one of
|
||||
'1' '2' '3' '4' '5' '6' '7' '8' '9'
|
||||
|
||||
octal-digit:: one of
|
||||
'0' '1' '2' '3' '4' '5' '6' '7'
|
||||
|
||||
hexadecimal-digit:: one of
|
||||
'0' '1' '2' '3' '4' '5' '6' '7' '8' '9'
|
||||
'a' 'b' 'c' 'd' 'e' 'f'
|
||||
'A' 'B' 'C' 'D' 'E' 'F'
|
||||
|
||||
binary-digit:: one of
|
||||
'0' '1'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>integer-literal::</i>
|
||||
<i>decimal-literal</i>
|
||||
@@ -429,6 +593,27 @@ On an implementation using 32-bit int representation
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
floating-literal::
|
||||
fractional-literal exponent-part?
|
||||
digit-sequence exponent-part
|
||||
|
||||
fractional-literal::
|
||||
digit-sequence? '.' digit-sequence
|
||||
digit-sequence '.'
|
||||
|
||||
exponent-part::
|
||||
'e' sign? digit-sequence
|
||||
'E' sign? digit-sequence
|
||||
|
||||
sign:: one of
|
||||
'+' '-'
|
||||
|
||||
digit-sequence::
|
||||
digit
|
||||
digit-sequence digit
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>floating-literal::</i>
|
||||
<i>fractional-literal exponent-part<sub>opt</sub></i>
|
||||
@@ -478,6 +663,14 @@ $values = array(1.23, 3e12, 543.678E-23);
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
string-literal::
|
||||
single-quoted-string-literal
|
||||
double-quoted-string-literal
|
||||
heredoc-string-literal
|
||||
nowdoc-string-literal
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>string-literal::</i>
|
||||
<i>single-quoted-string-literal</i>
|
||||
@@ -504,6 +697,25 @@ The type of a string literal is `string`.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
single-quoted-string-literal::
|
||||
b-prefix? '''' sq-char-sequence? ''''
|
||||
|
||||
sq-char-sequence::
|
||||
sq-char
|
||||
sq-char-sequence sq-char
|
||||
|
||||
sq-char::
|
||||
sq-escape-sequence
|
||||
'\'? "any member of the source character set except single-quote (') or backslash (\)"
|
||||
|
||||
sq-escape-sequence:: one of
|
||||
'\''' '\\'
|
||||
|
||||
b-prefix:: one of
|
||||
'b' 'B'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>single-quoted-string-literal::</i>
|
||||
<i>b-prefix<sub>opt</sub></i> ' <i>sq-char-sequence<sub>opt</sub></i> '
|
||||
@@ -548,6 +760,45 @@ A single-quoted string literal is always a constant expression.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
double-quoted-string-literal::
|
||||
b-prefix? '"' dq-char-sequence? '"'
|
||||
|
||||
dq-char-sequence::
|
||||
dq-char
|
||||
dq-char-sequence dq-char
|
||||
|
||||
dq-char::
|
||||
dq-escape-sequence
|
||||
"any member of the source character set except double-quote ("") or backslash (\)"
|
||||
'\' "any member of the source character set except ""\$efnrtvxX or" octal-digit
|
||||
|
||||
dq-escape-sequence::
|
||||
dq-simple-escape-sequence
|
||||
dq-octal-escape-sequence
|
||||
dq-hexadecimal-escape-sequence
|
||||
dq-unicode-escape-sequence
|
||||
|
||||
dq-simple-escape-sequence:: one of
|
||||
'\"' '\\' '\$' '\e' '\f' '\n' '\r' '\t' '\v'
|
||||
|
||||
dq-octal-escape-sequence::
|
||||
'\' octal-digit
|
||||
'\' octal-digit octal-digit
|
||||
'\' octal-digit octal-digit octal-digit
|
||||
|
||||
dq-hexadecimal-escape-sequence::
|
||||
'\x' hexadecimal-digit hexadecimal-digit?
|
||||
'\X' hexadecimal-digit hexadecimal-digit?
|
||||
|
||||
dq-unicode-escape-sequence::
|
||||
'\u{' codepoint-digits '}'
|
||||
|
||||
codepoint-digits::
|
||||
hexadecimal-digit
|
||||
hexadecimal-digit codepoint-digits
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>double-quoted-string-literal::</i>
|
||||
<i>b-prefix<sub>opt</sub></i> " <i>dq-char-sequence<sub>opt</sub></i> "
|
||||
@@ -652,6 +903,24 @@ ill-formed Unicode escape sequences.
|
||||
|
||||
The variable substitution accepts the following syntax:
|
||||
|
||||
<!-- GRAMMAR
|
||||
string-variable::
|
||||
variable-name offset-or-property?
|
||||
'${' expression '}'
|
||||
|
||||
offset-or-property::
|
||||
offset-in-string
|
||||
property-in-string
|
||||
|
||||
offset-in-string::
|
||||
'[' name ']'
|
||||
'[' variable-name ']'
|
||||
'[' integer-literal ']'
|
||||
|
||||
property-in-string::
|
||||
'->' name
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>string-variable::</i>
|
||||
<i>variable-name</i> <i>offset-or-property<sub>opt</sub></i>
|
||||
@@ -729,6 +998,39 @@ echo "\$myC->p1 = >$myC->p1<\n"; // → $myC->p1 = >2<
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
heredoc-string-literal::
|
||||
b-prefix? '<<<' hd-start-identifier new-line hd-body? hd-end-identifier ';'? new-line
|
||||
|
||||
hd-start-identifier::
|
||||
name
|
||||
'"' name '"'
|
||||
|
||||
hd-end-identifier::
|
||||
name
|
||||
|
||||
hd-body::
|
||||
hd-char-sequence? new-line
|
||||
|
||||
hd-char-sequence::
|
||||
hd-char
|
||||
hd-char-sequence hd-char
|
||||
|
||||
hd-char::
|
||||
hd-escape-sequence
|
||||
"any member of the source character set except backslash (\)"
|
||||
"\ any member of the source character set except \$efnrtvxX or" octal-digit
|
||||
|
||||
hd-escape-sequence::
|
||||
hd-simple-escape-sequence
|
||||
dq-octal-escape-sequence
|
||||
dq-hexadecimal-escape-sequence
|
||||
dq-unicode-escape-sequence
|
||||
|
||||
hd-simple-escape-sequence:: one of
|
||||
'\\' '\$' '\e' '\f' '\n' '\r' '\t' '\v'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>heredoc-string-literal::</i>
|
||||
<i>b-prefix<sub>opt</sub></i> <<< <i>hd-start-identifier new-line hd-body<sub>opt</sub></i> hd-end-identifier ;<i><sub>opt</sub> new-line</i>
|
||||
@@ -812,6 +1114,11 @@ echo ">$s<";
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
nowdoc-string-literal::
|
||||
b-prefix? '<<<' '''' name '''' new-line hd-body? name ';'? new-line
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>nowdoc-string-literal::</i>
|
||||
<i>b-prefix<sub>opt</sub></i> <<< ' <i>name</i> ' <i>new-line hd-body<sub>opt</sub> name</i> ;<i><sub>opt</sub> new-line</i>
|
||||
@@ -858,6 +1165,14 @@ echo ">$s<\n\n";
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
operator-or-punctuator:: one of
|
||||
'[' ']' '(' ')' '{' '}' '.' '->' '++' '--' '**' '*' '+' '-' '~' '!'
|
||||
'$' '/' '%' '<<' '>>' '<' '>' '<=' '>=' '==' '===' '!=' '!==' '^' '|'
|
||||
'&' '&&' '||' '?' ':' ';' '=' '**=' '*=' '/=' '%=' '+=' '-=' '.=' '<<='
|
||||
'>>=' '&=' '^=' '|=' ',' '??' '<=>' '...' '\'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>operator-or-punctuator:: one of</i>
|
||||
[ ] ( ) { } . -> ++ -- ** * + - ~ !
|
||||
|
||||
@@ -89,6 +89,18 @@ function, `$a` need not actually be incremented.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
primary-expression:
|
||||
variable
|
||||
class-constant-access-expression
|
||||
constant-access-expression
|
||||
literal
|
||||
array-creation-expression
|
||||
intrinsic
|
||||
anonymous-function-creation-expression
|
||||
'(' expression ')'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>primary-expression:</i>
|
||||
<i>variable</i>
|
||||
@@ -121,6 +133,13 @@ the un-parenthesized expression.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
simple-variable:
|
||||
variable-name
|
||||
'$' simple-variable
|
||||
'$' '{' expression '}'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>simple-variable:</i>
|
||||
<i>variable-name</i>
|
||||
@@ -177,6 +196,20 @@ ${1 + f1()} = 1000; // equivalent to ${3.5} = 1000
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
dereferencable-expression:
|
||||
variable
|
||||
'(' expression ')'
|
||||
array-creation-expression
|
||||
string-literal
|
||||
|
||||
callable-expression:
|
||||
callable-variable
|
||||
'(' expression ')'
|
||||
array-creation-expression
|
||||
string-literal
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>dereferencable-expression:</i>
|
||||
<i>variable</i>
|
||||
@@ -214,6 +247,20 @@ call operator](#function-call-operator).
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
callable-variable:
|
||||
simple-variable
|
||||
subscript-expression
|
||||
member-call-expression
|
||||
scoped-call-expression
|
||||
function-call-expression
|
||||
|
||||
variable:
|
||||
callable-variable
|
||||
scoped-property-access-expression
|
||||
member-access-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>callable-variable:</i>
|
||||
<i>simple-variable</i>
|
||||
@@ -246,6 +293,11 @@ An expression that is not a *variable* can never act as an lvalue.
|
||||
|
||||
###Constant Access Expression
|
||||
|
||||
<!-- GRAMMAR
|
||||
constant-access-expression:
|
||||
qualified-name
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>constant-access-expression:</i>
|
||||
<i>qualified-name</i>
|
||||
@@ -264,6 +316,13 @@ with name *qualified-name*.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
literal:
|
||||
integer-literal
|
||||
floating-literal
|
||||
string-literal
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>literal:</i>
|
||||
<i>integer-literal</i>
|
||||
@@ -287,6 +346,24 @@ A literal evaluates to its value, as specified in the lexical specification for
|
||||
####General
|
||||
|
||||
**Syntax**
|
||||
<!-- GRAMMAR
|
||||
intrinsic:
|
||||
intrinsic-construct
|
||||
intrinsic-operator
|
||||
|
||||
intrinsic-construct:
|
||||
echo-intrinsic
|
||||
list-intrinsic
|
||||
unset-intrinsic
|
||||
|
||||
intrinsic-operator:
|
||||
empty-intrinsic
|
||||
eval-intrinsic
|
||||
exit-intrinsic
|
||||
isset-intrinsic
|
||||
print-intrinsic
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>intrinsic:</i>
|
||||
<i>intrinsic-construct</i>
|
||||
@@ -331,6 +408,15 @@ other values or expressions could be used.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
echo-intrinsic:
|
||||
'echo' expression-list
|
||||
|
||||
expression-list:
|
||||
expression
|
||||
expression-list ',' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>echo-intrinsic:</i>
|
||||
echo <i>expression-list</i>
|
||||
@@ -376,6 +462,11 @@ echo "$v3\n";
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
empty-intrinsic:
|
||||
'empty' '(' expression ')'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>empty-intrinsic:</i>
|
||||
empty ( <i>expression</i> )
|
||||
@@ -415,6 +506,11 @@ empty($v); // results in FALSE
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
eval-intrinsic:
|
||||
'eval' '(' expression ')'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>eval-intrinsic:</i>
|
||||
eval ( <i>expression</i> )
|
||||
@@ -457,6 +553,14 @@ eval("echo \$str . \"\\n\";"); // → echo $str . "\n"; → prints Hello
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
exit-intrinsic:
|
||||
'exit'
|
||||
'exit' '(' expression? ')'
|
||||
'die'
|
||||
'die' '(' expression? ')'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>exit-intrinsic:</i>
|
||||
exit
|
||||
@@ -505,6 +609,15 @@ exit;
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
isset-intrinsic:
|
||||
'isset' '(' variable-list ')'
|
||||
|
||||
variable-list:
|
||||
variable
|
||||
variable-list ',' variable
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>isset-intrinsic:</i>
|
||||
isset ( <i>variable-list</i> )
|
||||
@@ -546,6 +659,28 @@ isset($v1, $v2, $v3); // results in FALSE
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
list-intrinsic:
|
||||
'list' '(' list-expression-list ')'
|
||||
|
||||
list-expression-list:
|
||||
unkeyed-list-expression-list
|
||||
keyed-list-expression-list ','?
|
||||
|
||||
unkeyed-list-expression-list:
|
||||
list-or-variable
|
||||
','
|
||||
unkeyed-list-expression-list ',' list-or-variable?
|
||||
|
||||
keyed-list-expression-list:
|
||||
expression '=>' list-or-variable
|
||||
keyed-list-expression-list ',' expression '=>' list-or-variable
|
||||
|
||||
list-or-variable:
|
||||
list-intrinsic
|
||||
expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>list-intrinsic:</i>
|
||||
list ( <i>list-expression-list</i> )
|
||||
@@ -660,6 +795,11 @@ list(0 => list($x1, $x2), 1 => list($x2, $y2)) = [[1, 2], [3, 4]];
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
print-intrinsic:
|
||||
'print' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>print-intrinsic:</i>
|
||||
print <i>expression</i>
|
||||
@@ -701,6 +841,11 @@ $a > $b ? print "..." : print "...";
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
unset-intrinsic:
|
||||
'unset' '(' variable-list ')'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>unset-intrinsic:</i>
|
||||
unset ( <i>variable-list</i> )
|
||||
@@ -752,6 +897,18 @@ unset($x->m); // if m is a dynamic property, $x->__unset("m") is called
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
anonymous-function-creation-expression:
|
||||
'static?' 'function' '&'? '(' parameter-declaration-list? ')' return-type? anonymous-function-use-clause? compound-statement
|
||||
|
||||
anonymous-function-use-clause:
|
||||
'use' '(' use-variable-name-list ')'
|
||||
|
||||
use-variable-name-list:
|
||||
'&'? variable-name
|
||||
use-variable-name-list ',' '&'? variable-name
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>anonymous-function-creation-expression:</i>
|
||||
static<sub>opt</sub> function &<sub>opt</sub> ( <i>parameter-declaration-list<sub>opt</sub></i> ) <i>return-type<sub>opt</sub></i> <i>anonymous-function-use-clause<sub>opt</sub></i>
|
||||
@@ -837,6 +994,16 @@ class C
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
postfix-expression:
|
||||
primary-expression
|
||||
clone-expression
|
||||
object-creation-expression
|
||||
postfix-increment-expression
|
||||
postfix-decrement-expression
|
||||
exponentiation-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>postfix-expression:</i>
|
||||
<i>primary-expression</i>
|
||||
@@ -864,6 +1031,11 @@ These operators associate left-to-right.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
clone-expression:
|
||||
'clone' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>clone-expression:</i>
|
||||
clone <i>expression</i>
|
||||
@@ -918,6 +1090,18 @@ $obj2 = clone $obj1; // creates a new Manager that is a deep copy
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
object-creation-expression:
|
||||
'new' class-type-designator '(' argument-expression-list? ')'
|
||||
'new' class-type-designator
|
||||
'new' 'class' '(' argument-expression-list? ')' class-base-clause? class-interface-clause? '{' class-member-declarations? '}'
|
||||
'new' 'class' class-base-clause? class-interface-clause? '{' class-member-declarations? '}'
|
||||
|
||||
class-type-designator:
|
||||
qualified-name
|
||||
expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>object-creation-expression:</i>
|
||||
new <i>class-type-designator</i> ( <i>argument-expression-list<sub>opt</sub></i> )
|
||||
@@ -1010,6 +1194,29 @@ $v2 = new class (100) extends C1 implements I1, I2 {
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
array-creation-expression:
|
||||
'array' '(' array-initializer? ')'
|
||||
'[' array-initializer? ']'
|
||||
|
||||
array-initializer:
|
||||
array-initializer-list ','?
|
||||
|
||||
array-initializer-list:
|
||||
array-element-initializer
|
||||
array-element-initializer ',' array-initializer-list
|
||||
|
||||
array-element-initializer:
|
||||
'&'? element-value
|
||||
element-key '=>' '&'? element-value
|
||||
|
||||
element-key:
|
||||
expression
|
||||
|
||||
element-value:
|
||||
expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>array-creation-expression:</i>
|
||||
array ( <i>array-initializer<sub>opt</sub></i> )
|
||||
@@ -1104,6 +1311,12 @@ for ($i = -1; $i <= 2; ++$i) { echo $v[$i]; } // retrieves via keys -1, 0, 1, 2
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
subscript-expression:
|
||||
dereferencable-expression '[' expression? ']'
|
||||
dereferencable-expression '{' expression '}' "<b>[Deprecated form]</b>"
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>subscript-expression:</i>
|
||||
<i>dereferencable-expression</i> [ <i>expression<sub>opt</sub></i> ]
|
||||
@@ -1268,6 +1481,23 @@ $x = $vect1[1]; // calls Vector::offsetGet(1)
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
function-call-expression:
|
||||
qualified-name '(' argument-expression-list? ')'
|
||||
callable-expression '(' argument-expression-list? ')'
|
||||
|
||||
argument-expression-list:
|
||||
argument-expression
|
||||
argument-expression-list ',' argument-expression
|
||||
|
||||
argument-expression:
|
||||
variadic-unpacking
|
||||
assignment-expression
|
||||
|
||||
variadic-unpacking:
|
||||
'...' assignment-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>function-call-expression:</i>
|
||||
<i>qualified-name</i> ( <i>argument-expression-list<sub>opt</sub></i> )
|
||||
@@ -1392,6 +1622,16 @@ $anon(); // call the anonymous function encapsulated by that object
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
member-access-expression:
|
||||
dereferencable-expression '->' member-name
|
||||
|
||||
member-name:
|
||||
name
|
||||
simple-variable
|
||||
'{' expression '}'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>member-access-expression:</i>
|
||||
<i>dereferencable-expression</i> -> <i>member-name</i>
|
||||
@@ -1472,6 +1712,11 @@ $c = $p1->color; // turned into $c = $p1->__get("color");
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
member-call-expression:
|
||||
dereferencable-expression '->' member-name '(' argument-expression-list? ')'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>member-call-expression:</i>
|
||||
<i>dereferencable-expression</i> -> <i>member-name</i> ( <i>argument-expression-list<sub>opt</sub></i> )
|
||||
@@ -1513,6 +1758,14 @@ See [member access examples](#member-access-operator).
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
postfix-increment-expression:
|
||||
variable '++'
|
||||
|
||||
postfix-decrement-expression:
|
||||
variable '--'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>postfix-increment-expression:</i>
|
||||
<i>variable</i> ++
|
||||
@@ -1547,6 +1800,27 @@ $a = array(100, 200); $v = $a[1]++; // old value of $ia[1] (200) is assigned
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
scoped-property-access-expression:
|
||||
scope-resolution-qualifier '::' simple-variable
|
||||
|
||||
scoped-call-expression:
|
||||
scope-resolution-qualifier '::' member-name '(' argument-expression-list? ')'
|
||||
|
||||
class-constant-access-expression:
|
||||
scope-resolution-qualifier '::' name
|
||||
|
||||
scope-resolution-qualifier:
|
||||
relative-scope
|
||||
qualified-name
|
||||
dereferencable-expression
|
||||
|
||||
relative-scope:
|
||||
'self'
|
||||
'parent'
|
||||
'static'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>scoped-property-access-expression:</i>
|
||||
<i>scope-resolution-qualifier</i> :: <i>simple-variable</i>
|
||||
@@ -1673,6 +1947,11 @@ class Point
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
exponentiation-expression:
|
||||
expression '**' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>exponentiation-expression:</i>
|
||||
<i>expression</i> ** <i>expression</i>
|
||||
@@ -1709,6 +1988,17 @@ for each. **Examples**
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
unary-expression:
|
||||
postfix-expression
|
||||
prefix-increment-expression
|
||||
prefix-decrement-expression
|
||||
unary-op-expression
|
||||
error-control-expression
|
||||
shell-command-expression
|
||||
cast-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>unary-expression:</i>
|
||||
<i>postfix-expression</i>
|
||||
@@ -1738,6 +2028,14 @@ These operators associate right-to-left.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
prefix-increment-expression:
|
||||
'++' variable
|
||||
|
||||
prefix-decrement-expression:
|
||||
'--' variable
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>prefix-increment-expression:</i>
|
||||
++ <i>variable</i>
|
||||
@@ -1848,6 +2146,14 @@ $a = "^^Z^^"; ++$a; // $a is now "^^Z^^"
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
unary-op-expression:
|
||||
unary-operator cast-expression
|
||||
|
||||
unary-operator: one of
|
||||
'+' '-' '!' '~'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>unary-op-expression:</i>
|
||||
<i>unary-operator cast-expression</i>
|
||||
@@ -1939,6 +2245,11 @@ $s = "\x86\x97"; $s = ~$s; // $s is "yh"
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
error-control-expression:
|
||||
'@' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>error-control-expression:</i>
|
||||
@ <i>expression</i>
|
||||
@@ -1995,6 +2306,11 @@ $x = $tmp;
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
shell-command-expression:
|
||||
'`' dq-char-sequence? '`'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>shell-command-expression:</i>
|
||||
` <i>dq-char-sequence<sub>opt</sub></i> `
|
||||
@@ -2032,6 +2348,16 @@ $result = `$d {$f}`; // result is the output of command dir *.*
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
cast-expression:
|
||||
unary-expression
|
||||
'(' cast-type ')' expression
|
||||
|
||||
cast-type: one of
|
||||
'array' 'binary' 'bool' 'boolean' 'double' 'int' 'integer' 'float' 'object'
|
||||
'real' 'string' 'unset'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>cast-expression:</i>
|
||||
<i>unary-expression</i>
|
||||
@@ -2087,6 +2413,19 @@ A *cast-type* of `unset` always results in a value of `NULL`. (This use of
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
instanceof-expression:
|
||||
unary-expression
|
||||
instanceof-subject 'instanceof' instanceof-type-designator
|
||||
|
||||
instanceof-subject:
|
||||
expression
|
||||
|
||||
instanceof-type-designator:
|
||||
qualified-name
|
||||
expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>instanceof-expression:</i>
|
||||
<i>unary-expression</i>
|
||||
@@ -2156,6 +2495,14 @@ var_dump($e2 instanceof $e1); // TRUE
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
multiplicative-expression:
|
||||
instanceof-expression
|
||||
multiplicative-expression '*' instanceof-expression
|
||||
multiplicative-expression '/' instanceof-expression
|
||||
multiplicative-expression '%' instanceof-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>multiplicative-expression:</i>
|
||||
<i>instanceof-expression</i>
|
||||
@@ -2227,6 +2574,14 @@ These operators associate left-to-right.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
additive-expression:
|
||||
multiplicative-expression
|
||||
additive-expression '+' multiplicative-expression
|
||||
additive-expression '-' multiplicative-expression
|
||||
additive-expression '.' multiplicative-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>additive-expression:</i>
|
||||
<i>multiplicative-expression</i>
|
||||
@@ -2301,6 +2656,13 @@ TRUE . NULL; // string with value "1"
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
shift-expression:
|
||||
additive-expression
|
||||
shift-expression '<<' additive-expression
|
||||
shift-expression '>>' additive-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>shift-expression:</i>
|
||||
<i>additive-expression</i>
|
||||
@@ -2361,6 +2723,16 @@ These operators associate left-to-right.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
relational-expression:
|
||||
shift-expression
|
||||
relational-expression '<' shift-expression
|
||||
relational-expression '>' shift-expression
|
||||
relational-expression '<=' shift-expression
|
||||
relational-expression '>=' shift-expression
|
||||
relational-expression '<=>' shift-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>relational-expression:</i>
|
||||
<i>shift-expression</i>
|
||||
@@ -2491,6 +2863,16 @@ function order_func($a, $b) {
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
equality-expression:
|
||||
relational-expression
|
||||
equality-expression '==' relational-expression
|
||||
equality-expression '!=' relational-expression
|
||||
equality-expression '<>' relational-expression
|
||||
equality-expression '===' relational-expression
|
||||
equality-expression '!==' relational-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>equality-expression:</i>
|
||||
<i>relational-expression</i>
|
||||
@@ -2549,6 +2931,12 @@ TRUE !== 100 // result has value TRUE
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
bitwise-AND-expression:
|
||||
equality-expression
|
||||
bitwise-AND-expression '&' equality-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>bitwise-AND-expression:</i>
|
||||
<i>equality-expression</i>
|
||||
@@ -2594,6 +2982,12 @@ $uLetter = $lLetter & ~0x20; // clear the 6th bit to make letter 'S'
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
bitwise-exc-OR-expression:
|
||||
bitwise-AND-expression
|
||||
bitwise-exc-OR-expression '^' bitwise-AND-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>bitwise-exc-OR-expression:</i>
|
||||
<i>bitwise-AND-expression</i>
|
||||
@@ -2641,6 +3035,12 @@ $v1 = $v1 ^ $v2; // $v1 is now -987, and $v2 is now 1234
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
bitwise-inc-OR-expression:
|
||||
bitwise-exc-OR-expression
|
||||
bitwise-inc-OR-expression '|' bitwise-exc-OR-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>bitwise-inc-OR-expression:</i>
|
||||
<i>bitwise-exc-OR-expression</i>
|
||||
@@ -2686,6 +3086,12 @@ $lLetter = $upCaseLetter | 0x20; // set the 6th bit to make letter 'a'
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
logical-AND-expression-1:
|
||||
bitwise-inc-OR-expression
|
||||
logical-AND-expression-1 '&&' bitwise-inc-OR-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>logical-AND-expression-1:</i>
|
||||
<i>bitwise-inc-OR-expression</i>
|
||||
@@ -2715,6 +3121,12 @@ if ($month > 1 && $month <= 12) ...
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
logical-inc-OR-expression-1:
|
||||
logical-AND-expression-1
|
||||
logical-inc-OR-expression-1 '||' logical-AND-expression-1
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>logical-inc-OR-expression-1:</i>
|
||||
<i>logical-AND-expression-1</i>
|
||||
@@ -2741,6 +3153,12 @@ if ($month < 1 || $month > 12) ...
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
conditional-expression:
|
||||
logical-inc-OR-expression-1
|
||||
logical-inc-OR-expression-1 '?' expression? ':' conditional-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>conditional-expression:</i>
|
||||
<i>logical-inc-OR-expression-1</i>
|
||||
@@ -2787,6 +3205,11 @@ function factorial($int)
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
coalesce-expression:
|
||||
logical-inc-OR-expression-1 '??' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>coalesce-expression:</i>
|
||||
<i>logical-inc-OR-expression-1</i> ?? <i>expression</i>
|
||||
@@ -2837,6 +3260,15 @@ var_dump(true ?? foo()); // outputs bool(true), "executed!" does not appear as i
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
assignment-expression:
|
||||
conditional-expression
|
||||
coalesce-expression
|
||||
simple-assignment-expression
|
||||
byref-assignment-expression
|
||||
compound-assignment-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>assignment-expression:</i>
|
||||
<i>conditional-expression</i>
|
||||
@@ -2867,6 +3299,12 @@ These operators associate right-to-left.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
simple-assignment-expression:
|
||||
variable '=' assignment-expression
|
||||
list-intrinsic '=' assignment-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>simple-assignment-expression:</i>
|
||||
<i>variable</i> = <i>assignment-expression</i>
|
||||
@@ -2937,6 +3375,11 @@ $a = new C; // make $a point to the allocated object
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
byref-assignment-expression:
|
||||
variable '=' '&' assignment-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>byref-assignment-expression:</i>
|
||||
<i>variable</i> = & <i>assignment-expression</i>
|
||||
@@ -2979,6 +3422,14 @@ $b =& g2(); // make $b an alias to "xxx"
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
compound-assignment-expression:
|
||||
variable compound-assignment-operator assignment-expression
|
||||
|
||||
compound-assignment-operator: one of
|
||||
'**=' '*=' '/=' '%=' '+=' '-=' '.=' '<<=' '>>=' '&=' '^=' '|='
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>compound-assignment-expression:</i>
|
||||
<i>variable compound-assignment-operator assignment-expression</i>
|
||||
@@ -3017,6 +3468,12 @@ $a[$i++] += 50; // $a[1] = 250, $i → 2
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
logical-AND-expression-2:
|
||||
assignment-expression
|
||||
logical-AND-expression-2 'and' assignment-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>logical-AND-expression-2:</i>
|
||||
<i>assignment-expression</i>
|
||||
@@ -3036,6 +3493,12 @@ same semantics as [operator `&&`](#logical-and-operator-form-1).
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
logical-exc-OR-expression:
|
||||
logical-AND-expression-2
|
||||
logical-exc-OR-expression 'xor' logical-AND-expression-2
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>logical-exc-OR-expression:</i>
|
||||
<i>logical-AND-expression-2</i>
|
||||
@@ -3068,6 +3531,12 @@ f($i++) xor g($i) // the sequence point makes this well-defined
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
logical-inc-OR-expression-2:
|
||||
logical-exc-OR-expression
|
||||
logical-inc-OR-expression-2 'or' logical-exc-OR-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>logical-inc-OR-expression-2:</i>
|
||||
<i>logical-exc-OR-expression</i>
|
||||
@@ -3087,6 +3556,13 @@ same semantics as [operator `||`](#logical-inclusive-or-operator-form-1).
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
yield-expression:
|
||||
logical-inc-OR-expression-2
|
||||
'yield' array-element-initializer
|
||||
'yield from' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>yield-expression:</i>
|
||||
<i>logical-inc-OR-expression-2</i>
|
||||
@@ -3216,6 +3692,15 @@ foreach ($g as $yielded) {
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
expression:
|
||||
yield-expression
|
||||
include-expression
|
||||
include-once-expression
|
||||
require-expression
|
||||
require-once-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>expression:</i>
|
||||
<i>yield-expression</i>
|
||||
@@ -3390,6 +3875,11 @@ echo $x; // hello
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
include-expression:
|
||||
'include' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>include-expression:</i>
|
||||
include <i>expression</i>
|
||||
@@ -3441,6 +3931,11 @@ If ((include 'Positions.php') == 1) ...
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
include-once-expression:
|
||||
'include_once' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>include-once-expression:</i>
|
||||
include_once <i>expression</i>
|
||||
@@ -3488,6 +3983,11 @@ $c1 = new Circle(9, 7, 2.4);
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
require-expression:
|
||||
'require' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>require-expression:</i>
|
||||
require <i>expression</i>
|
||||
@@ -3507,6 +4007,11 @@ produces a fatal error.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
require-once-expression:
|
||||
'require_once' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>require-once-expression:</i>
|
||||
require_once <i>expression</i>
|
||||
@@ -3533,6 +4038,11 @@ and relative path) still are considered the same file.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
constant-expression:
|
||||
expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>constant-expression:</i>
|
||||
<i>expression</i>
|
||||
|
||||
@@ -4,6 +4,27 @@
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
statement:
|
||||
compound-statement
|
||||
named-label-statement
|
||||
expression-statement
|
||||
selection-statement
|
||||
iteration-statement
|
||||
jump-statement
|
||||
try-statement
|
||||
declare-statement
|
||||
const-declaration
|
||||
function-definition
|
||||
class-declaration
|
||||
interface-declaration
|
||||
trait-declaration
|
||||
namespace-definition
|
||||
namespace-use-declaration
|
||||
global-declaration
|
||||
function-static-declaration
|
||||
-->
|
||||
|
||||
<pre>
|
||||
|
||||
<i>statement:</i>
|
||||
@@ -49,6 +70,15 @@
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
compound-statement:
|
||||
'{' statement-list? '}'
|
||||
|
||||
statement-list:
|
||||
statement
|
||||
statement-list statement
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>compound-statement:</i>
|
||||
{ <i>statement-list<sub>opt</sub></i> }
|
||||
@@ -90,6 +120,11 @@ while (condition)
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
named-label-statement:
|
||||
name ';' statement
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>named-label-statement:</i>
|
||||
<i>name</i> : <i>statement</i>
|
||||
@@ -117,6 +152,11 @@ execution.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
expression-statement:
|
||||
expression? ';'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>expression-statement:</i>
|
||||
<i>expression<sub>opt</sub></i> ;
|
||||
@@ -170,6 +210,12 @@ done:
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
selection-statement:
|
||||
if-statement
|
||||
switch-statement
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>selection-statement:</i>
|
||||
<i>if-statement</i>
|
||||
@@ -190,6 +236,32 @@ selects among a set of statements.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
if-statement:
|
||||
'if' '(' expression ')' statement elseif-clauses-1? else-clause-1?
|
||||
'if' '(' expression ')' ':' statement-list elseif-clauses-2? else-clause-2? 'endif' ';'
|
||||
|
||||
elseif-clauses-1:
|
||||
elseif-clause-1
|
||||
elseif-clauses-1 elseif-clause-1
|
||||
|
||||
elseif-clause-1:
|
||||
'elseif' '(' expression ')' statement
|
||||
|
||||
else-clause-1:
|
||||
'else' statement
|
||||
|
||||
elseif-clauses-2:
|
||||
elseif-clause-2
|
||||
elseif-clauses-2 elseif-clause-2
|
||||
|
||||
elseif-clause-2:
|
||||
'elseif' '(' expression ')' ':' statement-list
|
||||
|
||||
else-clause-2:
|
||||
'else' ':' statement-list
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>if-statement:</i>
|
||||
if ( <i>expression</i> ) <i>statement elseif-clauses-1<sub>opt</sub> else-clause-1<sub>opt</sub></i>
|
||||
@@ -283,6 +355,26 @@ else // this else does go with the outer if
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
switch-statement:
|
||||
'switch' '(' expression ')' '{' case-statements? '}'
|
||||
'switch' '(' expression ')' ':' case-statements? 'endswitch;'
|
||||
|
||||
case-statements:
|
||||
case-statement case-statements?
|
||||
default-statement case-statements?
|
||||
|
||||
case-statement:
|
||||
'case' expression case-default-label-terminator statement-list?
|
||||
|
||||
default-statement:
|
||||
'default' case-default-label-terminator statement-list?
|
||||
|
||||
case-default-label-terminator:
|
||||
':'
|
||||
';'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>switch-statement:</i>
|
||||
switch ( <i>expression</i> ) { <i>case-statements<sub>opt</sub></i> }
|
||||
@@ -397,6 +489,14 @@ case $v < $a: // non-constant expression
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
iteration-statement:
|
||||
while-statement
|
||||
do-statement
|
||||
for-statement
|
||||
foreach-statement
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>iteration-statement:</i>
|
||||
<i>while-statement</i>
|
||||
@@ -416,6 +516,12 @@ case $v < $a: // non-constant expression
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
while-statement:
|
||||
'while' '(' expression ')' statement
|
||||
'while' '(' expression ')' ':' statement-list 'endwhile' ';'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>while-statement:</i>
|
||||
while ( <i>expression</i> ) <i>statement</i>
|
||||
@@ -464,6 +570,11 @@ while (TRUE)
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
do-statement:
|
||||
'do' statement 'while' '(' expression ')' ';'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>do-statement:</i>
|
||||
do <i>statement</i> while ( <i>expression</i> ) ;
|
||||
@@ -508,6 +619,25 @@ while ($i <= 10);
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
for-statement:
|
||||
'for' '(' for-initializer? ';' for-control? ';' for-end-of-loop? ')' statement
|
||||
'for' '(' for-initializer? ';' for-control? ';' for-end-of-loop? ')' ':' statement-list 'endfor' ';'
|
||||
|
||||
for-initializer:
|
||||
for-expression-group
|
||||
|
||||
for-control:
|
||||
for-expression-group
|
||||
|
||||
for-end-of-loop:
|
||||
for-expression-group
|
||||
|
||||
for-expression-group:
|
||||
expression
|
||||
for-expression-group ',' expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>for-statement:</i>
|
||||
for ( <i>for-initializer<sub>opt</sub></i> ; <i>for-control<sub>opt</sub></i> ; <i>for-end-of-loop<sub>opt</sub></i> ) <i>statement</i>
|
||||
@@ -600,6 +730,22 @@ for ($a = 100, $i = 1; ++$i, $i <= 10; ++$i, $a -= 10)
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
foreach-statement:
|
||||
'foreach' '(' foreach-collection-name 'as' foreach-key? foreach-value ')' 'statement'
|
||||
'foreach' '(' foreach-collection-name 'as' foreach-key? foreach-value ')' ':' statement-list 'endforeach' ';'
|
||||
|
||||
foreach-collection-name:
|
||||
expression
|
||||
|
||||
foreach-key:
|
||||
expression '=>'
|
||||
|
||||
foreach-value:
|
||||
'&'? expression
|
||||
list-intrinsic
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>foreach-statement:</i>
|
||||
foreach ( <i>foreach-collection-name</i> as <i>foreach-key<sub>opt</sub> foreach-value</i> ) statement
|
||||
@@ -685,6 +831,15 @@ foreach ($colors as &$color) // note the &
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
jump-statement:
|
||||
goto-statement
|
||||
continue-statement
|
||||
break-statement
|
||||
return-statement
|
||||
throw-statement
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>jump-statement:</i>
|
||||
<i>goto-statement</i>
|
||||
@@ -706,6 +861,11 @@ foreach ($colors as &$color) // note the &
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
goto-statement:
|
||||
'goto' name ';'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>goto-statement:</i>
|
||||
goto <i>name</i> ;
|
||||
@@ -758,6 +918,14 @@ done:
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
continue-statement:
|
||||
'continue' breakout-level? ';'
|
||||
|
||||
breakout-level:
|
||||
integer-literal
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>continue-statement:</i>
|
||||
continue <i>breakout-level<sub>opt</sub></i> ;
|
||||
@@ -810,6 +978,11 @@ for ($i = 1; $i <= 5; ++$i)
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
break-statement:
|
||||
'break' breakout-level? ';'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>break-statement:</i>
|
||||
break <i>breakout-level<sub>opt</sub></i> ;
|
||||
@@ -875,6 +1048,11 @@ for ($i = 10; $i <= 40; $i +=10)
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
return-statement:
|
||||
'return' expression? ';'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>return-statement:</i>
|
||||
return <i>expression<sub>opt</sub></i> ;
|
||||
@@ -987,6 +1165,11 @@ enclosing function, `$a` need not actually be incremented.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
throw-statement:
|
||||
'throw' expression ';'
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>throw-statement:</i>
|
||||
throw <i>expression</i> ;
|
||||
@@ -1027,6 +1210,23 @@ throw new MyException;
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
try-statement:
|
||||
'try' compound-statement catch-clauses
|
||||
'try' compound-statement finally-clause
|
||||
'try' compound-statement catch-clauses finally-clause
|
||||
|
||||
catch-clauses:
|
||||
catch-clause
|
||||
catch-clauses catch-clause
|
||||
|
||||
catch-clause:
|
||||
'catch' '(' qualified-name variable-name ')' compound-statement
|
||||
|
||||
finally-clause:
|
||||
'finally' compound-statement
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>try-statement:</i>
|
||||
try <i>compound-statement catch-clauses</i>
|
||||
@@ -1128,6 +1328,18 @@ finally { ... }
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
declare-statement:
|
||||
'declare' '(' declare-directive ')' statement
|
||||
'declare' '(' declare-directive ')' ':' statement-list 'enddeclare' ';'
|
||||
'declare' '(' declare-directive ')' ';'
|
||||
|
||||
declare-directive:
|
||||
'ticks' '=' literal
|
||||
'encoding' '=' literal
|
||||
'strict_types' '=' literal
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>declare-statement:</i>
|
||||
declare ( <i>declare-directive</i> ) <i>statement</i>
|
||||
|
||||
@@ -47,6 +47,51 @@ A function is called via the function-call operator [`()`](10-expressions.md#fun
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
function-definition:
|
||||
function-definition-header compound-statement
|
||||
|
||||
function-definition-header:
|
||||
'function' '&'? name '(' parameter-declaration-list? ')' return-type?
|
||||
|
||||
parameter-declaration-list:
|
||||
simple-parameter-declaration-list
|
||||
variadic-declaration-list
|
||||
|
||||
simple-parameter-declaration-list:
|
||||
parameter-declaration
|
||||
parameter-declaration-list ',' parameter-declaration
|
||||
|
||||
variadic-declaration-list:
|
||||
simple-parameter-declaration-list ',' variadic-parameter
|
||||
variadic-parameter
|
||||
|
||||
parameter-declaration:
|
||||
type-declaration? '&'? variable-name default-argument-specifier?
|
||||
|
||||
variadic-parameter:
|
||||
type-declaration? '&'? '...' variable-name
|
||||
|
||||
return-type:
|
||||
':' type-declaration
|
||||
':' 'void'
|
||||
|
||||
type-declaration:
|
||||
'array'
|
||||
'callable'
|
||||
scalar-type
|
||||
qualified-name
|
||||
|
||||
scalar-type:
|
||||
'bool'
|
||||
'float'
|
||||
'int'
|
||||
'string'
|
||||
|
||||
default-argument-specifier:
|
||||
'=' constant-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>function-definition:</i>
|
||||
<i>function-definition-header compound-statement</i>
|
||||
|
||||
@@ -58,6 +58,22 @@ While PHP supports *anonymous class types*, such a type cannot be declared using
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
class-declaration:
|
||||
class-modifier? 'class' name class-base-clause? class-interface-clause? '{' class-member-declarations? '}'
|
||||
|
||||
class-modifier:
|
||||
'abstract'
|
||||
'final'
|
||||
|
||||
class-base-clause:
|
||||
'extends' qualified-name
|
||||
|
||||
class-interface-clause:
|
||||
'implements' qualified-name
|
||||
class-interface-clause ',' qualified-name
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>class-declaration:</i>
|
||||
<i>class-modifier<sub>opt</sub></i> class <i>name class-base-clause<sub>opt</sub> class-interface-clause<sub>opt</sub></i> { class-member-declarations<sub>opt</sub></i> }
|
||||
@@ -197,6 +213,20 @@ class MyList implements MyCollection
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
class-member-declarations:
|
||||
class-member-declaration
|
||||
class-member-declarations class-member-declaration
|
||||
|
||||
class-member-declaration:
|
||||
class-const-declaration
|
||||
property-declaration
|
||||
method-declaration
|
||||
constructor-declaration
|
||||
destructor-declaration
|
||||
trait-use-clause
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>class-member-declarations:</i>
|
||||
<i>class-member-declaration</i>
|
||||
@@ -386,6 +416,21 @@ Widget::__callStatic('sMethod', array(NULL, 1.234))
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
const-declaration:
|
||||
'const' const-elements ';'
|
||||
|
||||
class-const-declaration:
|
||||
visibility-modifier? 'const' const-elements ';'
|
||||
|
||||
const-elements:
|
||||
const-element
|
||||
const-elements const-element
|
||||
|
||||
const-element:
|
||||
name '=' constant-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>const-declaration:</i>
|
||||
const <i>const-elements</i> ;
|
||||
@@ -447,6 +492,34 @@ $col = Automobile::DEFAULT_COLOR;
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
property-declaration:
|
||||
property-modifier property-elements ';'
|
||||
|
||||
property-modifier:
|
||||
'var'
|
||||
visibility-modifier static-modifier?
|
||||
static-modifier visibility-modifier?
|
||||
|
||||
visibility-modifier:
|
||||
'public'
|
||||
'protected'
|
||||
'private'
|
||||
|
||||
static-modifier:
|
||||
'static'
|
||||
|
||||
property-elements:
|
||||
property-element
|
||||
property-elements property-element
|
||||
|
||||
property-element:
|
||||
variable-name property-initializer? ';'
|
||||
|
||||
property-initializer:
|
||||
'=' constant-expression
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>property-declaration:</i>
|
||||
<i>property-modifier property-elements</i> ;
|
||||
@@ -511,6 +584,21 @@ class Point
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
method-declaration:
|
||||
method-modifiers? function-definition
|
||||
method-modifiers function-definition-header ';'
|
||||
|
||||
method-modifiers:
|
||||
method-modifier
|
||||
method-modifiers method-modifier
|
||||
|
||||
method-modifier:
|
||||
visibility-modifier
|
||||
static-modifier
|
||||
class-modifier
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>method-declaration:</i>
|
||||
<i>method-modifiers<sub>opt</sub> function-definition</i>
|
||||
@@ -569,6 +657,11 @@ examples of abstract methods and their subsequent definitions.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
constructor-declaration:
|
||||
method-modifiers 'function' '&'? '__construct' '(' parameter-declaration-list? ')' compound-statement
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>constructor-declaration:</i>
|
||||
<i>method-modifiers</i> function &<sub>opt</sub> __construct ( <i>parameter-declaration-list<sub>opt</sub></i> ) <i>compound-statement</i>
|
||||
@@ -657,6 +750,11 @@ class MyRangeException extends Exception
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
destructor-declaration:
|
||||
method-modifiers 'function' '&'? '__destruct' '(' ')' compound-statement
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>destructor-declaration:</i>
|
||||
<i>method-modifiers</i> function &<sub>opt</sub> __destruct ( ) <i>compound-statement</i>
|
||||
|
||||
@@ -18,6 +18,15 @@ inherits all members from its *base interface(s)*.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
interface-declaration:
|
||||
'interface' name interface-base-clause? '{' interface-member-declarations? '}'
|
||||
|
||||
interface-base-clause:
|
||||
'extends' qualified-name
|
||||
interface-base-clause ',' qualified-name
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>interface-declaration:</i>
|
||||
interface <i>name interface-base-clause<sub>opt</sub></i> { <i>interface-member-declarations<sub>opt</sub></i> }
|
||||
@@ -82,6 +91,16 @@ processCollection(new MyQueue(...));
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
interface-member-declarations:
|
||||
interface-member-declaration
|
||||
interface-member-declarations interface-member-declaration
|
||||
|
||||
interface-member-declaration:
|
||||
class-const-declaration
|
||||
method-declaration
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>interface-member-declarations:</i>
|
||||
<i>interface-member-declaration</i>
|
||||
|
||||
@@ -42,6 +42,22 @@ that trait is used.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
trait-declaration:
|
||||
'trait' name '{' trait-member-declarations? '}'
|
||||
|
||||
trait-member-declarations:
|
||||
trait-member-declaration
|
||||
trait-member-declarations trait-member-declaration
|
||||
|
||||
trait-member-declaration:
|
||||
property-declaration
|
||||
method-declaration
|
||||
constructor-declaration
|
||||
destructor-declaration
|
||||
trait-use-clauses
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>trait-declaration:</i>
|
||||
trait <i>name</i> { trait-member-declarations<sub>opt</sub></i> }
|
||||
@@ -106,6 +122,38 @@ trait T
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
trait-use-clauses:
|
||||
trait-use-clause
|
||||
trait-use-clauses trait-use-clause
|
||||
|
||||
trait-use-clause:
|
||||
'use' trait-name-list trait-use-specification
|
||||
|
||||
trait-name-list:
|
||||
qualified-name
|
||||
trait-name-list ',' qualified-name
|
||||
|
||||
trait-use-specification:
|
||||
';'
|
||||
'{' trait-select-and-alias-clauses? '}'
|
||||
|
||||
trait-select-and-alias-clauses:
|
||||
trait-select-and-alias-clause
|
||||
trait-select-and-alias-clauses trait-select-and-alias-clause
|
||||
|
||||
trait-select-and-alias-clause:
|
||||
trait-select-insteadof-clause ';'
|
||||
trait-alias-as-clause ';'
|
||||
|
||||
trait-select-insteadof-clause:
|
||||
name 'insteadof' name
|
||||
|
||||
trait-alias-as-clause:
|
||||
name 'as' visibility-modifier? name
|
||||
name 'as' visibility-modifier name?
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>trait-use-clauses:</i>
|
||||
<i>trait-use-clause</i>
|
||||
|
||||
@@ -36,6 +36,12 @@ prefixes are reserved for use by PHP.
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
namespace-definition:
|
||||
'namespace' name ';'
|
||||
'namespace' name? compound-statement
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>namespace-definition:</i>
|
||||
namespace <i>name</i> ;
|
||||
@@ -118,6 +124,41 @@ namespace NS3\Sub1;
|
||||
|
||||
**Syntax**
|
||||
|
||||
<!-- GRAMMAR
|
||||
namespace-use-declaration:
|
||||
'use' namespace-function-or-const? namespace-use-clauses ';'
|
||||
'use' namespace-function-or-const '\'? namespace-name '\' '{' namespace-use-group-clauses-1 '}' ';'
|
||||
'use' '\'? 'namespace-name' '\' '{' namespace-use-group-clauses-2 '}' ';'
|
||||
|
||||
namespace-use-clauses:
|
||||
namespace-use-clause
|
||||
namespace-use-clauses ',' namespace-use-clause
|
||||
|
||||
namespace-use-clause:
|
||||
qualified-name namespace-aliasing-clause?
|
||||
|
||||
namespace-aliasing-clause:
|
||||
'as' name
|
||||
|
||||
namespace-function-or-const:
|
||||
'function'
|
||||
'const'
|
||||
|
||||
namespace-use-group-clauses-1:
|
||||
namespace-use-group-clause-1
|
||||
namespace-use-group-clauses-1 ',' namespace-use-group-clause-1
|
||||
|
||||
namespace-use-group-clause-1:
|
||||
namespace-name namespace-aliasing-clause?
|
||||
|
||||
namespace-use-group-clauses-2:
|
||||
namespace-use-group-clause-2
|
||||
namespace-use-group-clauses-2 ',' namespace-use-group-clause-2
|
||||
|
||||
namespace-use-group-clause-2:
|
||||
namespace-function-or-const? namespace-name namespace-aliasing-clause?
|
||||
-->
|
||||
|
||||
<pre>
|
||||
<i>namespace-use-declaration:</i>
|
||||
use <i>namespace-function-or-const<sub>opt</sub></i> <i>namespace-use-clauses</i> ;
|
||||
|
||||
Reference in New Issue
Block a user