summaryrefslogtreecommitdiff
path: root/ext/reflection/tests
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:35:13 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:35:13 -0400
commit0a36161e13484a99ccf69bb38f206462d27cc6d6 (patch)
treed5107db4b7369603ac7c753829e8972ee74949f7 /ext/reflection/tests
parentce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (diff)
downloadphp-upstream/5.1.2.tar.gz
Imported Upstream version 5.1.2upstream/5.1.2
Diffstat (limited to 'ext/reflection/tests')
-rwxr-xr-xext/reflection/tests/001.phpt89
-rwxr-xr-xext/reflection/tests/002.phpt63
-rwxr-xr-xext/reflection/tests/003.phpt31
-rwxr-xr-xext/reflection/tests/004.phpt42
-rwxr-xr-xext/reflection/tests/005.phpt54
-rwxr-xr-xext/reflection/tests/006.phpt103
-rwxr-xr-xext/reflection/tests/bug26640.phpt25
-rwxr-xr-xext/reflection/tests/bug26695.phpt25
-rwxr-xr-xext/reflection/tests/bug29268.phpt26
-rwxr-xr-xext/reflection/tests/bug29523.phpt38
-rwxr-xr-xext/reflection/tests/bug29828.phpt35
-rwxr-xr-xext/reflection/tests/bug30146.phpt23
-rwxr-xr-xext/reflection/tests/bug30148.phpt35
-rwxr-xr-xext/reflection/tests/bug30209.phpt31
-rwxr-xr-xext/reflection/tests/bug30856.phpt20
-rwxr-xr-xext/reflection/tests/bug30961.phpt20
-rwxr-xr-xext/reflection/tests/bug31651.phpt24
-rwxr-xr-xext/reflection/tests/bug32981.phpt34
-rwxr-xr-xext/reflection/tests/bug33312.phpt20
-rwxr-xr-xext/reflection/tests/bug33389.phpt97
-rw-r--r--ext/reflection/tests/exception.inc16
-rwxr-xr-xext/reflection/tests/parameters_001.phpt38
-rwxr-xr-xext/reflection/tests/property_exists.phpt222
-rwxr-xr-xext/reflection/tests/static_properties_002.phpt62
24 files changed, 1173 insertions, 0 deletions
diff --git a/ext/reflection/tests/001.phpt b/ext/reflection/tests/001.phpt
new file mode 100755
index 000000000..6a9d31a30
--- /dev/null
+++ b/ext/reflection/tests/001.phpt
@@ -0,0 +1,89 @@
+--TEST--
+Reflection inheritance
+--FILE--
+<?php
+
+class ReflectionClassEx extends ReflectionClass
+{
+ public $bla;
+
+ function getMethodNames()
+ {
+ $res = array();
+ foreach($this->getMethods() as $m)
+ {
+ $res[] = $m->class . '::' . $m->name;
+ }
+ return $res;
+ }
+}
+
+$r = new ReflectionClassEx('ReflectionClassEx');
+
+$exp = array (
+ 'UMLClass::__clone',
+ 'UMLClass::export',
+ 'UMLClass::__construct',
+ 'UMLClass::__toString',
+ 'UMLClass::getName',
+ 'UMLClass::isInternal',
+ 'UMLClass::isUserDefined',
+ 'UMLClass::isInstantiable',
+ 'UMLClass::getFileName',
+ 'UMLClass::getStartLine',
+ 'UMLClass::getEndLine',
+ 'UMLClass::getDocComment',
+ 'UMLClass::getConstructor',
+ 'UMLClass::getMethod',
+ 'UMLClass::getMethods',
+ 'UMLClass::getProperty',
+ 'UMLClass::getProperties',
+ 'UMLClass::getConstants',
+ 'UMLClass::getConstant',
+ 'UMLClass::getInterfaces',
+ 'UMLClass::isInterface',
+ 'UMLClass::isAbstract',
+ 'UMLClass::isFinal',
+ 'UMLClass::getModifiers',
+ 'UMLClass::isInstance',
+ 'UMLClass::newInstance',
+ 'UMLClass::getParentClass',
+ 'UMLClass::isSubclassOf',
+ 'UMLClass::getStaticProperties',
+ 'UMLClass::getDefaultProperties',
+ 'UMLClass::isIterateable',
+ 'UMLClass::implementsInterface',
+ 'UMLClass::getExtension',
+ 'UMLClass::getExtensionName');
+
+$miss = array();
+
+$res = $r->getMethodNames();
+
+foreach($exp as $m)
+{
+ if (!in_array($m, $exp))
+ {
+ $miss[] = $m;
+ }
+}
+
+var_dump($miss);
+
+$props = array_keys(get_class_vars('ReflectionClassEx'));
+sort($props);
+var_dump($props);
+var_dump($r->name);
+?>
+===DONE===
+--EXPECT--
+array(0) {
+}
+array(2) {
+ [0]=>
+ string(3) "bla"
+ [1]=>
+ string(4) "name"
+}
+string(17) "ReflectionClassEx"
+===DONE===
diff --git a/ext/reflection/tests/002.phpt b/ext/reflection/tests/002.phpt
new file mode 100755
index 000000000..bef4c8166
--- /dev/null
+++ b/ext/reflection/tests/002.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Reflection properties are read only
+--FILE--
+<?php
+
+class ReflectionMethodEx extends ReflectionMethod
+{
+ public $foo = "xyz";
+
+ function __construct($c,$m)
+ {
+ echo __METHOD__ . "\n";
+ parent::__construct($c,$m);
+ }
+}
+
+$r = new ReflectionMethodEx('ReflectionMethodEx','getName');
+
+var_dump($r->class);
+var_dump($r->name);
+var_dump($r->foo);
+@var_dump($r->bar);
+
+try
+{
+ $r->class = 'bullshit';
+}
+catch(ReflectionException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+try
+{
+$r->name = 'bullshit';
+}
+catch(ReflectionException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+$r->foo = 'bar';
+$r->bar = 'baz';
+
+var_dump($r->class);
+var_dump($r->name);
+var_dump($r->foo);
+var_dump($r->bar);
+
+?>
+===DONE===
+--EXPECTF--
+ReflectionMethodEx::__construct
+string(18) "ReflectionMethodEx"
+string(7) "getName"
+string(3) "xyz"
+NULL
+Cannot set read-only property ReflectionMethodEx::$class
+Cannot set read-only property ReflectionMethodEx::$name
+string(18) "ReflectionMethodEx"
+string(7) "getName"
+string(3) "bar"
+string(3) "baz"
+===DONE===
diff --git a/ext/reflection/tests/003.phpt b/ext/reflection/tests/003.phpt
new file mode 100755
index 000000000..660389255
--- /dev/null
+++ b/ext/reflection/tests/003.phpt
@@ -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===
diff --git a/ext/reflection/tests/004.phpt b/ext/reflection/tests/004.phpt
new file mode 100755
index 000000000..f8a448e6c
--- /dev/null
+++ b/ext/reflection/tests/004.phpt
@@ -0,0 +1,42 @@
+--TEST--
+invoke() with non object or null value
+--FILE--
+<?php
+
+class a {
+ function a(){
+ }
+}
+class b {
+}
+
+$b = new b();
+
+$a=new ReflectionClass("a");
+$m=$a->getMethod("a");
+
+try {
+ $m->invoke(null);
+} catch (ReflectionException $E) {
+ echo $E->getMessage()."\n";
+}
+
+
+try {
+ $m->invoke($b);
+} catch (ReflectionException $E) {
+ echo $E->getMessage()."\n";
+}
+
+$b = new a();
+try {
+ $m->invoke($b);
+} catch (ReflectionException $E) {
+ echo $E->getMessage()."\n";
+}
+
+echo "===DONE===\n";?>
+--EXPECT--
+Non-object passed to Invoke()
+Given object is not an instance of the class this method was declared in
+===DONE===
diff --git a/ext/reflection/tests/005.phpt b/ext/reflection/tests/005.phpt
new file mode 100755
index 000000000..f337e44ae
--- /dev/null
+++ b/ext/reflection/tests/005.phpt
@@ -0,0 +1,54 @@
+--TEST--
+ReflectionMethod::getDocComment() uses wrong comment block
+--FILE--
+<?php
+
+function strip_doc_comment($c)
+{
+ if (!strlen($c) || $c === false) return $c;
+ return trim(substr($c, 3, -2));
+}
+
+/** Comment for class A */
+class A
+{
+ /** Method A::bla()
+ */
+ function bla()
+ {
+ }
+
+ function foo() {
+ /**
+ * This is a valid comment inside a method
+ */
+ }
+
+ function bar() {
+ // I don't have a doc comment....
+ }
+
+ /**
+ * Comment for A::baz()
+ */
+ function baz() {
+ }
+}
+
+$r = new ReflectionClass('A');
+var_dump(strip_doc_comment($r->getDocComment()));
+
+foreach($r->getMethods() as $m)
+{
+ var_dump(strip_doc_comment($m->getDocComment()));
+}
+
+?>
+===DONE===
+--EXPECT--
+string(19) "Comment for class A"
+string(15) "Method A::bla()"
+bool(false)
+bool(false)
+string(22) "* Comment for A::baz()"
+===DONE===
diff --git a/ext/reflection/tests/006.phpt b/ext/reflection/tests/006.phpt
new file mode 100755
index 000000000..89c438765
--- /dev/null
+++ b/ext/reflection/tests/006.phpt
@@ -0,0 +1,103 @@
+--TEST--
+ReflectionClass::[gs]etStaticPropertyValue
+--FILE--
+<?php
+
+/* ReflectionClass cannot touch protected or private static properties */
+
+/* ReflectionClass cannot create or delete static properties */
+
+Class Test
+{
+ static public $pub = 'pub';
+ static protected $pro = 'pro';
+ static private $pri = 'pri';
+
+ static function testing()
+ {
+ $ref = new ReflectionClass('Test');
+
+ foreach(array('pub', 'pro', 'pri') as $name)
+ {
+ try
+ {
+ var_dump($ref->getStaticPropertyValue($name));
+ var_dump($ref->getStaticPropertyValue($name));
+ $ref->setStaticPropertyValue($name, 'updated');
+ var_dump($ref->getStaticPropertyValue($name));
+ }
+ catch(Exception $e)
+ {
+ echo "EXCEPTION\n";
+ }
+ }
+ }
+}
+
+Class TestDerived extends Test
+{
+// static public $pub = 'pub';
+// static protected $pro = 'pro';
+ static private $pri = 'pri';
+
+ static function testing()
+ {
+ $ref = new ReflectionClass('Test');
+
+ foreach(array('pub', 'pro', 'pri') as $name)
+ {
+ try
+ {
+ var_dump($ref->getStaticPropertyValue($name));
+ var_dump($ref->getStaticPropertyValue($name));
+ $ref->setStaticPropertyValue($name, 'updated');
+ var_dump($ref->getStaticPropertyValue($name));
+ }
+ catch(Exception $e)
+ {
+ echo "EXCEPTION\n";
+ }
+ }
+ }
+}
+
+$ref = new ReflectionClass('Test');
+
+foreach(array('pub', 'pro', 'pri') as $name)
+{
+ try
+ {
+ var_dump($ref->getStaticPropertyValue($name));
+ var_dump($ref->getStaticPropertyValue($name));
+ $ref->setStaticPropertyValue($name, 'updated');
+ var_dump($ref->getStaticPropertyValue($name));
+ }
+ catch(Exception $e)
+ {
+ echo "EXCEPTION\n";
+ }
+}
+
+Test::testing();
+TestDerived::testing();
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+string(3) "pub"
+string(3) "pub"
+string(7) "updated"
+EXCEPTION
+EXCEPTION
+string(7) "updated"
+string(7) "updated"
+string(7) "updated"
+EXCEPTION
+EXCEPTION
+string(7) "updated"
+string(7) "updated"
+string(7) "updated"
+EXCEPTION
+EXCEPTION
+===DONE===
diff --git a/ext/reflection/tests/bug26640.phpt b/ext/reflection/tests/bug26640.phpt
new file mode 100755
index 000000000..2cbd0d23d
--- /dev/null
+++ b/ext/reflection/tests/bug26640.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #26640 (__autoload() not invoked by Reflection classes)
+--FILE--
+<?php
+
+function __autoload($c)
+{
+ class autoload_class
+ {
+ public function __construct()
+ {
+ print "autoload success\n";
+ }
+ }
+}
+
+$a = new ReflectionClass('autoload_class');
+
+if (is_object($a)) {
+ echo "OK\n";
+}
+
+?>
+--EXPECT--
+OK
diff --git a/ext/reflection/tests/bug26695.phpt b/ext/reflection/tests/bug26695.phpt
new file mode 100755
index 000000000..38e6607c3
--- /dev/null
+++ b/ext/reflection/tests/bug26695.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #26695 (Reflection API does not recognize mixed-case class hints)
+--FILE--
+<?php
+
+class Foo {
+}
+
+class Bar {
+ function demo(foo $f) {
+ }
+}
+
+$class = new ReflectionClass('bar');
+$methods = $class->getMethods();
+$params = $methods[0]->getParameters();
+
+$class = $params[0]->getClass();
+
+var_dump($class->getName());
+?>
+===DONE===
+--EXPECT--
+string(3) "Foo"
+===DONE=== \ No newline at end of file
diff --git a/ext/reflection/tests/bug29268.phpt b/ext/reflection/tests/bug29268.phpt
new file mode 100755
index 000000000..335ee7337
--- /dev/null
+++ b/ext/reflection/tests/bug29268.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #29268 (__autoload() not called with reflectionProperty->getClass())
+--FILE--
+<?php
+function __autoload($classname) {
+ echo "__autoload($classname)\n";
+ eval("class $classname {}");
+}
+
+class B{
+ public function doit(A $a){
+ }
+}
+
+$ref = new reflectionMethod('B','doit');
+$parameters = $ref->getParameters();
+foreach($parameters as $parameter){
+ $class = $parameter->getClass();
+ echo $class->name."\n";
+}
+echo "ok\n";
+?>
+--EXPECT--
+__autoload(A)
+A
+ok
diff --git a/ext/reflection/tests/bug29523.phpt b/ext/reflection/tests/bug29523.phpt
new file mode 100755
index 000000000..4eb357cc2
--- /dev/null
+++ b/ext/reflection/tests/bug29523.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #29523 (ReflectionParameter::isOptional() is incorrect)
+--FILE--
+<?php
+
+class TestClass
+{
+}
+
+function optionalTest(TestClass $a, TestClass $b, $c = 3)
+{
+}
+
+$function = new ReflectionFunction('optionalTest');
+$numberOfNotOptionalParameters = 0;
+$numberOfOptionalParameters = 0;
+foreach($function->getParameters() as $parameter)
+{
+ var_dump($parameter->isOptional());
+ if ($parameter->isOptional())
+ {
+ ++$numberOfOptionalParameters;
+ }
+ else
+ {
+ ++$numberOfNotOptionalParameters;
+ }
+}
+var_dump($function->getNumberOfRequiredParameters());
+var_dump($numberOfNotOptionalParameters);
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
+bool(true)
+int(2)
+int(2)
diff --git a/ext/reflection/tests/bug29828.phpt b/ext/reflection/tests/bug29828.phpt
new file mode 100755
index 000000000..e1c9bbd36
--- /dev/null
+++ b/ext/reflection/tests/bug29828.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Bug #29828 (Interfaces no longer work)
+--FILE--
+<?php
+
+interface Bla
+{
+ function bla();
+}
+
+class BlaMore implements Bla
+{
+ function bla()
+ {
+ echo "Hello\n";
+ }
+}
+
+$r = new ReflectionClass('BlaMore');
+
+var_dump(count($r->getMethods()));
+var_dump($r->getMethod('bla')->isConstructor());
+var_dump($r->getMethod('bla')->isAbstract());
+
+$o=new BlaMore;
+$o->bla();
+
+?>
+===DONE===
+--EXPECT--
+int(1)
+bool(false)
+bool(false)
+Hello
+===DONE===
diff --git a/ext/reflection/tests/bug30146.phpt b/ext/reflection/tests/bug30146.phpt
new file mode 100755
index 000000000..72c6d2e5f
--- /dev/null
+++ b/ext/reflection/tests/bug30146.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #30146 (ReflectionProperty->getValue() requires instance for static property)
+--FILE--
+<?php
+class test {
+ static public $a = 1;
+}
+
+$r = new ReflectionProperty('test', 'a');
+var_dump($r->getValue(null));
+
+$r->setValue(NULL, 2);
+var_dump($r->getValue());
+
+$r->setValue(3);
+var_dump($r->getValue());
+?>
+===DONE===
+--EXPECT--
+int(1)
+int(2)
+int(3)
+===DONE=== \ No newline at end of file
diff --git a/ext/reflection/tests/bug30148.phpt b/ext/reflection/tests/bug30148.phpt
new file mode 100755
index 000000000..bc4415bfd
--- /dev/null
+++ b/ext/reflection/tests/bug30148.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Bug #30148 (ReflectionMethod->isConstructor() fails for inherited classes)
+--FILE--
+<?php
+
+class Root
+{
+ function Root() {}
+}
+class Base extends Root
+{
+ function __construct() {}
+}
+class Derived extends Base
+{
+}
+$a = new ReflectionMethod('Root','Root');
+$b = new ReflectionMethod('Base','Root');
+$c = new ReflectionMethod('Base','__construct');
+$d = new ReflectionMethod('Derived','Root');
+$e = new ReflectionMethod('Derived','__construct');
+var_dump($a->isConstructor());
+var_dump($b->isConstructor());
+var_dump($c->isConstructor());
+var_dump($d->isConstructor());
+var_dump($e->isConstructor());
+?>
+===DONE===
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/reflection/tests/bug30209.phpt b/ext/reflection/tests/bug30209.phpt
new file mode 100755
index 000000000..6705c6704
--- /dev/null
+++ b/ext/reflection/tests/bug30209.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #30209 (ReflectionClass::getMethod() lowercases attribute)
+--FILE--
+<?php
+
+class Foo
+{
+ private $name = 'testBAR';
+
+ public function testBAR()
+ {
+ try
+ {
+ $class = new ReflectionClass($this);
+ var_dump($this->name);
+ $method = $class->getMethod($this->name);
+ var_dump($this->name);
+ }
+
+ catch (Exception $e) {}
+ }
+}
+
+$foo = new Foo;
+$foo->testBAR();
+?>
+===DONE===
+--EXPECTF--
+string(7) "testBAR"
+string(7) "testBAR"
+===DONE===
diff --git a/ext/reflection/tests/bug30856.phpt b/ext/reflection/tests/bug30856.phpt
new file mode 100755
index 000000000..6c6d3171a
--- /dev/null
+++ b/ext/reflection/tests/bug30856.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #30856 (ReflectionClass::getStaticProperties segfaults)
+--FILE--
+<?php
+class bogus {
+ const C = 'test';
+ static $a = bogus::C;
+}
+
+$class = new ReflectionClass('bogus');
+
+var_dump($class->getStaticProperties());
+?>
+===DONE===
+--EXPECT--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+===DONE===
diff --git a/ext/reflection/tests/bug30961.phpt b/ext/reflection/tests/bug30961.phpt
new file mode 100755
index 000000000..67964343e
--- /dev/null
+++ b/ext/reflection/tests/bug30961.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #30961 (Wrong linenumber in ReflectionClass getStartLine())
+--FILE--
+<?php
+ class a
+ {
+ }
+
+ class b extends a
+ {
+ }
+
+ $ref1 = new ReflectionClass('a');
+ $ref2 = new ReflectionClass('b');
+ echo $ref1->getStartLine() . "\n";
+ echo $ref2->getStartLine() . "\n";
+?>
+--EXPECT--
+2
+6
diff --git a/ext/reflection/tests/bug31651.phpt b/ext/reflection/tests/bug31651.phpt
new file mode 100755
index 000000000..60bee14e9
--- /dev/null
+++ b/ext/reflection/tests/bug31651.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #31651 (ReflectionClass::getDefaultProperties segfaults with arrays.)
+--FILE--
+<?php
+
+class Test
+{
+ public $a = array('a' => 1);
+}
+
+$ref = new ReflectionClass('Test');
+
+print_r($ref->getDefaultProperties());
+
+?>
+--EXPECT--
+Array
+(
+ [a] => Array
+ (
+ [a] => 1
+ )
+
+)
diff --git a/ext/reflection/tests/bug32981.phpt b/ext/reflection/tests/bug32981.phpt
new file mode 100755
index 000000000..1f89ca682
--- /dev/null
+++ b/ext/reflection/tests/bug32981.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Bug #32981 (ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault)
+--FILE--
+<?php
+
+class TestClass
+{
+ static function test()
+ {
+ static $enabled = true;
+ }
+}
+
+$class = new ReflectionClass('TestClass');
+foreach ($class->getMethods() as $method)
+{
+ var_dump($method->getName());
+ $arr_static_vars[] = $method->getStaticVariables();
+}
+
+var_dump($arr_static_vars);
+
+?>
+===DONE===
+--EXPECT--
+string(4) "test"
+array(1) {
+ [0]=>
+ array(1) {
+ ["enabled"]=>
+ bool(true)
+ }
+}
+===DONE===
diff --git a/ext/reflection/tests/bug33312.phpt b/ext/reflection/tests/bug33312.phpt
new file mode 100755
index 000000000..3784b56a6
--- /dev/null
+++ b/ext/reflection/tests/bug33312.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #33312 (ReflectionParameter methods do not work correctly)
+--FILE--
+<?php
+class Foo {
+ public function bar(Foo $foo, $bar = 'bar') {
+ }
+}
+
+$class = new ReflectionClass('Foo');
+$method = $class->getMethod('bar');
+
+foreach ($method->getParameters() as $parameter) {
+ if ($parameter->isDefaultValueAvailable()) {
+ print $parameter->getDefaultValue()."\n";
+ }
+}
+?>
+--EXPECT--
+bar
diff --git a/ext/reflection/tests/bug33389.phpt b/ext/reflection/tests/bug33389.phpt
new file mode 100755
index 000000000..36f7079e2
--- /dev/null
+++ b/ext/reflection/tests/bug33389.phpt
@@ -0,0 +1,97 @@
+--TEST--
+Bug #33389 (double free() when exporting a ReflectionClass)
+--FILE--
+<?php
+define ('foobar', 1);
+class Test {
+ function foo1($arg=foobar) {
+ }
+ function foo2($arg=null) {
+ }
+ function foo3($arg=false) {
+ }
+ function foo4($arg='foo') {
+ }
+ function foo5($arg=1) {
+ }
+ function bar($arg) {
+ }
+ function foo() {
+ }
+}
+Reflection::export(new ReflectionClass('Test'));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Class [ <user> class Test ] {
+ @@ %sbug33389.php 3-18
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [7] {
+ Method [ <user> public method foo1 ] {
+ @@ %sbug33389.php 4 - 5
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = 1 ]
+ }
+ }
+
+ Method [ <user> public method foo2 ] {
+ @@ %sbug33389.php 6 - 7
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = NULL ]
+ }
+ }
+
+ Method [ <user> public method foo3 ] {
+ @@ %sbug33389.php 8 - 9
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = false ]
+ }
+ }
+
+ Method [ <user> public method foo4 ] {
+ @@ %sbug33389.php 10 - 11
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = 'foo' ]
+ }
+ }
+
+ Method [ <user> public method foo5 ] {
+ @@ %sbug33389.php 12 - 13
+
+ - Parameters [1] {
+ Parameter #0 [ <optional> $arg = 1 ]
+ }
+ }
+
+ Method [ <user> public method bar ] {
+ @@ %sbug33389.php 14 - 15
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $arg ]
+ }
+ }
+
+ Method [ <user> public method foo ] {
+ @@ %sbug33389.php 16 - 17
+ }
+ }
+}
+
+===DONE===
diff --git a/ext/reflection/tests/exception.inc b/ext/reflection/tests/exception.inc
new file mode 100644
index 000000000..e40333996
--- /dev/null
+++ b/ext/reflection/tests/exception.inc
@@ -0,0 +1,16 @@
+<?php
+class ReflectionExceptionEx extends ReflectionException {
+ function MyException($_errno, $_errmsg) {
+ $this->errno = $_errno;
+ $this->errmsg = $_errmsg;
+ }
+
+ function getErrno() {
+ return $this->errno;
+ }
+
+ function getErrmsg() {
+ return $this->errmsg;
+ }
+}
+?>
diff --git a/ext/reflection/tests/parameters_001.phpt b/ext/reflection/tests/parameters_001.phpt
new file mode 100755
index 000000000..0879756ea
--- /dev/null
+++ b/ext/reflection/tests/parameters_001.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Check for parameter being optional
+--FILE--
+<?php
+
+class Test {
+ function func($x, $y = NULL){
+ }
+}
+
+
+$f = new ReflectionMethod('Test', 'func');
+var_dump($f->getNumberOfParameters());
+var_dump($f->getNumberOfRequiredParameters());
+
+$p = new ReflectionParameter(array('Test', 'func'), 'x');
+var_dump($p->isOptional());
+
+$p = new ReflectionParameter(array('Test', 'func'), 'y');
+var_dump($p->isOptional());
+
+try {
+ $p = new ReflectionParameter(array('Test', 'func'), 'z');
+ var_dump($p->isOptional());
+}
+catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+===DONE===
+--EXPECT--
+int(2)
+int(1)
+bool(false)
+bool(true)
+string(54) "The parameter specified by its name could not be found"
+===DONE===
diff --git a/ext/reflection/tests/property_exists.phpt b/ext/reflection/tests/property_exists.phpt
new file mode 100755
index 000000000..fa712dfdb
--- /dev/null
+++ b/ext/reflection/tests/property_exists.phpt
@@ -0,0 +1,222 @@
+--TEST--
+ZE2 property_exists()
+--FILE--
+<?php
+
+class A
+{
+ public $a = 1;
+ protected $b = 2;
+ private $c = 3;
+
+ public $empty;
+ public $init = 1;
+
+ function __toString()
+ {
+ return 'obj(' . get_class($this) . ')';
+ }
+
+ static function test($oc, $props)
+ {
+ echo '===' . __CLASS__ . "===\n";
+ foreach($props as $p2) {
+ echo $oc, '::$' , $p2, "\n";
+ var_dump(property_exists($oc, $p2));
+ }
+ }
+}
+
+class B extends A
+{
+ private $c = 4;
+
+ static function test($oc, $props)
+ {
+ echo '===' . __CLASS__ . "===\n";
+ foreach($props as $p2) {
+ echo $oc, '::$' , $p2, "\n";
+ var_dump(property_exists($oc, $p2));
+ }
+ }
+}
+
+class C extends B
+{
+ private $d = 5;
+
+ static function test($oc, $props)
+ {
+ echo '===' . __CLASS__ . "===\n";
+ foreach($props as $p2) {
+ echo $oc, '::$' , $p2, "\n";
+ var_dump(property_exists($oc, $p2));
+ }
+ }
+}
+
+$oA = new A;
+$oA->e = 6;
+
+$oC = new C;
+
+$pc = array($oA, 'A', 'B', 'C', $oC);
+$pr = array('a', 'b', 'c', 'd', 'e');
+
+foreach($pc as $p1) {
+ if (is_object($p1)) {
+ $p1->test($p1, $pr);
+ } else {
+ $r = new ReflectionMethod($p1, 'test');
+ $r->invoke(NULL, $p1, $pr);
+ }
+ echo "===GLOBAL===\n";
+ foreach($pr as $p2) {
+ echo $p1, '::$' , $p2, "\n";
+ var_dump(property_exists($p1, $p2));
+ }
+}
+
+echo "===PROBLEMS===\n";
+var_dump(property_exists(NULL, 'empty'));
+var_dump(property_exists(25,'empty'));
+var_dump(property_exists('',''));
+var_dump(property_exists('A',''));
+var_dump(property_exists('A','123'));
+var_dump(property_exists('A','init'));
+var_dump(property_exists('A','empty'));
+var_dump(property_exists(new A, ''));
+var_dump(property_exists(new A, '123'));
+var_dump(property_exists(new A, 'init'));
+var_dump(property_exists(new A, 'empty'));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===A===
+obj(A)::$a
+bool(true)
+obj(A)::$b
+bool(true)
+obj(A)::$c
+bool(true)
+obj(A)::$d
+bool(false)
+obj(A)::$e
+bool(true)
+===GLOBAL===
+obj(A)::$a
+bool(true)
+obj(A)::$b
+bool(false)
+obj(A)::$c
+bool(false)
+obj(A)::$d
+bool(false)
+obj(A)::$e
+bool(true)
+===A===
+A::$a
+bool(true)
+A::$b
+bool(true)
+A::$c
+bool(true)
+A::$d
+bool(false)
+A::$e
+bool(false)
+===GLOBAL===
+A::$a
+bool(true)
+A::$b
+bool(false)
+A::$c
+bool(false)
+A::$d
+bool(false)
+A::$e
+bool(false)
+===B===
+B::$a
+bool(true)
+B::$b
+bool(true)
+B::$c
+bool(true)
+B::$d
+bool(false)
+B::$e
+bool(false)
+===GLOBAL===
+B::$a
+bool(true)
+B::$b
+bool(false)
+B::$c
+bool(false)
+B::$d
+bool(false)
+B::$e
+bool(false)
+===C===
+C::$a
+bool(true)
+C::$b
+bool(true)
+C::$c
+bool(false)
+C::$d
+bool(true)
+C::$e
+bool(false)
+===GLOBAL===
+C::$a
+bool(true)
+C::$b
+bool(false)
+C::$c
+bool(false)
+C::$d
+bool(false)
+C::$e
+bool(false)
+===C===
+obj(C)::$a
+bool(true)
+obj(C)::$b
+bool(true)
+obj(C)::$c
+bool(false)
+obj(C)::$d
+bool(true)
+obj(C)::$e
+bool(false)
+===GLOBAL===
+obj(C)::$a
+bool(true)
+obj(C)::$b
+bool(false)
+obj(C)::$c
+bool(false)
+obj(C)::$d
+bool(false)
+obj(C)::$e
+bool(false)
+===PROBLEMS===
+
+Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists.php on line %d
+NULL
+
+Warning: First parameter must either be an object or the name of an existing class in %sproperty_exists.php on line %d
+NULL
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/reflection/tests/static_properties_002.phpt b/ext/reflection/tests/static_properties_002.phpt
new file mode 100755
index 000000000..29b84a8e6
--- /dev/null
+++ b/ext/reflection/tests/static_properties_002.phpt
@@ -0,0 +1,62 @@
+--TEST--
+ZE2 Inheriting static properties
+--SKIPIF--
+<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
+--FILE--
+<?php
+
+class base {
+ static protected $prop = 2;
+
+ static function show() {
+ echo __METHOD__ . '(' . self::$prop . ")\n";
+ }
+
+ static function inc() {
+ base::$prop++;
+ echo __METHOD__ . "()\n";
+ }
+}
+
+class derived extends base {
+ static public $prop;
+
+ static function show() {
+ echo __METHOD__ . '(' . self::$prop . ")\n";
+ }
+
+ static function inc() {
+ derived::$prop++;
+ echo __METHOD__ . "()\n";
+ }
+}
+
+base::show();
+derived::show();
+
+base::inc();
+
+base::show();
+derived::show();
+
+derived::inc();
+
+base::show();
+derived::show();
+
+$r = new ReflectionClass('derived');
+echo 'Number of properties: '. count($r->getStaticProperties()) . "\n";
+
+echo "Done\n";
+?>
+--EXPECTF--
+base::show(2)
+derived::show(2)
+base::inc()
+base::show(3)
+derived::show(3)
+derived::inc()
+base::show(4)
+derived::show(4)
+Number of properties: 1
+Done