com php-src: Deprecate (unset): Zend/tests/unset_cast_depre cated.phpt Zend/zend_compile.c

[email protected] (Nikita Popov)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    7a73c5f6bba386e0d82dd467e9dacceb10b851e3
Author:    Nikita Popov <[email protected]>         Thu, 2 Feb 2017 00:23:11 +0100
Parents:   162aa1a5fc96b3dd7e3420c6882607b361801fbd
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=7a73c5f6bba386e0d82dd467e9dacceb10b851e3

Log:
Deprecate (unset)

Pecularily, there wasn't a single test for the (unset) cast...

Changed paths:
  A  Zend/tests/unset_cast_deprecated.phpt
  M  Zend/zend_compile.c


Diff:
diff --git a/Zend/tests/unset_cast_deprecated.phpt b/Zend/tests/unset_cast_deprecated.phpt
new file mode 100644
index 0000000..6744c85
--- /dev/null
+++ b/Zend/tests/unset_cast_deprecated.phpt
@@ -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)
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 9a904ee..84a3e6a 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -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");
+	}
 }
 /* }}} */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.