summaryrefslogtreecommitdiff
path: root/tests/classes/__set__get_005.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /tests/classes/__set__get_005.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'tests/classes/__set__get_005.phpt')
-rw-r--r--tests/classes/__set__get_005.phpt68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/classes/__set__get_005.phpt b/tests/classes/__set__get_005.phpt
new file mode 100644
index 0000000..d8bbad3
--- /dev/null
+++ b/tests/classes/__set__get_005.phpt
@@ -0,0 +1,68 @@
+--TEST--
+ZE2 __set() and __get()
+--SKIPIF--
+<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
+--FILE--
+<?php
+class Test
+{
+ protected $x;
+
+ function __get($name) {
+ echo __METHOD__ . "\n";
+ if (isset($this->x[$name])) {
+ return $this->x[$name];
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+
+ function __set($name, $val) {
+ echo __METHOD__ . "\n";
+ $this->x[$name] = $val;
+ }
+}
+
+class AutoGen
+{
+ protected $x;
+
+ function __get($name) {
+ echo __METHOD__ . "\n";
+ if (!isset($this->x[$name])) {
+ $this->x[$name] = new Test();
+ }
+ return $this->x[$name];
+ }
+
+ function __set($name, $val) {
+ echo __METHOD__ . "\n";
+ $this->x[$name] = $val;
+ }
+}
+
+$foo = new AutoGen();
+$foo->bar->baz = "Check";
+
+var_dump($foo->bar);
+var_dump($foo->bar->baz);
+
+?>
+===DONE===
+--EXPECTF--
+AutoGen::__get
+Test::__set
+AutoGen::__get
+object(Test)#%d (1) {
+ ["x":protected]=>
+ array(1) {
+ ["baz"]=>
+ string(5) "Check"
+ }
+}
+AutoGen::__get
+Test::__get
+string(5) "Check"
+===DONE===