blob: ead933646a2e03ae9f20aa765a9cb74e974c8630 (
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
|
--TEST--
Un-setting public instance properties causes magic methods to be called when trying to access them from outside class scope
--FILE--
<?php
class Test
{
public $testProperty = 'property set';
public function __get($name)
{
return '__get ' . $name;
}
public function __set($name, $value)
{
$this->$name = $value;
echo '__set ' . $name . ' to ' . $value;
}
public function __isset($name)
{
echo '__isset ' . $name;
return isset($this->$name);
}
public function getTestProperty()
{
return $this->testProperty;
}
public function setTestProperty($testProperty)
{
$this->testProperty = $testProperty;
}
}
$o = new Test;
echo $o->testProperty;
echo "\n";
isset($o->testProperty);
echo "\n";
unset($o->testProperty);
isset($o->testProperty);
echo "\n";
echo $o->testProperty;
echo "\n";
echo $o->getTestProperty();
echo "\n";
echo $o->setTestProperty('new value via setter');
echo "\n";
echo $o->testProperty;
echo "\n";
unset($o->testProperty);
$o->testProperty = 'new value via public access';
echo "\n";
isset($o->testProperty);
echo "\n";
echo $o->testProperty;
?>
--EXPECTF--
property set
__isset testProperty
__get testProperty
__get testProperty
__set testProperty to new value via setter
new value via setter
__set testProperty to new value via public access
new value via public access
|