]> granicus.if.org Git - php/commitdiff
Deprecate (unset)
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 1 Feb 2017 23:23:11 +0000 (00:23 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 3 Feb 2017 17:52:57 +0000 (18:52 +0100)
Pecularily, there wasn't a single test for the (unset) cast...

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

diff --git a/Zend/tests/unset_cast_deprecated.phpt b/Zend/tests/unset_cast_deprecated.phpt
new file mode 100644 (file)
index 0000000..6744c85
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+The (unset) cast is deprecated
+--FILE--
+<?php
+
+$x = 1;
+var_dump((unset) $x);
+var_dump($x);
+
+?>
+--EXPECTF--
+Deprecated: The (unset) cast is deprecated in %s on line %d
+NULL
+int(1)
index 9a904eefa8e400253520cb69ae634d675fa54914..84a3e6a021299c73d82cb6db78726ca98ebd7956 100644 (file)
@@ -6871,6 +6871,10 @@ void zend_compile_cast(znode *result, zend_ast *ast) /* {{{ */
 
        opline = zend_emit_op_tmp(result, ZEND_CAST, &expr_node, NULL);
        opline->extended_value = ast->attr;
+
+       if (ast->attr == IS_NULL) {
+               zend_error(E_DEPRECATED, "The (unset) cast is deprecated");
+       }
 }
 /* }}} */