mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
Add tests verifying calls work inside echo, concatenation and array access
This commit is contained in:
parent
35314a416a
commit
43f3d250f4
4 changed files with 89 additions and 0 deletions
18
Zend/tests/methods-on-non-objects-array-access.phpt
Executable file
18
Zend/tests/methods-on-non-objects-array-access.phpt
Executable file
|
@ -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
|
35
Zend/tests/methods-on-non-objects-array-creation.phpt
Executable file
35
Zend/tests/methods-on-non-objects-array-creation.phpt
Executable file
|
@ -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
|
18
Zend/tests/methods-on-non-objects-concat.phpt
Executable file
18
Zend/tests/methods-on-non-objects-concat.phpt
Executable file
|
@ -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
|
18
Zend/tests/methods-on-non-objects-in-echo.phpt
Executable file
18
Zend/tests/methods-on-non-objects-in-echo.phpt
Executable file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue