mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Add tests for indirect calls to methods on non-objects
http://news.php.net/php.internals/73823
This commit is contained in:
parent
a86e762166
commit
da1db5e688
2 changed files with 56 additions and 0 deletions
13
Zend/tests/methods-on-non-objects-call-user-func.phpt
Normal file
13
Zend/tests/methods-on-non-objects-call-user-func.phpt
Normal file
|
@ -0,0 +1,13 @@
|
|||
--TEST--
|
||||
call_user_func() in combination with "Call to a member function method() on a non-object"
|
||||
--FILE--
|
||||
<?php
|
||||
$comparator= null;
|
||||
var_dump(call_user_func([$comparator, 'compare'], 1, 2));
|
||||
echo "Alive\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in %s on line %d
|
||||
NULL
|
||||
Alive
|
||||
|
43
Zend/tests/methods-on-non-objects-usort.phpt
Normal file
43
Zend/tests/methods-on-non-objects-usort.phpt
Normal file
|
@ -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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue