mirror of
https://github.com/php/php-src.git
synced 2024-12-24 09:18:17 +08:00
e63febb1c7
Ensure that the "creating default object from empty value" warning is always thrown. Previously some cases were missing the warning, in particular those going through FETCH_OBJ_W rather than a dedicated opcode (like ASSIGN_OBJ). One slightly unfortunate side-effect of this change is that something like $a->b->c = 'd' will now generate two warnings rather than one when $a is null (one for property b, one for property c).
81 lines
1.5 KiB
PHP
81 lines
1.5 KiB
PHP
--TEST--
|
|
Bug #75921: Inconsistent error when creating stdObject from empty variable
|
|
--FILE--
|
|
<?php
|
|
|
|
$null->a = 42;
|
|
var_dump($null);
|
|
unset($null);
|
|
|
|
$null->a['hello'] = 42;
|
|
var_dump($null);
|
|
unset($null);
|
|
|
|
$null->a->b = 42;
|
|
var_dump($null);
|
|
unset($null);
|
|
|
|
$null->a['hello']->b = 42;
|
|
var_dump($null);
|
|
unset($null);
|
|
|
|
$null->a->b['hello'] = 42;
|
|
var_dump($null);
|
|
unset($null);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Warning: Creating default object from empty value in %sbug75921.php on line 3
|
|
object(stdClass)#1 (1) {
|
|
["a"]=>
|
|
int(42)
|
|
}
|
|
|
|
Warning: Creating default object from empty value in %sbug75921.php on line 7
|
|
object(stdClass)#1 (1) {
|
|
["a"]=>
|
|
array(1) {
|
|
["hello"]=>
|
|
int(42)
|
|
}
|
|
}
|
|
|
|
Warning: Creating default object from empty value in %sbug75921.php on line 11
|
|
|
|
Warning: Creating default object from empty value in %sbug75921.php on line 11
|
|
object(stdClass)#1 (1) {
|
|
["a"]=>
|
|
object(stdClass)#2 (1) {
|
|
["b"]=>
|
|
int(42)
|
|
}
|
|
}
|
|
|
|
Warning: Creating default object from empty value in %sbug75921.php on line 15
|
|
|
|
Warning: Creating default object from empty value in %sbug75921.php on line 15
|
|
object(stdClass)#1 (1) {
|
|
["a"]=>
|
|
array(1) {
|
|
["hello"]=>
|
|
object(stdClass)#2 (1) {
|
|
["b"]=>
|
|
int(42)
|
|
}
|
|
}
|
|
}
|
|
|
|
Warning: Creating default object from empty value in %sbug75921.php on line 19
|
|
|
|
Warning: Creating default object from empty value in %sbug75921.php on line 19
|
|
object(stdClass)#1 (1) {
|
|
["a"]=>
|
|
object(stdClass)#2 (1) {
|
|
["b"]=>
|
|
array(1) {
|
|
["hello"]=>
|
|
int(42)
|
|
}
|
|
}
|
|
}
|