Skip to content

Commit 9b431c7

Browse files
author
cmb
committed
Document deprecation of undefined constant as bare string fallback
Cf. <https://wiki.php.net/rfc/deprecate-bareword-strings>. git-svn-id: http://svn.php.net/repository/phpdoc/en@345953 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 6fed67f commit 9b431c7

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

trunk/language/constants.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ define("__FOO__", "something");
100100
<simpara>
101101
If you use an undefined constant, PHP assumes that you mean
102102
the name of the constant itself, just as if you called it as
103-
a <type>string</type> (CONSTANT vs "CONSTANT"). An error of level
104-
<link linkend="ref.errorfunc">E_NOTICE</link> will be issued
105-
when this happens. See also the manual entry on why
103+
a <type>string</type> (CONSTANT vs "CONSTANT").
104+
This fallback is deprecated as of PHP 7.2.0, and an error of level
105+
<constant>E_WARNING</constant> is issued when it happens
106+
(previously, an error of level
107+
<link linkend="ref.errorfunc">E_NOTICE</link> has been issued instead.)
108+
See also the manual entry on why
106109
<link linkend="language.types.array.foo-bar">$foo[bar]</link> is
107110
wrong (unless you first <function>define</function>
108111
<literal>bar</literal> as a constant). This does not apply to <link

trunk/language/types/array.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,13 @@ echo $foo[bar];
574574
constant named <constant>bar</constant>, then PHP will substitute in the
575575
<type>string</type> <literal>'bar'</literal> and use that.
576576
</para>
577+
<warning>
578+
<simpara>
579+
The fallback to treat an undefined constant as bare string is deprecated as
580+
of PHP 7.2.0, and issues an error of level <constant>E_WARNING</constant>.
581+
Formerly, an error of level <constant>E_NOTICE</constant> has been issued.
582+
</simpara>
583+
</warning>
577584

578585
<note>
579586
<simpara>

0 commit comments

Comments
 (0)