xref: /PHP-7.4/Zend/tests/bug75921.phpt (revision e63febb1)
1--TEST--
2Bug #75921: Inconsistent error when creating stdObject from empty variable
3--FILE--
4<?php
5
6$null->a = 42;
7var_dump($null);
8unset($null);
9
10$null->a['hello'] = 42;
11var_dump($null);
12unset($null);
13
14$null->a->b = 42;
15var_dump($null);
16unset($null);
17
18$null->a['hello']->b = 42;
19var_dump($null);
20unset($null);
21
22$null->a->b['hello'] = 42;
23var_dump($null);
24unset($null);
25
26?>
27--EXPECTF--
28Warning: Creating default object from empty value in %sbug75921.php on line 3
29object(stdClass)#1 (1) {
30  ["a"]=>
31  int(42)
32}
33
34Warning: Creating default object from empty value in %sbug75921.php on line 7
35object(stdClass)#1 (1) {
36  ["a"]=>
37  array(1) {
38    ["hello"]=>
39    int(42)
40  }
41}
42
43Warning: Creating default object from empty value in %sbug75921.php on line 11
44
45Warning: Creating default object from empty value in %sbug75921.php on line 11
46object(stdClass)#1 (1) {
47  ["a"]=>
48  object(stdClass)#2 (1) {
49    ["b"]=>
50    int(42)
51  }
52}
53
54Warning: Creating default object from empty value in %sbug75921.php on line 15
55
56Warning: Creating default object from empty value in %sbug75921.php on line 15
57object(stdClass)#1 (1) {
58  ["a"]=>
59  array(1) {
60    ["hello"]=>
61    object(stdClass)#2 (1) {
62      ["b"]=>
63      int(42)
64    }
65  }
66}
67
68Warning: Creating default object from empty value in %sbug75921.php on line 19
69
70Warning: Creating default object from empty value in %sbug75921.php on line 19
71object(stdClass)#1 (1) {
72  ["a"]=>
73  object(stdClass)#2 (1) {
74    ["b"]=>
75    array(1) {
76      ["hello"]=>
77      int(42)
78    }
79  }
80}
81