Change 'undefined constant' from E_NOTICE to E_WARNING and mention deprecation

Implements RFC "Deprecate and Remove Bareword (Unquoted) Strings"
[https://wiki.php.net/rfc/deprecate-bareword-strings]
This commit is contained in:
Rowan Collins 2017-03-04 22:47:19 +00:00 committed by Nikita Popov
parent b5b7691ab5
commit 1b565f1393
29 changed files with 37 additions and 32 deletions

2
NEWS
View File

@ -20,6 +20,8 @@ PHP NEWS
php.exe). (Michele Locati)
. Implemented "Convert numeric keys in object/array casts" RFC, fixes
bugs #53838, #61655, #66173, #70925, #72254, etc. (Andrea)
. Implemented "Deprecate and Remove Bareword (Unquoted) Strings" RFC.
(Rowan Collins)
. Raised minimum supported Windows versions to Windows 7/Server 2008 R2.
(Anatol)
. Implemented minor optimization in array_keys/array_values(). (Sara)

View File

@ -35,6 +35,9 @@ PHP 7.2 UPGRADE NOTES
/^(0|(-?[1-9][0-9]*))$/ where PHP_INT_MIN <= n <= PHP_INT_MAX) to integer
keys. This fixes the behaviour of previous versions, where numeric string
property names would become inaccessible string keys.
. Unqualified references to undefined constants now generate a Warning instead
of a notice. They will generate an Error in a future version of PHP.
(https://wiki.php.net/rfc/deprecate-bareword-strings)
. Minimum supported Windows versions are Windows 7/Server 2008 R2.
- BCMath:

View File

@ -23,6 +23,6 @@ string(3) "Foo"
Warning: Constants may only evaluate to scalar values or arrays in %sbug37811.php on line %d
Notice: Use of undefined constant Baz - assumed 'Baz' in %sbug37811.php on line %d
Warning: Use of undefined constant Baz - assumed 'Baz' (this will throw an Error in a future version of PHP) in %sbug37811.php on line %d
string(3) "Baz"
===DONE===

View File

@ -19,14 +19,14 @@ echo f2()."\n";
echo f3()."\n";
?>
--EXPECTF--
Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 13
Warning: Use of undefined constant bar - assumed 'bar' (this will throw an Error in a future version of PHP) in %sbug43344_1.php on line 13
bar
Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 3
Warning: Use of undefined constant bar - assumed 'bar' (this will throw an Error in a future version of PHP) in %sbug43344_1.php on line 3
bar
Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 6
Warning: Use of undefined constant bar - assumed 'bar' (this will throw an Error in a future version of PHP) in %sbug43344_1.php on line 6
bar
Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 9
Warning: Use of undefined constant bar - assumed 'bar' (this will throw an Error in a future version of PHP) in %sbug43344_1.php on line 9
bar

View File

@ -14,4 +14,4 @@ $foo = new Foo();
?>
--EXPECTF--
Notice: Use of undefined constant FOO - assumed 'FOO' in %s on line %d
Warning: Use of undefined constant FOO - assumed 'FOO' (this will throw an Error in a future version of PHP) in %s on line %d

View File

@ -5,4 +5,4 @@ Bug #69755: segfault in ZEND_CONCAT_SPEC_TMPVAR_CONST_HANDLER
c . 10;
?>
--EXPECTF--
Notice: Use of undefined constant c - assumed 'c' in %sbug69755.php on line 2
Warning: Use of undefined constant c - assumed 'c' (this will throw an Error in a future version of PHP) in %sbug69755.php on line 2

View File

@ -5,4 +5,4 @@ Bug #69788: Malformed script causes Uncaught Error in php-cgi, valgrind SIGILL
--EXPECTF--
Notice: Array to string conversion in %s on line %d
Notice: Use of undefined constant t - assumed 't' in %s on line %d
Warning: Use of undefined constant t - assumed 't' (this will throw an Error in a future version of PHP) in %s on line %d

View File

@ -6,7 +6,7 @@ Bug #72944 (Null pointer deref in zval_delref_p).
echo "OK\n";
?>
--EXPECTF--
Notice: Use of undefined constant e - assumed 'e' in %sbug72944.php on line 2
Warning: Use of undefined constant e - assumed 'e' (this will throw an Error in a future version of PHP) in %sbug72944.php on line 2
Notice: Undefined variable: A in %sbug72944.php on line 2
OK

View File

@ -14,7 +14,7 @@ doSomething();
?>
--EXPECTF--
Fatal error: Uncaught Exception: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' in %s:%d
Fatal error: Uncaught Exception: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' (this will throw an Error in a future version of PHP) in %s:%d
Stack trace:
#0 %s(%d): {closure}(%s)
#1 %s(%d): doSomething()

View File

@ -13,6 +13,6 @@ var_dump(foo);
--EXPECTF--
Warning: Constants may only evaluate to scalar values or arrays in %s on line %d
Notice: Use of undefined constant foo - assumed 'foo' in %s on line %d
Warning: Use of undefined constant foo - assumed 'foo' (this will throw an Error in a future version of PHP) in %s on line %d
string(%d) "foo"
resource(%d) of type (stream)

View File

@ -7,6 +7,6 @@ define("ZEND_THREAD_safe", 123);
var_dump(ZEND_THREAD_safe);
?>
--EXPECTF--
Notice: Use of undefined constant ZEND_THREAD_safe - assumed 'ZEND_THREAD_safe' in %s on line %d
Warning: Use of undefined constant ZEND_THREAD_safe - assumed 'ZEND_THREAD_safe' (this will throw an Error in a future version of PHP) in %s on line %d
string(16) "ZEND_THREAD_safe"
int(123)

View File

@ -18,5 +18,5 @@ ok
ok
ok
Notice: Use of undefined constant BAR - assumed 'BAR' in %sns_041.php on line 9
Warning: Use of undefined constant BAR - assumed 'BAR' (this will throw an Error in a future version of PHP) in %sns_041.php on line 9
BAR

View File

@ -11,11 +11,11 @@ echo "\n";
var_dump($a);
echo \unknown;
--EXPECTF--
Notice: Use of undefined constant unknown - assumed 'unknown' in %sns_076.php on line %d
Warning: Use of undefined constant unknown - assumed 'unknown' (this will throw an Error in a future version of PHP) in %sns_076.php on line %d
Notice: Use of undefined constant unknown - assumed 'unknown' in %sns_076.php on line %d
Warning: Use of undefined constant unknown - assumed 'unknown' (this will throw an Error in a future version of PHP) in %sns_076.php on line %d
Notice: Use of undefined constant unknown - assumed 'unknown' in %sns_076.php on line %d
Warning: Use of undefined constant unknown - assumed 'unknown' (this will throw an Error in a future version of PHP) in %sns_076.php on line %d
unknown
array(1) {
["unknown"]=>

View File

@ -611,7 +611,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */
actual_len -= (actual - Z_STRVAL_P(p));
}
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual);
zend_error(E_WARNING, "Use of undefined constant %s - assumed '%s' (this will throw an Error in a future version of PHP)", actual, actual);
if (EG(exception)) {
RESET_CONSTANT_VISITED(p);
return FAILURE;

View File

@ -4908,7 +4908,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, UNUSED, CONST, CONST_FETCH)
actual, Z_STRLEN_P(EX_CONSTANT(opline->op2)) - (actual - Z_STRVAL_P(EX_CONSTANT(opline->op2))));
}
/* non-qualified constant - allow text substitution */
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
zend_error(E_WARNING, "Use of undefined constant %s - assumed '%s' (this will throw an Error in a future version of PHP)",
Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var)));
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
} else {

View File

@ -28065,7 +28065,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CON
actual, Z_STRLEN_P(EX_CONSTANT(opline->op2)) - (actual - Z_STRVAL_P(EX_CONSTANT(opline->op2))));
}
/* non-qualified constant - allow text substitution */
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
zend_error(E_WARNING, "Use of undefined constant %s - assumed '%s' (this will throw an Error in a future version of PHP)",
Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var)));
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
} else {

View File

@ -13,5 +13,5 @@ const A="hello";
function getA() {return A;}
?>
--EXPECTF--
Notice: Use of undefined constant A - assumed 'A' in %sbug66251.php on line 4
Warning: Use of undefined constant A - assumed 'A' (this will throw an Error in a future version of PHP) in %sbug66251.php on line 4
A=A

View File

@ -13,13 +13,13 @@ opcache.optimization_level=0xFFFFBFFF
?>
okey
--EXPECTF--
Notice: Use of undefined constant E - assumed 'E' in %sbug71843.php on line %d
Warning: Use of undefined constant E - assumed 'E' (this will throw an Error in a future version of PHP) in %sbug71843.php on line %d
Warning: A non-numeric value encountered in %s on line %d
Notice: Use of undefined constant R - assumed 'R' in %sbug71843.php on line %d
Warning: Use of undefined constant R - assumed 'R' (this will throw an Error in a future version of PHP) in %sbug71843.php on line %d
Warning: A non-numeric value encountered in %s on line %d
Notice: Use of undefined constant See - assumed 'See' in %sbug71843.php on line %d
Warning: Use of undefined constant See - assumed 'See' (this will throw an Error in a future version of PHP) in %sbug71843.php on line %d
okey

View File

@ -33,7 +33,7 @@ NULL
Warning: array_diff_ukey() expects parameter 3 to be a valid callback, function 'unknown_function' not found or invalid function name in %s on line %d
NULL
Notice: Use of undefined constant unknown_function - assumed 'unknown_function' in %s on line %d
Warning: Use of undefined constant unknown_function - assumed 'unknown_function' (this will throw an Error in a future version of PHP) in %s on line %d
Warning: array_diff_ukey() expects parameter 3 to be a valid callback, function 'unknown_function' not found or invalid function name in %s on line %d
NULL

View File

@ -32,7 +32,7 @@ NULL
Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, function 'unknown_function' not found or invalid function name in %s on line %d
NULL
Notice: Use of undefined constant unknown_function - assumed 'unknown_function' in %s on line %d
Warning: Use of undefined constant unknown_function - assumed 'unknown_function' (this will throw an Error in a future version of PHP) in %s on line %d
Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, function 'unknown_function' not found or invalid function name in %s on line %d
NULL

View File

@ -32,7 +32,7 @@ NULL
Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, function 'unknown_function' not found or invalid function name in %s on line %d
NULL
Notice: Use of undefined constant unknown_function - assumed 'unknown_function' in %s on line %d
Warning: Use of undefined constant unknown_function - assumed 'unknown_function' (this will throw an Error in a future version of PHP) in %s on line %d
Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, function 'unknown_function' not found or invalid function name in %s on line %d
NULL

View File

@ -239,7 +239,7 @@ NULL
Warning: count() expects at most 2 parameters, 3 given in %s on line %d
NULL
Notice: Use of undefined constant ABCD - assumed 'ABCD' in %s on line %d
Warning: Use of undefined constant ABCD - assumed 'ABCD' (this will throw an Error in a future version of PHP) in %s on line %d
Warning: count() expects parameter 2 to be integer, %s given in %s on line %d
NULL

View File

@ -23,7 +23,7 @@ var_dump($r2=assert($sa));
--EXPECTF--
Deprecated: assert(): Calling assert() with a string argument is deprecated in %s on line %d
Notice: Use of undefined constant threemeninaboat - assumed 'threemeninaboat' in %s(9) : assert code on line 1
Warning: Use of undefined constant threemeninaboat - assumed 'threemeninaboat' (this will throw an Error in a future version of PHP) in %s(9) : assert code on line 1
bool(true)
int(0)

View File

@ -78,7 +78,7 @@ int(-1)
Notice: Undefined variable: undefined_var in %s on line %d
Notice: Use of undefined constant undefined_constant - assumed 'undefined_constant' in %s on line %d
Warning: Use of undefined constant undefined_constant - assumed 'undefined_constant' (this will throw an Error in a future version of PHP) in %s on line %d
array(0) {
}
array(0) {

View File

@ -7,7 +7,7 @@ include "skipif.inc";
--FILE--
<?php
include "php_cli_server.inc";
php_cli_server_start('echo done, "\n";', null);
php_cli_server_start('echo "done\n";', null);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port)?:80;

View File

@ -63,7 +63,7 @@ Notice: Undefined variable: undef in %s on line 5
Attempt to access various kinds of class constants:
Notice: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' in %s on line %d
Warning: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' (this will throw an Error in a future version of PHP) in %s on line %d
string(9) "UNDEFINED"
int(1)
float(1.5)

View File

@ -29,7 +29,7 @@ ErrorCodesDerived::print_fatal_error_codes();
?>
--EXPECTF--
Notice: Use of undefined constant FATAL - assumed 'FATAL' in %sconstants_scope_001.php on line %d
Warning: Use of undefined constant FATAL - assumed 'FATAL' (this will throw an Error in a future version of PHP) in %sconstants_scope_001.php on line %d
FATAL = FATAL
self::FATAL = Fatal error
self::FATAL = Worst error