File: 002.phpt

package info (click to toggle)
php-propro 2.1.0%2B1.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 264 kB
  • sloc: ansic: 1,106; xml: 129; php: 18; makefile: 1
file content (102 lines) | stat: -rw-r--r-- 1,384 bytes parent folder | download | duplicates (2)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
--TEST--
property proxy
--SKIPIF--
<?php if (!extension_loaded("propro")) print "skip"; ?>
--FILE--
<?php

echo "Test\n";

class c {
	private $storage = array();
	function __get($p) {
		$pp = new php\PropertyProxy(null, $p,
			new php\PropertyProxy($this, "storage"));
		return $pp; 
	}
	function __set($p, $v) {
		$this->storage[$p] = $v;
	}
}

$c = new c;
$c->data["foo"] = 1;
var_dump(
	isset($c->data["foo"]),
	isset($c->data["bar"])
);

var_dump($c);

$c->data[] = 1;
$c->data[] = 2;
$c->data[] = 3;
$c->data["bar"][] = 123;
$c->data["bar"][] = 456;

var_dump($c);
unset($c->data["bar"][0]);

var_dump($c);

?>
DONE
--EXPECTF--
Test
bool(true)
bool(false)
object(c)#%d (1) {
  ["storage":"c":private]=>
  array(1) {
    ["data"]=>
    array(1) {
      ["foo"]=>
      int(1)
    }
  }
}
object(c)#%d (1) {
  ["storage":"c":private]=>
  array(1) {
    ["data"]=>
    array(5) {
      ["foo"]=>
      int(1)
      [0]=>
      int(1)
      [1]=>
      int(2)
      [2]=>
      int(3)
      ["bar"]=>
      array(2) {
        [0]=>
        int(123)
        [1]=>
        int(456)
      }
    }
  }
}
object(c)#%d (1) {
  ["storage":"c":private]=>
  array(1) {
    ["data"]=>
    array(5) {
      ["foo"]=>
      int(1)
      [0]=>
      int(1)
      [1]=>
      int(2)
      [2]=>
      int(3)
      ["bar"]=>
      array(1) {
        [1]=>
        int(456)
      }
    }
  }
}
DONE