mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Add tests for calls to nested, *non*-compile-time-resolveable functions
See a1a4ba9511 (commitcomment-7414362)
This commit is contained in:
parent
a1a4ba9511
commit
971d369d88
43
Zend/tests/methods-on-non-objects-nested-calls-nonct.phpt
Executable file
43
Zend/tests/methods-on-non-objects-nested-calls-nonct.phpt
Executable file
@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
Catch method calls on non-objects with nested non-compile-time-resolveable calls
|
||||
--FILE--
|
||||
<?php
|
||||
require('methods-on-non-objects-nested.inc');
|
||||
|
||||
set_error_handler(function($code, $message) {
|
||||
static $i= 0;
|
||||
echo 'Called #'.(++$i)."\n";
|
||||
});
|
||||
|
||||
$x= null;
|
||||
|
||||
var_dump($x->method(nested()));
|
||||
|
||||
$closure= function() { return nested(); };
|
||||
var_dump($x->method($closure()));
|
||||
|
||||
$lambda= create_function('', 'return nested();');
|
||||
var_dump($x->method($lambda()));
|
||||
|
||||
$func= 'nested';
|
||||
var_dump($x->method($func()));
|
||||
|
||||
var_dump($x->method(call_user_func('nested')));
|
||||
var_dump($x->method(call_user_func_array('nested', [])));
|
||||
|
||||
echo "Alive\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Called #1
|
||||
NULL
|
||||
Called #2
|
||||
NULL
|
||||
Called #3
|
||||
NULL
|
||||
Called #4
|
||||
NULL
|
||||
Called #5
|
||||
NULL
|
||||
Called #6
|
||||
NULL
|
||||
Alive
|
4
Zend/tests/methods-on-non-objects-nested.inc
Executable file
4
Zend/tests/methods-on-non-objects-nested.inc
Executable file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
function nested() {
|
||||
throw new LogicException('Should not be called');
|
||||
}
|
Loading…
Reference in New Issue
Block a user