com php-src: Add tests verifying calls work inside echo, concatenation and array access: Zend/tests/methods-on-non-objects-array-access.phpt
Zend/tests/methods-on-non-objects-array-creation.phpt Zend/tests/methods-on-non-objects-concat.phpt Zend/tests/methods-on-non-objects-in-echo.phpt
| From: | Tjerk Anne Meesters | Date: | Sun, 05 Oct 2014 22:08:02 +0000 |
| Subject: | com php-src: Add tests verifying calls work inside echo, concatenation and array access: Zend/tests/methods-on-non-objects-array-access.phpt Zend/tests/methods-on-non-objects-array-creation.phpt Zend/tests/methods-on-non-objects-concat.phpt Zend/tests/methods-on-non-objects-in-echo.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82157@lists.php.net to get a copy of this message | ||
Commit: 43f3d250f45e095150d12185f9ac8bfaad27d1cc
Author: Timm Friebe <thekid@thekid.de> Sun, 5 Oct 2014 14:27:21 +0200
Committer: Tjerk Meesters <datibbaw@php.net> Mon, 6 Oct 2014 06:08:02 +0800
Parents: 35314a416ac59e6410ec3aa74c98abb2fc9c5077
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=43f3d250f45e095150d12185f9ac8bfaad27d1cc
Log:
Add tests verifying calls work inside echo, concatenation and array access
Changed paths:
A Zend/tests/methods-on-non-objects-array-access.phpt
A Zend/tests/methods-on-non-objects-array-creation.phpt
A Zend/tests/methods-on-non-objects-concat.phpt
A Zend/tests/methods-on-non-objects-in-echo.phpt
Diff:
diff --git a/Zend/tests/methods-on-non-objects-array-access.phpt
b/Zend/tests/methods-on-non-objects-array-access.phpt
new file mode 100755
index 0000000..be87457
--- /dev/null
+++ b/Zend/tests/methods-on-non-objects-array-access.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Catch method calls on non-objects inside array access
+--FILE--
+<?php
+set_error_handler(function($code, $message) {
+ var_dump($code, $message);
+});
+
+$x= null;
+$a= [null => 'OK'];
+var_dump($a[$x->method()]);
+echo "Alive\n";
+?>
+--EXPECTF--
+int(4096)
+string(%d) "Call to a member function method() on null"
+string(2) "OK"
+Alive
\ No newline at end of file
diff --git a/Zend/tests/methods-on-non-objects-array-creation.phpt
b/Zend/tests/methods-on-non-objects-array-creation.phpt
new file mode 100755
index 0000000..74cbb9c
--- /dev/null
+++ b/Zend/tests/methods-on-non-objects-array-creation.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Catch method calls on non-objects inside array creation
+--FILE--
+<?php
+set_error_handler(function($code, $message) {
+ var_dump($code, $message);
+});
+
+$x= null;
+var_dump([$x->method() => 'OK']);
+var_dump([$x->method(), $x->method(), $x->method()]);
+echo "Alive\n";
+?>
+--EXPECTF--
+int(4096)
+string(%d) "Call to a member function method() on null"
+array(1) {
+ [""]=>
+ string(2) "OK"
+}
+int(4096)
+string(%d) "Call to a member function method() on null"
+int(4096)
+string(%d) "Call to a member function method() on null"
+int(4096)
+string(%d) "Call to a member function method() on null"
+array(3) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ [2]=>
+ NULL
+}
+Alive
\ No newline at end of file
diff --git a/Zend/tests/methods-on-non-objects-concat.phpt
b/Zend/tests/methods-on-non-objects-concat.phpt
new file mode 100755
index 0000000..4ff47aa
--- /dev/null
+++ b/Zend/tests/methods-on-non-objects-concat.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Catch method calls on non-objects inside concatenation
+--FILE--
+<?php
+set_error_handler(function($code, $message) {
+ var_dump($code, $message);
+});
+
+$x= null;
+echo "Before\n".$x->method()."After\n";
+echo "Alive\n";
+?>
+--EXPECTF--
+int(4096)
+string(%d) "Call to a member function method() on null"
+Before
+After
+Alive
\ No newline at end of file
diff --git a/Zend/tests/methods-on-non-objects-in-echo.phpt
b/Zend/tests/methods-on-non-objects-in-echo.phpt
new file mode 100755
index 0000000..a0267c0
--- /dev/null
+++ b/Zend/tests/methods-on-non-objects-in-echo.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Catch method calls on non-objects inside echo
+--FILE--
+<?php
+set_error_handler(function($code, $message) {
+ var_dump($code, $message);
+});
+
+$x= null;
+echo "Before\n", $x->method(), "After\n";
+echo "Alive\n";
+?>
+--EXPECTF--
+Before
+int(4096)
+string(%d) "Call to a member function method() on null"
+After
+Alive
\ No newline at end of file