]> granicus.if.org Git - php/commitdiff
Deprecate defining a free-standing assert() function
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 4 Jul 2018 21:20:29 +0000 (23:20 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 21 Jul 2018 20:34:09 +0000 (22:34 +0200)
Part of https://wiki.php.net/rfc/deprecations_php_7_3.

Zend/tests/custom_assert_deprecation.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/Zend/tests/custom_assert_deprecation.phpt b/Zend/tests/custom_assert_deprecation.phpt
new file mode 100644 (file)
index 0000000..b4e2284
--- /dev/null
@@ -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
index 16b8fe9288eb7af3f2c0fff2fe022e07fae1e26e..dc9ee094906da8de8ef74db22f2e6a6bf9400b38 100644 (file)
@@ -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);