1: --TEST--
2: Bug #31098 (isset() / empty() incorrectly returns true in dereference of a wrong type)
3: --FILE--
4: <?php
5: $a = '';
6: var_dump(isset($a->b));
7: $a = 'a';
8: var_dump(isset($a->b));
9: $a = '0';
10: var_dump(isset($a->b));
11: $a = '';
12: var_dump(isset($a['b']));
13: $a = 'a';
14: var_dump(isset($a['b']));
15: $a = '0';
16: var_dump(isset($a['b']));
17:
18: $simpleString = "Bogus String Text";
19: echo isset($simpleString->wrong)?"bug\n":"ok\n";
20: echo isset($simpleString["wrong"])?"ok\n":"bug\n";
21: echo isset($simpleString[-1])?"bug\n":"ok\n";
22: echo isset($simpleString[0])?"ok\n":"bug\n";
23: echo isset($simpleString["0"])?"ok\n":"bug\n";
24: echo isset($simpleString["16"])?"ok\n":"bug\n";
25: echo isset($simpleString["17"])?"bug\n":"ok\n";
26: echo isset($simpleString["wrong"][0])?"bug\n":"ok\n";
27: echo $simpleString->wrong === null?"ok\n":"bug\n";
28: echo $simpleString["wrong"] === "B"?"ok\n":"bug\n";
29: echo $simpleString["0"] === "B"?"ok\n":"bug\n";
30: $simpleString["wrong"] = "f";
31: echo $simpleString["0"] === "f"?"ok\n":"bug\n";
32: ?>
33: --EXPECTF--
34: bool(false)
35: bool(false)
36: bool(false)
37: bool(false)
38: bool(true)
39: bool(true)
40: ok
41: ok
42: ok
43: ok
44: ok
45: ok
46: ok
47: ok
48:
49: Notice: Trying to get property of non-object in %sbug31098.php on line %d
50: ok
51: ok
52: ok
53: ok
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>