From 5c4047b3396818e51bc95878cd45bcd3ff6d357b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 4 Jul 2018 23:20:29 +0200 Subject: [PATCH] Deprecate defining a free-standing assert() function Part of https://wiki.php.net/rfc/deprecations_php_7_3. --- Zend/tests/custom_assert_deprecation.phpt | 12 ++++++++++++ Zend/zend_compile.c | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 Zend/tests/custom_assert_deprecation.phpt diff --git a/Zend/tests/custom_assert_deprecation.phpt b/Zend/tests/custom_assert_deprecation.phpt new file mode 100644 index 00000000000..b4e22843ddb --- /dev/null +++ b/Zend/tests/custom_assert_deprecation.phpt @@ -0,0 +1,12 @@ +--TEST-- +Defining a free-standing assert() function is deprecated +--FILE-- + +--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 16b8fe9288e..dc9ee094906 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);