1--TEST--
2Un-setting instance properties causes magic methods to be called when trying to access them from outside the magic
3methods themselves.
4--FILE--
5<?php
6
7class Test
8{
9	public    $publicProperty        = 'publicProperty set';
10
11	protected $protectedProperty     = 'protectedProperty set';
12
13	private   $privateProperty       = 'privateProperty set';
14
15	public function __get($name)
16	{
17		return '__get "' . $name . '"';
18	}
19
20	public function __set($name, $value)
21	{
22		$this->$name = $value;
23		echo '__set "' . $name . '" to "' . $value . '"';
24	}
25
26	public function __isset($name)
27	{
28		echo '__isset "' . $name . '"';
29		return isset($this->$name);
30	}
31
32	public function getPublicProperty()
33	{
34		return $this->publicProperty;
35	}
36
37	public function setPublicProperty($publicProperty)
38	{
39		$this->publicProperty = $publicProperty;
40	}
41
42	public function unsetProtectedProperty()
43	{
44		unset($this->protectedProperty);
45	}
46
47	public function getProtectedProperty()
48	{
49		return $this->protectedProperty;
50	}
51
52	public function setProtectedProperty($protectedProperty)
53	{
54		$this->protectedProperty = $protectedProperty;
55	}
56
57	public function unsetPrivateProperty()
58	{
59		unset($this->privateProperty);
60	}
61
62	public function getPrivateProperty()
63	{
64		return $this->privateProperty;
65	}
66
67	public function setPrivateProperty($privateProperty)
68	{
69		$this->privateProperty = $privateProperty;
70	}
71}
72
73// verifying public property
74$o = new Test;
75echo $o->publicProperty;
76echo "\n";
77var_export(isset($o->publicProperty));
78echo "\n";
79unset($o->publicProperty);
80isset($o->publicProperty);
81echo "\n";
82echo $o->publicProperty;
83echo "\n";
84echo $o->getPublicProperty();
85echo "\n";
86echo $o->setPublicProperty('new publicProperty value via setter');
87echo "\n";
88echo $o->publicProperty;
89echo "\n";
90unset($o->publicProperty);
91$o->publicProperty = 'new publicProperty value via public access';
92echo "\n";
93var_export(isset($o->publicProperty));
94echo "\n";
95echo $o->publicProperty;
96echo "\n\n";
97
98// verifying protected property
99echo $o->getProtectedProperty();
100echo "\n";
101$o->unsetProtectedProperty();
102var_export(isset($o->protectedProperty));
103echo "\n";
104echo $o->getProtectedProperty();
105echo "\n";
106echo $o->setProtectedProperty('new protectedProperty value via setter');
107echo "\n";
108var_export(isset($o->protectedProperty));
109echo "\n";
110echo $o->getProtectedProperty();
111echo "\n\n";
112
113// verifying private property
114echo $o->getPrivateProperty();
115echo "\n";
116$o->unsetPrivateProperty();
117var_export(isset($o->privateProperty));
118echo "\n";
119echo $o->getPrivateProperty();
120echo "\n";
121echo $o->setPrivateProperty('new privateProperty value via setter');
122echo "\n";
123var_export(isset($o->privateProperty));
124echo "\n";
125echo $o->getPrivateProperty();
126echo "\n\n";
127
128?>
129--EXPECTF--
130publicProperty set
131true
132__isset "publicProperty"
133__get "publicProperty"
134__get "publicProperty"
135__set "publicProperty" to "new publicProperty value via setter"
136new publicProperty value via setter
137__set "publicProperty" to "new publicProperty value via public access"
138true
139new publicProperty value via public access
140
141protectedProperty set
142__isset "protectedProperty"false
143__get "protectedProperty"
144__set "protectedProperty" to "new protectedProperty value via setter"
145__isset "protectedProperty"true
146new protectedProperty value via setter
147
148privateProperty set
149__isset "privateProperty"false
150__get "privateProperty"
151__set "privateProperty" to "new privateProperty value via setter"
152__isset "privateProperty"true
153new privateProperty value via setter
154