Skip to content

Commit 5c4047b

Browse files
committed
Deprecate defining a free-standing assert() function
Part of https://wiki.php.net/rfc/deprecations_php_7_3.
1 parent f4a9da3 commit 5c4047b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Defining a free-standing assert() function is deprecated
3+
--FILE--
4+
<?php
5+
6+
namespace FooBar;
7+
8+
function assert() {}
9+
10+
?>
11+
--EXPECTF--
12+
Deprecated: Defining a custom assert() function is deprecated, as the function has special semantics in %s on line %d

Zend/zend_compile.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5981,6 +5981,12 @@ static void zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_as
59815981
zend_error(E_DEPRECATED, "__autoload() is deprecated, use spl_autoload_register() instead");
59825982
}
59835983

5984+
if (zend_string_equals_literal_ci(unqualified_name, "assert")) {
5985+
zend_error(E_DEPRECATED,
5986+
"Defining a custom assert() function is deprecated, "
5987+
"as the function has special semantics");
5988+
}
5989+
59845990
key = zend_build_runtime_definition_key(lcname, decl->lex_pos);
59855991
zend_hash_update_ptr(CG(function_table), key, op_array);
59865992
zend_register_seen_symbol(lcname, ZEND_SYMBOL_FUNCTION);

0 commit comments

Comments
 (0)