diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2018-07-04 23:20:29 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2018-07-21 22:34:09 +0200 |
commit | 5c4047b3396818e51bc95878cd45bcd3ff6d357b (patch) | |
tree | 0ed9f6eb1be279b20066069d9e9890faea28848b | |
parent | f4a9da389b728dcff2b499ff64fefd1c8e762c85 (diff) | |
download | php-git-5c4047b3396818e51bc95878cd45bcd3ff6d357b.tar.gz |
Deprecate defining a free-standing assert() function
Part of https://wiki.php.net/rfc/deprecations_php_7_3.
-rw-r--r-- | Zend/tests/custom_assert_deprecation.phpt | 12 | ||||
-rw-r--r-- | Zend/zend_compile.c | 6 |
2 files changed, 18 insertions, 0 deletions
diff --git a/Zend/tests/custom_assert_deprecation.phpt b/Zend/tests/custom_assert_deprecation.phpt new file mode 100644 index 0000000000..b4e22843dd --- /dev/null +++ b/Zend/tests/custom_assert_deprecation.phpt @@ -0,0 +1,12 @@ +--TEST-- +Defining a free-standing assert() function is deprecated +--FILE-- +<?php + +namespace FooBar; + +function assert() {} + +?> +--EXPECTF-- +Deprecated: Defining a custom assert() function is deprecated, as the function has special semantics in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 16b8fe9288..dc9ee09490 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5981,6 +5981,12 @@ static void zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_as zend_error(E_DEPRECATED, "__autoload() is deprecated, use spl_autoload_register() instead"); } + if (zend_string_equals_literal_ci(unqualified_name, "assert")) { + zend_error(E_DEPRECATED, + "Defining a custom assert() function is deprecated, " + "as the function has special semantics"); + } + key = zend_build_runtime_definition_key(lcname, decl->lex_pos); zend_hash_update_ptr(CG(function_table), key, op_array); zend_register_seen_symbol(lcname, ZEND_SYMBOL_FUNCTION); |