]> granicus.if.org Git - php/commitdiff
This commit was manufactured by cvs2svn to create branch 'PHP_5_0'.
authorSVN Migration <svn@php.net>
Sat, 2 Oct 2004 14:22:53 +0000 (14:22 +0000)
committerSVN Migration <svn@php.net>
Sat, 2 Oct 2004 14:22:53 +0000 (14:22 +0000)
Zend/tests/bug28444.phpt [new file with mode: 0755]
Zend/tests/bug29368.phpt [new file with mode: 0755]
ext/reflection/tests/003.phpt [new file with mode: 0755]

diff --git a/Zend/tests/bug28444.phpt b/Zend/tests/bug28444.phpt
new file mode 100755 (executable)
index 0000000..f8a5513
--- /dev/null
@@ -0,0 +1,74 @@
+--TEST--
+Bug #28444 (Cannot access undefined property for object with overloaded property access)
+--FILE--
+<?php
+
+class Object
+{
+       public $x;
+
+       function __construct($x)
+       {
+               $this->x = $x;
+       }
+}
+
+class Overloaded
+{
+       public $props = array();
+       public $x;
+
+       function __construct($x)
+       {
+               $this->x = new Object($x);
+       }
+
+       function __get($prop)
+       {
+               echo __METHOD__ . "($prop)\n";
+               return $this->props[$prop];
+       }
+
+       function __set($prop, $val)
+       {
+               echo __METHOD__ . "($prop,$val)\n";
+               $this->props[$prop] = $val;
+       }
+}
+$y = new Overloaded(2);
+var_dump($y->x);
+var_dump($y->x->x);
+var_dump($y->x->x = 3);
+var_dump($y->y = 3);
+var_dump($y->y);
+var_dump($y->z = new Object(4));
+var_dump($y->z->x);
+$t = $y->z;
+var_dump($t->x = 5);
+var_dump($y->z->x = 6);
+
+?>
+===DONE===
+--EXPECTF--
+object(Object)#%d (1) {
+  ["x"]=>
+  int(2)
+}
+int(2)
+int(3)
+Overloaded::__set(y,3)
+int(3)
+Overloaded::__get(y)
+int(3)
+Overloaded::__set(z,Object id #3)
+object(Object)#%d (1) {
+  ["x"]=>
+  int(4)
+}
+Overloaded::__get(z)
+int(4)
+Overloaded::__get(z)
+int(5)
+Overloaded::__get(z)
+int(6)
+===DONE===
diff --git a/Zend/tests/bug29368.phpt b/Zend/tests/bug29368.phpt
new file mode 100755 (executable)
index 0000000..4c5a125
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+Bug #29368 (The destructor is called when an exception is thrown from the constructor)
+--FILE--
+<?
+
+class Foo
+{
+       function __construct()
+       {
+               echo __METHOD__ . "\n";
+               throw new Exception;
+       }
+       function __destruct()
+       {
+               echo __METHOD__ . "\n";
+       }
+}
+
+try
+{
+       $bar = new Foo;
+} catch(Exception $exc)
+{
+       echo "Caught exception!\n";
+}
+
+unset($bar);
+
+?>
+===DONE===
+--EXPECTF--
+Foo::__construct
+Caught exception!
+===DONE===
diff --git a/ext/reflection/tests/003.phpt b/ext/reflection/tests/003.phpt
new file mode 100755 (executable)
index 0000000..6603892
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+invoke() with base class method
+--FILE--
+<?php
+
+class Foo
+{
+       function Test()
+       {
+               echo __METHOD__ . "\n";
+       }
+}
+
+class Bar extends Foo
+{
+       function Test()
+       {
+               echo __METHOD__ . "\n";
+       }
+}
+
+$o = new Bar;
+$r = new ReflectionMethod('Foo','Test');
+
+$r->invoke($o);
+
+?>
+===DONE===
+--EXPECT--
+Foo::Test
+===DONE===