com php-langspec: Specify that qualified constant uses throw Error: spec/07-variables.md
[email protected] (Nikita Popov) Wed, 13 Jul 2016 11:54:16 +0000
| Newsgroups | php.standards.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit: ba380138b88e51321352fdfa43ff47ca0f7d8109=0AAuthor: Nikita Pop= ov <[email protected]> Wed, 13 Jul 2016 13:54:16 +0200=0AParents: 48b= f751fd190b83cb44d9033b4f56eb8ecf4474b=0ABranches: master=0A=0ALink: = http://git.php.net/?p=3Dphp-langspec.git;a=3Dcommitdiff;h=3Dba380138b88e513= 21352fdfa43ff47ca0f7d8109=0A=0ALog:=0ASpecify that qualified constant uses = throw Error=0A=0AChanged paths:=0A M spec/07-variables.md=0A=0A=0ADiff:= =0Adiff --git a/spec/07-variables.md b/spec/07-variables.md=0Aindex 0ed53d0= ..a4c5204 100644=0A--- a/spec/07-variables.md=0A+++ b/spec/07-variables.md= =0A@@ -52,9 +52,9 @@ and is a non-modifiable lvalue.=0A =0A Undefined const= ants are not defined implicitly -- forward usages of constants are also cla= ssified as undefined constants here. A distinction between class/interface = constants and top level constants is made.=0A =0A-For top level constants: = the name of the undefined constant (as string) is used as substitution valu= e. Moreover, a notice is emitted stating that the corresponding constant wa= s undefined.=0A+For top level constants: For unqualified usages, the name o= f the undefined constant (as string) is used as substitution value. Moreove= r, a notice is emitted stating that the corresponding constant was undefine= d. For qualified usages, an exception of type [`Error`](14-classes.md#class= -error) is thrown.=0A =0A-For class/interface constants: a fatal error is p= roduced stating that the corresponding constant was undefined.=0A+For class= /interface constants: An exception of type [`Error`](14-classes.md#class-er= ror) is thrown, stating that the corresponding constant was undefined.=0A = =0A **Examples**=0A =0A@@ -64,7 +64,7 @@ const UPPER_LIMIT =3D MAX_HEIGHT;= =0A define('COEFFICIENT_1', 2.345); // define two d-constants=0A define('FA= ILURE', TRUE);=0A =0A-//examples of undefined constants=0A+// Examples of u= ndefined constants=0A echo NON_EXISTING_CONSTANT; // uses 'NON_EXISTING= _CONSTANT' as substitution=0A // value and = emits a notice stating that the=0A // const= ant was undefined.=0A@@ -79,10 +79,13 @@ echo MAX_LENGTH; //= same here due to a forward usage=0A // 'MA= X_LENGTH' is used as substitution =0A // va= lue and an notice is emitted.=0A =0A+echo \NON_EXISTING_CONSTANT; // qua= lified use of undefined constant. Throws=0A+ = // an exception of type Error.=0A+=0A const MAX_LENGTH =3D 7.5;=0A =0A-ech= o Exception::MESSAGE; // undefined class constant. Emits a fatal =0A= - // error and stops execution.=0A+echo Exce= ption::MESSAGE; // undefined class constant. Throws an exception=0A+= // of type Error.=0A =0A ```=0A