mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Remove bareword fallback for constants
Access to undefined constants will now always result in an Error exception being thrown. This required quite a few test changes, because there were many buggy tests that unintentionally used bareword fallback in combination with error suppression.
This commit is contained in:
parent
3d39479f4d
commit
aad39879f2
49 changed files with 375 additions and 470 deletions
|
@ -566,29 +566,10 @@ ZEND_API int zend_use_undefined_constant(zend_string *name, zend_ast_attr attr,
|
|||
} else if ((colon = (char*)zend_memrchr(ZSTR_VAL(name), ':', ZSTR_LEN(name)))) {
|
||||
zend_throw_error(NULL, "Undefined class constant '%s'", ZSTR_VAL(name));
|
||||
return FAILURE;
|
||||
} else if ((attr & IS_CONSTANT_UNQUALIFIED) == 0) {
|
||||
} else {
|
||||
zend_throw_error(NULL, "Undefined constant '%s'", ZSTR_VAL(name));
|
||||
return FAILURE;
|
||||
} else {
|
||||
char *actual = ZSTR_VAL(name);
|
||||
size_t actual_len = ZSTR_LEN(name);
|
||||
char *slash = (char *) zend_memrchr(actual, '\\', actual_len);
|
||||
|
||||
if (slash) {
|
||||
actual = slash + 1;
|
||||
actual_len -= (actual - ZSTR_VAL(name));
|
||||
}
|
||||
|
||||
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)) {
|
||||
return FAILURE;
|
||||
} else {
|
||||
zend_string *result_str = zend_string_init(actual, actual_len, 0);
|
||||
zval_ptr_dtor_nogc(result);
|
||||
ZVAL_NEW_STR(result, result_str);
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue