global statement removal: hphp/test [7/x]
[hiphop-php.git] / hphp / test / quick / recursive-setter.php
blob696b87696642bab3e6294ac1c0987eb698a23f49
1 <?hh
3 error_reporting(-1);
5 //////////////////////////////////////////////////////////////////////
7 class Foo {
8 public function __set($k, $v) {
9 var_dump($k, $v);
10 if ($k != 'bar') {
11 $this->bar = ($v + 1);
16 function main1() {
17 $f = new Foo;
18 $f->foo = 2;
21 //////////////////////////////////////////////////////////////////////
23 class Foo2 {
24 public function __set($k, $v) {
25 var_dump($k, $v);
26 $this->foo = ($v + 1);
30 function main2() {
31 $f = new Foo2;
32 $f->bar = 2;
35 //////////////////////////////////////////////////////////////////////
37 class CaseFoo {
38 public function __set($k, $v) {
39 var_dump($k, $v);
40 if ($k === 'bar') { $this->Bar = ($v + 1); return; }
41 if ($k === 'Bar') { $this->foo = ($v + 1); return; }
42 if ($k === 'foo') { $this->bar = ($v + 1); return; }
43 var_dump("shouldn't get here");
47 function main3() {
48 $f = new CaseFoo;
49 $f->bar = 2;
52 //////////////////////////////////////////////////////////////////////
54 main1();
55 echo "--\n";
56 main2();
57 echo "--\n";
58 main3();
59 echo "--\n";