summaryrefslogtreecommitdiff
path: root/Zend/tests/methods-on-non-objects-usort.phpt
diff options
context:
space:
mode:
authorTimm Friebe <thekid@thekid.de>2014-04-28 21:44:24 +0200
committerTimm Friebe <thekid@thekid.de>2014-04-28 21:44:24 +0200
commitda1db5e688c46a044bc0745c86cc34cc4e9ab808 (patch)
tree91b061f53db04ae24da9309ff56f64bd04e436af /Zend/tests/methods-on-non-objects-usort.phpt
parenta86e7621666bce5dcf5ac3304b2384b254319025 (diff)
downloadphp-git-da1db5e688c46a044bc0745c86cc34cc4e9ab808.tar.gz
Add tests for indirect calls to methods on non-objects
http://news.php.net/php.internals/73823
Diffstat (limited to 'Zend/tests/methods-on-non-objects-usort.phpt')
-rw-r--r--Zend/tests/methods-on-non-objects-usort.phpt43
1 files changed, 43 insertions, 0 deletions
diff --git a/Zend/tests/methods-on-non-objects-usort.phpt b/Zend/tests/methods-on-non-objects-usort.phpt
new file mode 100644
index 0000000000..df702d3a9a
--- /dev/null
+++ b/Zend/tests/methods-on-non-objects-usort.phpt
@@ -0,0 +1,43 @@
+--TEST--
+usort() in combination with "Call to a member function method() on a non-object"
+--FILE--
+<?php
+set_error_handler(function($code, $message) {
+ var_dump($code, $message);
+});
+
+$comparator= null;
+$list= [1, 4, 2, 3, -1];
+usort($list, function($a, $b) use ($comparator) {
+ return $comparator->compare($a, $b);
+});
+var_dump($list);
+echo "Alive\n";
+?>
+--EXPECTF--
+int(4096)
+string(51) "Call to a member function compare() on a non-object"
+int(4096)
+string(51) "Call to a member function compare() on a non-object"
+int(4096)
+string(51) "Call to a member function compare() on a non-object"
+int(4096)
+string(51) "Call to a member function compare() on a non-object"
+int(4096)
+string(51) "Call to a member function compare() on a non-object"
+int(4096)
+string(51) "Call to a member function compare() on a non-object"
+array(5) {
+ [0]=>
+ int(-1)
+ [1]=>
+ int(3)
+ [2]=>
+ int(2)
+ [3]=>
+ int(4)
+ [4]=>
+ int(1)
+}
+Alive
+