Annotation of embedaddon/php/Zend/tests/bug28444.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Bug #28444 (Cannot access undefined property for object with overloaded property access)
3: --FILE--
4: <?php
5:
6: function my_error_handler($errno, $errstr, $errfile, $errline) {
7: var_dump($errstr);
8: }
9:
10: set_error_handler('my_error_handler');
11:
12: class Object
13: {
14: public $x;
15:
16: function __construct($x)
17: {
18: $this->x = $x;
19: }
20: }
21:
22: class Overloaded
23: {
24: public $props = array();
25: public $x;
26:
27: function __construct($x)
28: {
29: $this->x = new Object($x);
30: }
31:
32: function __get($prop)
33: {
34: echo __METHOD__ . "($prop)\n";
35: return $this->props[$prop];
36: }
37:
38: function __set($prop, $val)
39: {
40: echo __METHOD__ . "($prop,$val)\n";
41: $this->props[$prop] = $val;
42: }
43: }
44: $y = new Overloaded(2);
45: var_dump($y->x);
46: var_dump($y->x->x);
47: var_dump($y->x->x = 3);
48: var_dump($y->y = 3);
49: var_dump($y->y);
50: var_dump($y->z = new Object(4));
51: var_dump($y->z->x);
52: $t = $y->z;
53: var_dump($t->x = 5);
54: var_dump($y->z->x = 6);
55:
56: ?>
57: ===DONE===
58: --EXPECTF--
59: object(Object)#%d (1) {
60: ["x"]=>
61: int(2)
62: }
63: int(2)
64: int(3)
65: Overloaded::__set(y,3)
66: int(3)
67: Overloaded::__get(y)
68: int(3)
69: string(55) "Object of class Object could not be converted to string"
70: Overloaded::__set(z,)
71: object(Object)#%d (1) {
72: ["x"]=>
73: int(4)
74: }
75: Overloaded::__get(z)
76: int(4)
77: Overloaded::__get(z)
78: int(5)
79: Overloaded::__get(z)
80: int(6)
81: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>