diff options
| -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); | 
