com php-src: Deprecate defining a free-standing assert() function: Zend/tests/custom_assert_deprecation.phpt Zend/zend_c ompile.c
| From: | Nikita Popov | Date: | Sat, 21 Jul 2018 20:34:09 +0000 |
| Subject: | com php-src: Deprecate defining a free-standing assert() function: Zend/tests/custom_assert_deprecation.phpt Zend/zend_c ompile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-102629@lists.php.net to get a copy of this message | ||
Commit: 5c4047b3396818e51bc95878cd45bcd3ff6d357b
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 4 Jul 2018 23:20:29 +0200
Parents: f4a9da389b728dcff2b499ff64fefd1c8e762c85
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5c4047b3396818e51bc95878cd45bcd3ff6d357b
Log:
Deprecate defining a free-standing assert() function
Part of https://wiki.php.net/rfc/deprecations_php_7_3..
Changed paths:
A Zend/tests/custom_assert_deprecation.phpt
M Zend/zend_compile.c
Diff:
diff --git a/Zend/tests/custom_assert_deprecation.phpt b/Zend/tests/custom_assert_deprecation.phpt
new file mode 100644
index 0000000..b4e2284
--- /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 16b8fe9..dc9ee09 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);