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