summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2020-02-07 13:36:52 +0300
committerDmitry Stogov <dmitry@zend.com>2020-02-07 13:36:52 +0300
commit64b40f69dca440e86e608847a39b795aedf75861 (patch)
tree8662ed948ea4001fb572cdd7e672eb769361dc6b /tests
parentad3f7682538604302ee6c4d4513e7efd06f01f02 (diff)
downloadphp-git-64b40f69dca440e86e608847a39b795aedf75861.tar.gz
Make ASSIGN, ASSIGN_OP, INC and DEC opcodes to return IS_TMP_VAR instead of IS_VAR.
This helps to avoid unnecessary IS_REFERENCE checks. This changes some notices "Only variables should be passed by reference" to exception "Cannot pass parameter %d by reference". Also, for consistency, compile-time fatal error "Only variables can be passed by reference" was converted to exception "Cannot pass parameter %d by reference"
Diffstat (limited to 'tests')
-rw-r--r--tests/classes/constants_error_003.phpt5
-rw-r--r--tests/lang/passByReference_002.phpt5
-rw-r--r--tests/lang/passByReference_010.phpt63
3 files changed, 43 insertions, 30 deletions
diff --git a/tests/classes/constants_error_003.phpt b/tests/classes/constants_error_003.phpt
index fa7984f06e..a0ee23506b 100644
--- a/tests/classes/constants_error_003.phpt
+++ b/tests/classes/constants_error_003.phpt
@@ -16,4 +16,7 @@ Basic class support - attempting to pass a class constant by reference.
var_dump(aclass::myConst);
?>
--EXPECTF--
-Fatal error: Only variables can be passed by reference in %s on line 12
+Fatal error: Uncaught Error: Cannot pass parameter 1 by reference in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d
diff --git a/tests/lang/passByReference_002.phpt b/tests/lang/passByReference_002.phpt
index 81868177a8..2c3de8879a 100644
--- a/tests/lang/passByReference_002.phpt
+++ b/tests/lang/passByReference_002.phpt
@@ -12,4 +12,7 @@ f(2);
?>
--EXPECTF--
-Fatal error: Only variables can be passed by reference in %s on line 8
+Fatal error: Uncaught Error: Cannot pass parameter 1 by reference in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d
diff --git a/tests/lang/passByReference_010.phpt b/tests/lang/passByReference_010.phpt
index f996073c0f..9606d4f842 100644
--- a/tests/lang/passByReference_010.phpt
+++ b/tests/lang/passByReference_010.phpt
@@ -9,42 +9,52 @@ function f(&$a) {
}
echo "\n\n---> Pass constant assignment by reference:\n";
-f($a="a.original");
-var_dump($a);
+try {
+ f($a="a.original");
+ var_dump($a);
+} catch (Throwable $e) {
+ echo "Exception: " . $e->getMessage() ."\n";
+}
echo "\n\n---> Pass variable assignment by reference:\n";
-unset($a);
-$a = "a.original";
-f($b = $a);
-var_dump($a);
+try {
+ unset($a);
+ $a = "a.original";
+ f($b = $a);
+ var_dump($a);
+} catch (Throwable $e) {
+ echo "Exception: " . $e->getMessage() ."\n";
+}
echo "\n\n---> Pass reference assignment by reference:\n";
-unset($a, $b);
-$a = "a.original";
-f($b =& $a);
-var_dump($a);
+try {
+ unset($a, $b);
+ $a = "a.original";
+ f($b =& $a);
+ var_dump($a);
+} catch (Throwable $e) {
+ echo "Exception: " . $e->getMessage() ."\n";
+}
echo "\n\n---> Pass concat assignment by reference:\n";
-unset($a, $b);
-$b = "b.original";
-$a = "a.original";
-f($b .= $a);
-var_dump($a);
+try {
+ unset($a, $b);
+ $b = "b.original";
+ $a = "a.original";
+ f($b .= $a);
+ var_dump($a);
+} catch (Throwable $e) {
+ echo "Exception: " . $e->getMessage() ."\n";
+}
?>
---EXPECTF--
+--EXPECT--
---> Pass constant assignment by reference:
-
-Notice: Only variables should be passed by reference in %s on line 9
-string(10) "a.original"
-string(10) "a.original"
+Exception: Cannot pass parameter 1 by reference
---> Pass variable assignment by reference:
-
-Notice: Only variables should be passed by reference in %s on line 15
-string(10) "a.original"
-string(10) "a.original"
+Exception: Cannot pass parameter 1 by reference
---> Pass reference assignment by reference:
@@ -53,7 +63,4 @@ string(9) "a.changed"
---> Pass concat assignment by reference:
-
-Notice: Only variables should be passed by reference in %s on line 28
-string(20) "b.originala.original"
-string(10) "a.original"
+Exception: Cannot pass parameter 1 by reference