xref: /php-src/Zend/tests/bug75921.phpt (revision d30cd7d7)
1--TEST--
2Bug #75921: Inconsistent error when creating stdObject from empty variable
3--FILE--
4<?php
5
6try {
7    $null->a = 42;
8} catch (Error $e) {
9    echo $e->getMessage(), "\n";
10}
11var_dump($null);
12unset($null);
13
14try {
15    $null->a['hello'] = 42;
16} catch (Error $e) {
17    echo $e->getMessage(), "\n";
18}
19var_dump($null);
20unset($null);
21
22try {
23    $null->a->b = 42;
24} catch (Error $e) {
25    echo $e->getMessage(), "\n";
26}
27var_dump($null);
28unset($null);
29
30try {
31    $null->a['hello']->b = 42;
32} catch (Error $e) {
33    echo $e->getMessage(), "\n";
34}
35var_dump($null);
36unset($null);
37
38try {
39    $null->a->b['hello'] = 42;
40} catch (Error $e) {
41    echo $e->getMessage(), "\n";
42}
43var_dump($null);
44unset($null);
45
46?>
47--EXPECTF--
48Attempt to assign property "a" on null
49
50Warning: Undefined variable $null in %s on line %d
51NULL
52Attempt to modify property "a" on null
53
54Warning: Undefined variable $null in %s on line %d
55NULL
56Attempt to modify property "a" on null
57
58Warning: Undefined variable $null in %s on line %d
59NULL
60Attempt to modify property "a" on null
61
62Warning: Undefined variable $null in %s on line %d
63NULL
64Attempt to modify property "a" on null
65
66Warning: Undefined variable $null in %s on line %d
67NULL
68