summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:39:08 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:39:08 -0400
commit993e1866df547532a05ab6db76c9ff5aefc9a3df (patch)
tree169d3bde0974235d3cde164786ef6f381a4749a7 /ext/reflection
parent1f589a2bd44ba835ad1b009a5d83abd453724829 (diff)
downloadphp-993e1866df547532a05ab6db76c9ff5aefc9a3df.tar.gz
Imported Upstream version 5.2.6upstream/5.2.6
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c19
-rw-r--r--ext/reflection/php_reflection.h4
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic1.phpt300
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic2.phpt188
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic3.phpt169
-rw-r--r--ext/reflection/tests/ReflectionMethod_basic4.phpt172
-rw-r--r--ext/reflection/tests/ReflectionMethod_constructor_basic.phpt121
-rw-r--r--ext/reflection/tests/ReflectionMethod_getDeclaringClass_basic.phpt32
-rw-r--r--ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt115
-rw-r--r--ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt19
-rw-r--r--ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt244
-rw-r--r--ext/reflection/tests/ReflectionMethod_getStaticVariables_basic.phpt65
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt75
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt38
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt29
-rw-r--r--ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt119
-rw-r--r--ext/reflection/tests/ReflectionMethod_invoke_basic.phpt110
-rw-r--r--ext/reflection/tests/ReflectionMethod_invoke_error1.phpt73
-rw-r--r--ext/reflection/tests/ReflectionMethod_invoke_error2.phpt34
-rw-r--r--ext/reflection/tests/ReflectionMethod_returnsReference_basic.phpt25
-rw-r--r--ext/reflection/tests/reflectionProperty_basic1.phpt162
-rw-r--r--ext/reflection/tests/reflectionProperty_basic2.phpt105
-rw-r--r--ext/reflection/tests/reflectionProperty_constructor_error.phpt46
-rw-r--r--ext/reflection/tests/reflectionProperty_error.phpt70
-rw-r--r--ext/reflection/tests/reflectionProperty_export_basic.phpt18
-rw-r--r--ext/reflection/tests/reflectionProperty_export_error.phpt56
-rw-r--r--ext/reflection/tests/reflectionProperty_getDeclaringClass_variation1.phpt29
-rw-r--r--ext/reflection/tests/reflectionProperty_getDocComment_basic.phpt102
-rw-r--r--ext/reflection/tests/reflectionProperty_getDocComment_error.phpt31
-rw-r--r--ext/reflection/tests/reflectionProperty_getModifiers_basic.phpt48
-rw-r--r--ext/reflection/tests/reflectionProperty_getValue_error.phpt83
-rw-r--r--ext/reflection/tests/reflectionProperty_isDefault_basic.phpt65
-rw-r--r--ext/reflection/tests/reflectionProperty_setValue_error.phpt102
33 files changed, 2857 insertions, 11 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 3e3e4b67a..88791a3fe 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.c,v 1.164.2.33.2.47 2007/10/28 13:47:14 iliaa Exp $ */
+/* $Id: php_reflection.c,v 1.164.2.33.2.50 2008/03/13 15:56:21 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -836,7 +836,7 @@ static int _extension_ini_string(zend_ini_entry *ini_entry, int num_args, va_lis
if (number == ini_entry->module_number) {
string_printf(str, " %sEntry [ %s <", indent, ini_entry->name);
- if (ini_entry->modifiable == ZEND_INI_ALL) {
+ if (ini_entry->modifiable & ZEND_INI_ALL) {
string_printf(str, "ALL");
} else {
if (ini_entry->modifiable & ZEND_INI_USER) {
@@ -2144,7 +2144,6 @@ ZEND_METHOD(reflection_parameter, getDefaultValue)
reflection_object *intern;
parameter_reference *param;
zend_op *precv;
- zval *zv, zv_copy;
METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0);
GET_REFLECTION_OBJECT_PTR(param);
@@ -2164,10 +2163,12 @@ ZEND_METHOD(reflection_parameter, getDefaultValue)
return;
}
- zv_copy = precv->op2.u.constant;
- zv = &zv_copy;
- zval_update_constant_ex(&zv, (void*)0, param->fptr->common.scope TSRMLS_CC);
- RETURN_ZVAL(zv, 1, 1);
+ *return_value = precv->op2.u.constant;
+ INIT_PZVAL(return_value);
+ if (Z_TYPE_P(return_value) != IS_CONSTANT) {
+ zval_copy_ctor(return_value);
+ }
+ zval_update_constant_ex(&return_value, (void*)0, param->fptr->common.scope TSRMLS_CC);
}
/* }}} */
@@ -4907,7 +4908,7 @@ PHP_MINFO_FUNCTION(reflection) /* {{{ */
php_info_print_table_start();
php_info_print_table_header(2, "Reflection", "enabled");
- php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.33.2.47 2007/10/28 13:47:14 iliaa Exp $");
+ php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.33.2.50 2008/03/13 15:56:21 iliaa Exp $");
php_info_print_table_end();
} /* }}} */
diff --git a/ext/reflection/php_reflection.h b/ext/reflection/php_reflection.h
index 8ebeffb63..f7ff5fe4c 100644
--- a/ext/reflection/php_reflection.h
+++ b/ext/reflection/php_reflection.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.h,v 1.4.2.3.2.2 2007/01/01 09:36:05 sebastian Exp $ */
+/* $Id: php_reflection.h,v 1.4.2.3.2.3 2007/12/31 07:20:10 sebastian Exp $ */
#ifndef PHP_REFLECTION_H
#define PHP_REFLECTION_H
diff --git a/ext/reflection/tests/ReflectionMethod_basic1.phpt b/ext/reflection/tests/ReflectionMethod_basic1.phpt
new file mode 100644
index 000000000..8671c5acb
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_basic1.phpt
@@ -0,0 +1,300 @@
+--TEST--
+ReflectionMethod class - various methods
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function reflectMethod($class, $method) {
+ $methodInfo = new ReflectionMethod($class, $method);
+ echo "**********************************\n";
+ echo "Reflecting on method $class::$method()\n\n";
+ echo "\nisFinal():\n";
+ var_dump($methodInfo->isFinal());
+ echo "\nisAbstract():\n";
+ var_dump($methodInfo->isAbstract());
+ echo "\nisPublic():\n";
+ var_dump($methodInfo->isPublic());
+ echo "\nisPrivate():\n";
+ var_dump($methodInfo->isPrivate());
+ echo "\nisProtected():\n";
+ var_dump($methodInfo->isProtected());
+ echo "\nisStatic():\n";
+ var_dump($methodInfo->isStatic());
+ echo "\nisConstructor():\n";
+ var_dump($methodInfo->isConstructor());
+ echo "\nisDestructor():\n";
+ var_dump($methodInfo->isDestructor());
+ echo "\n**********************************\n";
+}
+
+class TestClass
+{
+ public function foo() {
+ echo "Called foo()\n";
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public function __destruct() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+}
+
+reflectMethod("DerivedClass", "foo");
+reflectMethod("TestClass", "stat");
+reflectMethod("TestClass", "priv");
+reflectMethod("TestClass", "prot");
+reflectMethod("DerivedClass", "prot");
+reflectMethod("TestInterface", "int");
+reflectMethod("ReflectionProperty", "__construct");
+reflectMethod("TestClass", "__destruct");
+
+?>
+--EXPECT--
+**********************************
+Reflecting on method DerivedClass::foo()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::stat()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(true)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::priv()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(false)
+
+isPrivate():
+bool(true)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::prot()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(false)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(true)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method DerivedClass::prot()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(false)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(true)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestInterface::int()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(true)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method ReflectionProperty::__construct()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(true)
+
+isDestructor():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::__destruct()
+
+
+isFinal():
+bool(false)
+
+isAbstract():
+bool(false)
+
+isPublic():
+bool(true)
+
+isPrivate():
+bool(false)
+
+isProtected():
+bool(false)
+
+isStatic():
+bool(false)
+
+isConstructor():
+bool(false)
+
+isDestructor():
+bool(true)
+
+**********************************
+
+
diff --git a/ext/reflection/tests/ReflectionMethod_basic2.phpt b/ext/reflection/tests/ReflectionMethod_basic2.phpt
new file mode 100644
index 000000000..56ddb7fce
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_basic2.phpt
@@ -0,0 +1,188 @@
+--TEST--
+ReflectionMethod class __toString() and export() methods
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function reflectMethod($class, $method) {
+ $methodInfo = new ReflectionMethod($class, $method);
+ echo "**********************************\n";
+ echo "Reflecting on method $class::$method()\n\n";
+ echo "__toString():\n";
+ var_dump($methodInfo->__toString());
+ echo "\nexport():\n";
+ var_dump(ReflectionMethod::export($class, $method, true));
+ echo "\n**********************************\n";
+}
+
+class TestClass
+{
+ public function foo() {
+ echo "Called foo()\n";
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public function __destruct() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+}
+
+reflectMethod("DerivedClass", "foo");
+reflectMethod("TestClass", "stat");
+reflectMethod("TestClass", "priv");
+reflectMethod("TestClass", "prot");
+reflectMethod("DerivedClass", "prot");
+reflectMethod("TestInterface", "int");
+reflectMethod("ReflectionProperty", "__construct");
+reflectMethod("TestClass", "__destruct");
+
+?>
+--EXPECTF--
+**********************************
+Reflecting on method DerivedClass::foo()
+
+__toString():
+string(%d) "Method [ <user, inherits TestClass> public method foo ] {
+ @@ %s 16 - 18
+}
+"
+
+export():
+string(%d) "Method [ <user, inherits TestClass> public method foo ] {
+ @@ %s 16 - 18
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestClass::stat()
+
+__toString():
+string(%d) "Method [ <user> static public method stat ] {
+ @@ %s 20 - 22
+}
+"
+
+export():
+string(%d) "Method [ <user> static public method stat ] {
+ @@ %s 20 - 22
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestClass::priv()
+
+__toString():
+string(%d) "Method [ <user> private method priv ] {
+ @@ %s 24 - 26
+}
+"
+
+export():
+string(%d) "Method [ <user> private method priv ] {
+ @@ %s 24 - 26
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestClass::prot()
+
+__toString():
+string(%d) "Method [ <user> protected method prot ] {
+ @@ %s 28 - 28
+}
+"
+
+export():
+string(%d) "Method [ <user> protected method prot ] {
+ @@ %s 28 - 28
+}
+"
+
+**********************************
+**********************************
+Reflecting on method DerivedClass::prot()
+
+__toString():
+string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
+ @@ %s 28 - 28
+}
+"
+
+export():
+string(%d) "Method [ <user, inherits TestClass> protected method prot ] {
+ @@ %s 28 - 28
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestInterface::int()
+
+__toString():
+string(%d) "Method [ <user> abstract public method int ] {
+ @@ %s 36 - 36
+}
+"
+
+export():
+string(%d) "Method [ <user> abstract public method int ] {
+ @@ %s 36 - 36
+}
+"
+
+**********************************
+**********************************
+Reflecting on method ReflectionProperty::__construct()
+
+__toString():
+string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $argument ]
+ }
+}
+"
+
+export():
+string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $argument ]
+ }
+}
+"
+
+**********************************
+**********************************
+Reflecting on method TestClass::__destruct()
+
+__toString():
+string(%d) "Method [ <user, dtor> public method __destruct ] {
+ @@ %s 30 - 30
+}
+"
+
+export():
+string(%d) "Method [ <user, dtor> public method __destruct ] {
+ @@ %s 30 - 30
+}
+"
+
+**********************************
diff --git a/ext/reflection/tests/ReflectionMethod_basic3.phpt b/ext/reflection/tests/ReflectionMethod_basic3.phpt
new file mode 100644
index 000000000..3bc517138
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_basic3.phpt
@@ -0,0 +1,169 @@
+--TEST--
+ReflectionMethod class getName(), isInternal() and isUserDefined() methods
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function reflectMethod($class, $method) {
+ $methodInfo = new ReflectionMethod($class, $method);
+ echo "**********************************\n";
+ echo "Reflecting on method $class::$method()\n\n";
+ echo "\ngetName():\n";
+ var_dump($methodInfo->getName());
+ echo "\nisInternal():\n";
+ var_dump($methodInfo->isInternal());
+ echo "\nisUserDefined():\n";
+ var_dump($methodInfo->isUserDefined());
+ echo "\n**********************************\n";
+}
+
+class TestClass
+{
+ public function foo() {
+ echo "Called foo()\n";
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public function __destruct() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+}
+
+reflectMethod("DerivedClass", "foo");
+reflectMethod("TestClass", "stat");
+reflectMethod("TestClass", "priv");
+reflectMethod("TestClass", "prot");
+reflectMethod("DerivedClass", "prot");
+reflectMethod("TestInterface", "int");
+reflectMethod("ReflectionProperty", "__construct");
+reflectMethod("TestClass", "__destruct");
+
+
+?>
+--EXPECT--
+**********************************
+Reflecting on method DerivedClass::foo()
+
+
+getName():
+string(3) "foo"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method TestClass::stat()
+
+
+getName():
+string(4) "stat"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method TestClass::priv()
+
+
+getName():
+string(4) "priv"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method TestClass::prot()
+
+
+getName():
+string(4) "prot"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method DerivedClass::prot()
+
+
+getName():
+string(4) "prot"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method TestInterface::int()
+
+
+getName():
+string(3) "int"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on method ReflectionProperty::__construct()
+
+
+getName():
+string(11) "__construct"
+
+isInternal():
+bool(true)
+
+isUserDefined():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::__destruct()
+
+
+getName():
+string(10) "__destruct"
+
+isInternal():
+bool(false)
+
+isUserDefined():
+bool(true)
+
+**********************************
diff --git a/ext/reflection/tests/ReflectionMethod_basic4.phpt b/ext/reflection/tests/ReflectionMethod_basic4.phpt
new file mode 100644
index 000000000..9aac8c67f
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_basic4.phpt
@@ -0,0 +1,172 @@
+--TEST--
+ReflectionMethod class getFileName(), getStartLine() and getEndLine() methods
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function reflectMethod($class, $method) {
+ $methodInfo = new ReflectionMethod($class, $method);
+ echo "**********************************\n";
+ echo "Reflecting on method $class::$method()\n\n";
+ echo "\ngetFileName():\n";
+ var_dump($methodInfo->getFileName());
+ echo "\ngetStartLine():\n";
+ var_dump($methodInfo->getStartLine());
+ echo "\ngetEndLine():\n";
+ var_dump($methodInfo->getEndLine());
+ echo "\n**********************************\n";
+}
+
+class TestClass
+{
+ public function foo() {
+
+
+ echo "Called foo()\n";
+
+
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public function __destruct() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+}
+
+reflectMethod("DerivedClass", "foo");
+reflectMethod("TestClass", "stat");
+reflectMethod("TestClass", "priv");
+reflectMethod("TestClass", "prot");
+reflectMethod("DerivedClass", "prot");
+reflectMethod("TestInterface", "int");
+reflectMethod("ReflectionProperty", "__construct");
+reflectMethod("TestClass", "__destruct");
+
+?>
+--EXPECTF--
+**********************************
+Reflecting on method DerivedClass::foo()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(18)
+
+getEndLine():
+int(24)
+
+**********************************
+**********************************
+Reflecting on method TestClass::stat()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(26)
+
+getEndLine():
+int(28)
+
+**********************************
+**********************************
+Reflecting on method TestClass::priv()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(30)
+
+getEndLine():
+int(32)
+
+**********************************
+**********************************
+Reflecting on method TestClass::prot()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(34)
+
+getEndLine():
+int(34)
+
+**********************************
+**********************************
+Reflecting on method DerivedClass::prot()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(34)
+
+getEndLine():
+int(34)
+
+**********************************
+**********************************
+Reflecting on method TestInterface::int()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(42)
+
+getEndLine():
+int(42)
+
+**********************************
+**********************************
+Reflecting on method ReflectionProperty::__construct()
+
+
+getFileName():
+bool(false)
+
+getStartLine():
+bool(false)
+
+getEndLine():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on method TestClass::__destruct()
+
+
+getFileName():
+string(%d) "%sReflectionMethod_basic4.php"
+
+getStartLine():
+int(36)
+
+getEndLine():
+int(36)
+
+**********************************
diff --git a/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
new file mode 100644
index 000000000..5655b0eea
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
@@ -0,0 +1,121 @@
+--TEST--
+ReflectionMethod::isConstructor()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class NewCtor {
+ function __construct() {
+ echo "In " . __METHOD__ . "\n";
+ }
+
+}
+echo "New-style constructor:\n";
+$methodInfo = new ReflectionMethod("NewCtor::__construct");
+var_dump($methodInfo->isConstructor());
+
+class ExtendsNewCtor extends NewCtor {
+}
+echo "\nInherited new-style constructor\n";
+$methodInfo = new ReflectionMethod("ExtendsNewCtor::__construct");
+var_dump($methodInfo->isConstructor());
+
+class OldCtor {
+ function OldCtor() {
+ echo "In " . __METHOD__ . "\n";
+ }
+}
+echo "\nOld-style constructor:\n";
+$methodInfo = new ReflectionMethod("OldCtor::OldCtor");
+var_dump($methodInfo->isConstructor());
+
+class ExtendsOldCtor extends OldCtor {
+}
+echo "\nInherited old-style constructor:\n";
+$methodInfo = new ReflectionMethod("ExtendsOldCtor::OldCtor");
+var_dump($methodInfo->isConstructor());
+
+class X {
+ function Y() {
+ echo "In " . __METHOD__ . "\n";
+ }
+}
+echo "\nNot a constructor:\n";
+$methodInfo = new ReflectionMethod("X::Y");
+var_dump($methodInfo->isConstructor());
+
+class Y extends X {
+}
+echo "\nInherited method of the same name as the class:\n";
+$methodInfo = new ReflectionMethod("Y::Y");
+var_dump($methodInfo->isConstructor());
+
+class OldAndNewCtor {
+ function OldAndNewCtor() {
+ echo "In " . __METHOD__ . "\n";
+ }
+
+ function __construct() {
+ echo "In " . __METHOD__ . "\n";
+ }
+}
+echo "\nOld-style constructor:\n";
+$methodInfo = new ReflectionMethod("OldAndNewCtor::OldAndNewCtor");
+var_dump($methodInfo->isConstructor());
+
+echo "\nRedefined constructor:\n";
+$methodInfo = new ReflectionMethod("OldAndNewCtor::__construct");
+var_dump($methodInfo->isConstructor());
+
+class NewAndOldCtor {
+ function __construct() {
+ echo "In " . __METHOD__ . "\n";
+ }
+
+ function NewAndOldCtor() {
+ echo "In " . __METHOD__ . "\n";
+ }
+}
+echo "\nNew-style constructor:\n";
+$methodInfo = new ReflectionMethod("NewAndOldCtor::__construct");
+var_dump($methodInfo->isConstructor());
+
+echo "\nRedefined old-style constructor:\n";
+$methodInfo = new ReflectionMethod("NewAndOldCtor::NewAndOldCtor");
+var_dump($methodInfo->isConstructor());
+
+?>
+--EXPECTF--
+Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line %d
+
+Strict Standards: %s for class NewAndOldCtor in %s on line %d
+New-style constructor:
+bool(true)
+
+Inherited new-style constructor
+bool(true)
+
+Old-style constructor:
+bool(true)
+
+Inherited old-style constructor:
+bool(true)
+
+Not a constructor:
+bool(false)
+
+Inherited method of the same name as the class:
+bool(false)
+
+Old-style constructor:
+bool(false)
+
+Redefined constructor:
+bool(true)
+
+New-style constructor:
+bool(true)
+
+Redefined old-style constructor:
+bool(false)
diff --git a/ext/reflection/tests/ReflectionMethod_getDeclaringClass_basic.phpt b/ext/reflection/tests/ReflectionMethod_getDeclaringClass_basic.phpt
new file mode 100644
index 000000000..f043e5247
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getDeclaringClass_basic.phpt
@@ -0,0 +1,32 @@
+--TEST--
+ReflectionMethod::getDeclaringClass()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class A {
+ function foo() {}
+}
+
+class B extends A {
+ function bar() {}
+}
+
+$methodInfo = new ReflectionMethod('B', 'foo');
+var_dump($methodInfo->getDeclaringClass());
+
+$methodInfo = new ReflectionMethod('B', 'bar');
+var_dump($methodInfo->getDeclaringClass());
+
+?>
+--EXPECTF--
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(1) "A"
+}
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(1) "B"
+}
+
diff --git a/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt
new file mode 100644
index 000000000..542ddf014
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt
@@ -0,0 +1,115 @@
+--TEST--
+ReflectionMethod::getDocComment()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+/**
+ * My Doc Comment for A
+ */
+class A {
+ /**
+ * My Doc Comment for A::f
+ */
+ function f() {}
+
+ /**
+ * My Doc Comment for A::privf
+ */
+ private function privf() {}
+
+ /** My Doc Comment for A::protStatf */
+ protected static function protStatf() {}
+
+ /**
+
+ * My Doc Comment for A::finalStatPubf
+ */
+ final static public function finalStatPubf() {}
+
+}
+
+
+class B extends A {
+ /*** Not a doc comment */
+ function f() {}
+
+ /** *
+ * My Doc Comment for B::privf
+ */
+
+
+
+
+ private function privf() {}
+
+
+ /** My Doc Comment for B::protStatf
+
+
+
+
+ */
+ protected static function protStatf() {}
+
+}
+
+foreach (array('A', 'B') as $class) {
+ $rc = new ReflectionClass($class);
+ $rms = $rc->getMethods();
+ foreach ($rms as $rm) {
+ echo "\n\n---> Doc comment for $class::" . $rm->getName() . "():\n";
+ var_dump($rm->getDocComment());
+ }
+}
+?>
+--EXPECTF--
+
+
+---> Doc comment for A::f():
+string(%d) "/**
+ * My Doc Comment for A::f
+ */"
+
+
+---> Doc comment for A::privf():
+string(%d) "/**
+ * My Doc Comment for A::privf
+ */"
+
+
+---> Doc comment for A::protStatf():
+string(%d) "/** My Doc Comment for A::protStatf */"
+
+
+---> Doc comment for A::finalStatPubf():
+string(%d) "/**
+
+ * My Doc Comment for A::finalStatPubf
+ */"
+
+
+---> Doc comment for B::f():
+bool(false)
+
+
+---> Doc comment for B::privf():
+string(%d) "/** *
+ * My Doc Comment for B::privf
+ */"
+
+
+---> Doc comment for B::protStatf():
+string(%d) "/** My Doc Comment for B::protStatf
+
+
+
+
+ */"
+
+
+---> Doc comment for B::finalStatPubf():
+string(%d) "/**
+
+ * My Doc Comment for A::finalStatPubf
+ */" \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt b/ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt
new file mode 100644
index 000000000..041d17ef3
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getDocComment_error.phpt
@@ -0,0 +1,19 @@
+--TEST--
+ReflectionMethod::getDocComment() errors
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class C { function f() {} }
+$rc = new ReflectionMethod('C::f');
+var_dump($rc->getDocComment(null));
+var_dump($rc->getDocComment('X'));
+?>
+--EXPECTF--
+
+Warning: Wrong parameter count for ReflectionFunctionAbstract::getDocComment() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionFunctionAbstract::getDocComment() in %s on line %d
+NULL
+
diff --git a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt
new file mode 100644
index 000000000..74b96f8ee
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt
@@ -0,0 +1,244 @@
+--TEST--
+ReflectionMethod::getModifiers()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function reflectMethodModifiers($class) {
+ $classInfo = new reflectionClass($class);
+ $methodArray = $classInfo->getMethods();
+
+ foreach ($methodArray as $method) {
+ echo "Modifiers for method $method->class::$method->name():\n";
+ var_dump($method->getModifiers());
+ echo "\n\n";
+ }
+}
+
+class TestClass
+{
+ public function foo() {
+ echo "Called foo()\n";
+ }
+
+ static function stat() {
+ echo "Called stat()\n";
+ }
+
+ private function priv() {
+ echo "Called priv()\n";
+ }
+
+ protected function prot() {}
+
+ public final function fin() {}
+
+ public function __destruct() {}
+
+ public function __call($a, $b) {}
+
+ public function __clone() {}
+
+ public function __get($a) {}
+
+ public function __set($a, $b) {}
+
+ public function __unset($a) {}
+
+ public function __isset($a) {}
+
+ public function __tostring() {}
+
+ public function __sleep() {}
+
+ public function __wakeup() {}
+
+ public function __set_state() {}
+
+ public function __autoload() {}
+}
+
+class DerivedClass extends TestClass {}
+
+interface TestInterface {
+ public function int();
+ public function __clone();
+}
+
+abstract class AbstractClass {
+ public abstract function foo();
+}
+
+
+
+reflectMethodModifiers("TestClass");
+reflectMethodModifiers("DerivedClass");
+reflectMethodModifiers("TestInterface");
+reflectMethodModifiers("AbstractClass");
+
+echo "Wrong number of params:\n";
+$a = new ReflectionMethod('TestClass::foo');
+$a->getModifiers(1);
+
+$a = new ReflectionMethod('ReflectionMethod::getModifiers');
+
+echo "\nReflectionMethod::getModifiers() modifiers:\n";
+var_dump($a->getModifiers());
+
+?>
+--EXPECTF--
+Modifiers for method TestClass::foo():
+int(65792)
+
+
+Modifiers for method TestClass::stat():
+int(257)
+
+
+Modifiers for method TestClass::priv():
+int(66560)
+
+
+Modifiers for method TestClass::prot():
+int(66048)
+
+
+Modifiers for method TestClass::fin():
+int(65796)
+
+
+Modifiers for method TestClass::__destruct():
+int(16640)
+
+
+Modifiers for method TestClass::__call():
+int(256)
+
+
+Modifiers for method TestClass::__clone():
+int(33024)
+
+
+Modifiers for method TestClass::__get():
+int(256)
+
+
+Modifiers for method TestClass::__set():
+int(256)
+
+
+Modifiers for method TestClass::__unset():
+int(256)
+
+
+Modifiers for method TestClass::__isset():
+int(256)
+
+
+Modifiers for method TestClass::__tostring():
+int(256)
+
+
+Modifiers for method TestClass::__sleep():
+int(65792)
+
+
+Modifiers for method TestClass::__wakeup():
+int(65792)
+
+
+Modifiers for method TestClass::__set_state():
+int(65792)
+
+
+Modifiers for method TestClass::__autoload():
+int(65792)
+
+
+Modifiers for method DerivedClass::foo():
+int(65792)
+
+
+Modifiers for method DerivedClass::stat():
+int(257)
+
+
+Modifiers for method DerivedClass::priv():
+int(66560)
+
+
+Modifiers for method DerivedClass::prot():
+int(66048)
+
+
+Modifiers for method DerivedClass::fin():
+int(65796)
+
+
+Modifiers for method DerivedClass::__destruct():
+int(16640)
+
+
+Modifiers for method DerivedClass::__call():
+int(256)
+
+
+Modifiers for method DerivedClass::__clone():
+int(33024)
+
+
+Modifiers for method DerivedClass::__get():
+int(256)
+
+
+Modifiers for method DerivedClass::__set():
+int(256)
+
+
+Modifiers for method DerivedClass::__unset():
+int(256)
+
+
+Modifiers for method DerivedClass::__isset():
+int(256)
+
+
+Modifiers for method DerivedClass::__tostring():
+int(256)
+
+
+Modifiers for method DerivedClass::__sleep():
+int(65792)
+
+
+Modifiers for method DerivedClass::__wakeup():
+int(65792)
+
+
+Modifiers for method DerivedClass::__set_state():
+int(65792)
+
+
+Modifiers for method DerivedClass::__autoload():
+int(65792)
+
+
+Modifiers for method TestInterface::int():
+int(258)
+
+
+Modifiers for method TestInterface::__clone():
+int(258)
+
+
+Modifiers for method AbstractClass::foo():
+int(65794)
+
+
+Wrong number of params:
+
+Warning: Wrong parameter count for ReflectionMethod::getModifiers() in %s on line %d
+
+ReflectionMethod::getModifiers() modifiers:
+int(256)
diff --git a/ext/reflection/tests/ReflectionMethod_getStaticVariables_basic.phpt b/ext/reflection/tests/ReflectionMethod_getStaticVariables_basic.phpt
new file mode 100644
index 000000000..1a3d7c8ea
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_getStaticVariables_basic.phpt
@@ -0,0 +1,65 @@
+--TEST--
+ReflectionMethod::getStaticVariables()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+ public function foo() {
+ static $c;
+ static $a = 1;
+ static $b = "hello";
+ $d = 5;
+ }
+
+ private function bar() {
+ static $a = 1;
+ }
+
+ public function noStatics() {
+ $a = 54;
+ }
+}
+
+echo "Public method:\n";
+$methodInfo = new ReflectionMethod('TestClass::foo');
+var_dump($methodInfo->getStaticVariables());
+
+echo "\nPrivate method:\n";
+$methodInfo = new ReflectionMethod('TestClass::bar');
+var_dump($methodInfo->getStaticVariables());
+
+echo "\nMethod with no static variables:\n";
+$methodInfo = new ReflectionMethod('TestClass::noStatics');
+var_dump($methodInfo->getStaticVariables());
+
+echo "\nInternal Method:\n";
+$methodInfo = new ReflectionMethod('ReflectionClass::getName');
+var_dump($methodInfo->getStaticVariables());
+
+?>
+--EXPECT--
+Public method:
+array(3) {
+ ["c"]=>
+ NULL
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ string(5) "hello"
+}
+
+Private method:
+array(1) {
+ ["a"]=>
+ int(1)
+}
+
+Method with no static variables:
+array(0) {
+}
+
+Internal Method:
+array(0) {
+} \ No newline at end of file
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt
new file mode 100644
index 000000000..b6dd1c90f
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_basic.phpt
@@ -0,0 +1,75 @@
+--TEST--
+ReflectionMethod::invokeArgs()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+ public $prop = 2;
+
+ public function foo() {
+ echo "Called foo(), property = $this->prop\n";
+ var_dump($this);
+ return "Return Val";
+ }
+
+ public function willThrow() {
+ throw new Exception("Called willThrow()");
+ }
+
+ public function methodWithArgs($a, $b) {
+ echo "Called methodWithArgs($a, $b)\n";
+ }
+}
+
+
+$testClassInstance = new TestClass();
+$testClassInstance->prop = "Hello";
+
+$foo = new ReflectionMethod($testClassInstance, 'foo');
+$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
+$methodThatThrows = new ReflectionMethod("TestClass::willThrow");
+
+
+echo "Public method:\n";
+
+var_dump($foo->invokeArgs($testClassInstance, array()));
+var_dump($foo->invokeArgs($testClassInstance, array(true)));
+
+echo "\nMethod with args:\n";
+
+var_dump($methodWithArgs->invokeArgs($testClassInstance, array(1, "arg2")));
+var_dump($methodWithArgs->invokeArgs($testClassInstance, array(1, "arg2", 3)));
+
+echo "\nMethod that throws an exception:\n";
+try {
+ $methodThatThrows->invokeArgs($testClassInstance, array());
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+Public method:
+Called foo(), property = Hello
+object(TestClass)#%d (1) {
+ ["prop"]=>
+ string(5) "Hello"
+}
+string(10) "Return Val"
+Called foo(), property = Hello
+object(TestClass)#%d (1) {
+ ["prop"]=>
+ string(5) "Hello"
+}
+string(10) "Return Val"
+
+Method with args:
+Called methodWithArgs(1, arg2)
+NULL
+Called methodWithArgs(1, arg2)
+NULL
+
+Method that throws an exception:
+string(18) "Called willThrow()"
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt
new file mode 100644
index 000000000..19b7fe288
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error1.phpt
@@ -0,0 +1,38 @@
+--TEST--
+ReflectionMethod:invokeArgs() errors
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+
+ public function methodWithArgs($a, $b) {
+ echo "Called methodWithArgs($a, $b)\n";
+ }
+}
+
+abstract class AbstractClass {
+ abstract function foo();
+}
+
+$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
+
+$testClassInstance = new TestClass();
+
+echo "\nMethod with args:\n";
+var_dump($methodWithArgs->invokeArgs($testClassInstance, array()));
+
+?>
+--EXPECTF--
+Method with args:
+
+Warning: Missing argument 1 for TestClass::methodWithArgs() in %s on line %d
+
+Warning: Missing argument 2 for TestClass::methodWithArgs() in %s on line %d
+
+Notice: Undefined variable: a in %s on line %d
+
+Notice: Undefined variable: b in %s on line %d
+Called methodWithArgs(, )
+NULL
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt
new file mode 100644
index 000000000..ebdf9730b
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt
@@ -0,0 +1,29 @@
+--TEST--
+ReflectionMethod::invokeArgs() further errors
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+
+ public function foo() {
+ echo "Called foo()\n";
+ var_dump($this);
+ return "Return Val";
+ }
+}
+
+$foo = new ReflectionMethod('TestClass', 'foo');
+
+$testClassInstance = new TestClass();
+
+try {
+ var_dump($foo->invokeArgs($testClassInstance, true));
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+Catchable fatal error: Argument 2 passed to ReflectionMethod::invokeArgs() must be an array, boolean given in %s on line %d
diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt
new file mode 100644
index 000000000..834f35d66
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt
@@ -0,0 +1,119 @@
+--TEST--
+ReflectionMethod::invokeArgs() further errors
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+ public $prop = 2;
+
+ public function foo() {
+ echo "Called foo(), property = $this->prop\n";
+ var_dump($this);
+ return "Return Val";
+ }
+
+ public static function staticMethod() {
+ echo "Called staticMethod()\n";
+ var_dump($this);
+ }
+
+ private static function privateMethod() {
+ echo "Called privateMethod()\n";
+ }
+}
+
+abstract class AbstractClass {
+ abstract function foo();
+}
+
+$testClassInstance = new TestClass();
+$testClassInstance->prop = "Hello";
+
+$foo = new ReflectionMethod($testClassInstance, 'foo');
+$staticMethod = new ReflectionMethod('TestClass::staticMethod');
+$privateMethod = new ReflectionMethod("TestClass::privateMethod");
+
+echo "Wrong number of parameters:\n";
+var_dump($foo->invokeArgs());
+var_dump($foo->invokeArgs(true));
+
+echo "\nNon-instance:\n";
+try {
+ var_dump($foo->invokeArgs(new stdClass(), array()));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\nNon-object:\n";
+var_dump($foo->invokeArgs(true, array()));
+
+echo "\nStatic method:\n";
+
+var_dump($staticMethod->invokeArgs());
+var_dump($staticMethod->invokeArgs(true));
+var_dump($staticMethod->invokeArgs(true, array()));
+var_dump($staticMethod->invokeArgs(null, array()));
+
+echo "\nPrivate method:\n";
+try {
+ var_dump($privateMethod->invokeArgs($testClassInstance, array()));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\nAbstract method:\n";
+$abstractMethod = new ReflectionMethod("AbstractClass::foo");
+try {
+ $abstractMethod->invokeArgs($testClassInstance, array());
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+try {
+ $abstractMethod->invokeArgs(true);
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+Wrong number of parameters:
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Non-instance:
+string(72) "Given object is not an instance of the class this method was declared in"
+
+Non-object:
+
+Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+
+Static method:
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+Called staticMethod()
+
+Notice: Undefined variable: this in %s on line %d
+NULL
+NULL
+
+Private method:
+string(84) "Trying to invoke private method TestClass::privateMethod from scope ReflectionMethod"
+
+Abstract method:
+string(51) "Trying to invoke abstract method AbstractClass::foo"
+
+Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 1 given in %s on line %d
diff --git a/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt
new file mode 100644
index 000000000..c08b915e8
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt
@@ -0,0 +1,110 @@
+--TEST--
+ReflectionMethod::invoke()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+ public $prop = 2;
+
+ public function foo() {
+ echo "Called foo(), property = $this->prop\n";
+ var_dump($this);
+ return "Return Val";
+ }
+
+ public function willThrow() {
+ throw new Exception("Called willThrow()");
+ }
+
+ public function methodWithArgs($a, $b) {
+ echo "Called methodWithArgs($a, $b)\n";
+ }
+
+ public static function staticMethod() {
+ echo "Called staticMethod()\n";
+ var_dump($this);
+ }
+
+ private static function privateMethod() {
+ echo "Called privateMethod()\n";
+ }
+}
+
+abstract class AbstractClass {
+ abstract function foo();
+}
+
+$foo = new ReflectionMethod('TestClass', 'foo');
+$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
+$staticMethod = new ReflectionMethod('TestClass::staticMethod');
+$privateMethod = new ReflectionMethod("TestClass::privateMethod");
+$methodThatThrows = new ReflectionMethod("TestClass::willThrow");
+
+$testClassInstance = new TestClass();
+$testClassInstance->prop = "Hello";
+
+echo "Public method:\n";
+
+var_dump($foo->invoke($testClassInstance));
+
+var_dump($foo->invoke($testClassInstance, true));
+
+echo "\nMethod with args:\n";
+
+var_dump($methodWithArgs->invoke($testClassInstance, 1, "arg2"));
+var_dump($methodWithArgs->invoke($testClassInstance, 1, "arg2", 3));
+
+echo "\nStatic method:\n";
+
+var_dump($staticMethod->invoke());
+var_dump($staticMethod->invoke(true));
+var_dump($staticMethod->invoke(new stdClass()));
+
+echo "\nMethod that throws an exception:\n";
+try {
+ var_dump($methodThatThrows->invoke($testClassInstance));
+} catch (Exception $exc) {
+ var_dump($exc->getMessage());
+}
+
+?>
+--EXPECTF--
+Public method:
+Called foo(), property = Hello
+object(TestClass)#%d (1) {
+ ["prop"]=>
+ string(5) "Hello"
+}
+string(10) "Return Val"
+Called foo(), property = Hello
+object(TestClass)#%d (1) {
+ ["prop"]=>
+ string(5) "Hello"
+}
+string(10) "Return Val"
+
+Method with args:
+Called methodWithArgs(1, arg2)
+NULL
+Called methodWithArgs(1, arg2)
+NULL
+
+Static method:
+
+Warning: Invoke() expects at least one parameter, none given in %s on line %d
+bool(false)
+Called staticMethod()
+
+Notice: Undefined variable: this in %s on line %d
+NULL
+NULL
+Called staticMethod()
+
+Notice: Undefined variable: this in %s on line %d
+NULL
+NULL
+
+Method that throws an exception:
+string(18) "Called willThrow()"
diff --git a/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt b/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt
new file mode 100644
index 000000000..2846a13c6
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invoke_error1.phpt
@@ -0,0 +1,73 @@
+--TEST--
+ReflectionMethod::invoke() errors
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+ public $prop = 2;
+
+ public function foo() {
+ echo "Called foo(), property = $this->prop\n";
+ var_dump($this);
+ return "Return Val";
+ }
+
+ private static function privateMethod() {
+ echo "Called privateMethod()\n";
+ }
+}
+
+abstract class AbstractClass {
+ abstract function foo();
+}
+
+$foo = new ReflectionMethod('TestClass', 'foo');
+$privateMethod = new ReflectionMethod("TestClass::privateMethod");
+
+$testClassInstance = new TestClass();
+$testClassInstance->prop = "Hello";
+
+echo "invoke() on a non-object:\n";
+try {
+ var_dump($foo->invoke(true));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\ninvoke() on a non-instance:\n";
+try {
+ var_dump($foo->invoke(new stdClass()));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\nPrivate method:\n";
+try {
+ var_dump($privateMethod->invoke($testClassInstance));
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+echo "\nAbstract method:\n";
+$abstractMethod = new ReflectionMethod("AbstractClass::foo");
+try {
+ $abstractMethod->invoke(true);
+} catch (ReflectionException $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+invoke() on a non-object:
+string(29) "Non-object passed to Invoke()"
+
+invoke() on a non-instance:
+string(72) "Given object is not an instance of the class this method was declared in"
+
+Private method:
+string(86) "Trying to invoke private method TestClass::privateMethod() from scope ReflectionMethod"
+
+Abstract method:
+string(53) "Trying to invoke abstract method AbstractClass::foo()"
diff --git a/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt b/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt
new file mode 100644
index 000000000..cb3b1c2d2
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_invoke_error2.phpt
@@ -0,0 +1,34 @@
+--TEST--
+ReflectionMethod::invoke() further errors
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+
+ public function methodWithArgs($a, $b) {
+ echo "Called methodWithArgs($a, $b)\n";
+ }
+}
+
+$methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
+
+$testClassInstance = new TestClass();
+
+echo "\nMethod with args:\n";
+var_dump($methodWithArgs->invoke($testClassInstance));
+
+?>
+--EXPECTF--
+Method with args:
+
+Warning: Missing argument 1 for TestClass::methodWithArgs() in %s on line %d
+
+Warning: Missing argument 2 for TestClass::methodWithArgs() in %s on line %d
+
+Notice: Undefined variable: a in %s on line %d
+
+Notice: Undefined variable: b in %s on line %d
+Called methodWithArgs(, )
+NULL
diff --git a/ext/reflection/tests/ReflectionMethod_returnsReference_basic.phpt b/ext/reflection/tests/ReflectionMethod_returnsReference_basic.phpt
new file mode 100644
index 000000000..b3a1f8c00
--- /dev/null
+++ b/ext/reflection/tests/ReflectionMethod_returnsReference_basic.phpt
@@ -0,0 +1,25 @@
+--TEST--
+ReflectionMethod::returnsReference()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+ public function &foo() {
+ }
+
+ private function bar() {
+ }
+}
+
+$methodInfo = new ReflectionMethod('TestClass::foo');
+var_dump($methodInfo->returnsReference());
+
+$methodInfo = new ReflectionMethod('TestClass::bar');
+var_dump($methodInfo->returnsReference());
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
diff --git a/ext/reflection/tests/reflectionProperty_basic1.phpt b/ext/reflection/tests/reflectionProperty_basic1.phpt
new file mode 100644
index 000000000..f7c1c8f10
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_basic1.phpt
@@ -0,0 +1,162 @@
+--TEST--
+Test usage of ReflectionProperty methods __toString(), export(), getName(), isPublic(), isPrivate(), isProtected(), isStatic(), getValue() and setValue().
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function reflectProperty($class, $property) {
+ $propInfo = new ReflectionProperty($class, $property);
+ echo "**********************************\n";
+ echo "Reflecting on property $class::$property\n\n";
+ echo "__toString():\n";
+ var_dump($propInfo->__toString());
+ echo "export():\n";
+ var_dump(ReflectionProperty::export($class, $property, true));
+ echo "export():\n";
+ var_dump(ReflectionProperty::export($class, $property, false));
+ echo "getName():\n";
+ var_dump($propInfo->getName());
+ echo "isPublic():\n";
+ var_dump($propInfo->isPublic());
+ echo "isPrivate():\n";
+ var_dump($propInfo->isPrivate());
+ echo "isProtected():\n";
+ var_dump($propInfo->isProtected());
+ echo "isStatic():\n";
+ var_dump($propInfo->isStatic());
+ $instance = new $class();
+ if ($propInfo->isPublic()) {
+ echo "getValue():\n";
+ var_dump($propInfo->getValue($instance));
+ $propInfo->setValue($instance, "NewValue");
+ echo "getValue() after a setValue():\n";
+ var_dump($propInfo->getValue($instance));
+ }
+ echo "\n**********************************\n";
+}
+
+class TestClass {
+ public $pub;
+ static public $stat = "static property";
+ protected $prot = 4;
+ private $priv = "keepOut";
+}
+
+reflectProperty("TestClass", "pub");
+reflectProperty("TestClass", "stat");
+reflectProperty("TestClass", "prot");
+reflectProperty("TestClass", "priv");
+
+?>
+--EXPECT--
+**********************************
+Reflecting on property TestClass::pub
+
+__toString():
+string(35) "Property [ <default> public $pub ]
+"
+export():
+string(35) "Property [ <default> public $pub ]
+"
+export():
+Property [ <default> public $pub ]
+
+NULL
+getName():
+string(3) "pub"
+isPublic():
+bool(true)
+isPrivate():
+bool(false)
+isProtected():
+bool(false)
+isStatic():
+bool(false)
+getValue():
+NULL
+getValue() after a setValue():
+string(8) "NewValue"
+
+**********************************
+**********************************
+Reflecting on property TestClass::stat
+
+__toString():
+string(33) "Property [ public static $stat ]
+"
+export():
+string(33) "Property [ public static $stat ]
+"
+export():
+Property [ public static $stat ]
+
+NULL
+getName():
+string(4) "stat"
+isPublic():
+bool(true)
+isPrivate():
+bool(false)
+isProtected():
+bool(false)
+isStatic():
+bool(true)
+getValue():
+string(15) "static property"
+getValue() after a setValue():
+string(8) "NewValue"
+
+**********************************
+**********************************
+Reflecting on property TestClass::prot
+
+__toString():
+string(39) "Property [ <default> protected $prot ]
+"
+export():
+string(39) "Property [ <default> protected $prot ]
+"
+export():
+Property [ <default> protected $prot ]
+
+NULL
+getName():
+string(4) "prot"
+isPublic():
+bool(false)
+isPrivate():
+bool(false)
+isProtected():
+bool(true)
+isStatic():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on property TestClass::priv
+
+__toString():
+string(37) "Property [ <default> private $priv ]
+"
+export():
+string(37) "Property [ <default> private $priv ]
+"
+export():
+Property [ <default> private $priv ]
+
+NULL
+getName():
+string(4) "priv"
+isPublic():
+bool(false)
+isPrivate():
+bool(true)
+isProtected():
+bool(false)
+isStatic():
+bool(false)
+
+**********************************
+
+
diff --git a/ext/reflection/tests/reflectionProperty_basic2.phpt b/ext/reflection/tests/reflectionProperty_basic2.phpt
new file mode 100644
index 000000000..f2b5ff4fb
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_basic2.phpt
@@ -0,0 +1,105 @@
+--TEST--
+Test usage of ReflectionProperty methods isDefault(), getModifiers(), getDeclaringClass() and getDocComment().
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function reflectProperty($class, $property) {
+ $propInfo = new ReflectionProperty($class, $property);
+ echo "**********************************\n";
+ echo "Reflecting on property $class::$property\n\n";
+ echo "isDefault():\n";
+ var_dump($propInfo->isDefault());
+ echo "getModifiers():\n";
+ var_dump($propInfo->getModifiers());
+ echo "getDeclaringClass():\n";
+ var_dump($propInfo->getDeclaringClass());
+ echo "getDocComment():\n";
+ var_dump($propInfo->getDocComment());
+ echo "\n**********************************\n";
+}
+
+class TestClass {
+ public $pub;
+ static public $stat = "static property";
+ /**
+ * This property has a comment.
+ */
+ protected $prot = 4;
+ private $priv = "keepOut";
+}
+
+reflectProperty("TestClass", "pub");
+reflectProperty("TestClass", "stat");
+reflectProperty("TestClass", "prot");
+reflectProperty("TestClass", "priv");
+
+?>
+--EXPECTF--
+**********************************
+Reflecting on property TestClass::pub
+
+isDefault():
+bool(true)
+getModifiers():
+int(256)
+getDeclaringClass():
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(9) "TestClass"
+}
+getDocComment():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on property TestClass::stat
+
+isDefault():
+bool(true)
+getModifiers():
+int(257)
+getDeclaringClass():
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(9) "TestClass"
+}
+getDocComment():
+bool(false)
+
+**********************************
+**********************************
+Reflecting on property TestClass::prot
+
+isDefault():
+bool(true)
+getModifiers():
+int(512)
+getDeclaringClass():
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(9) "TestClass"
+}
+getDocComment():
+string(%d) "/**
+ * This property has a comment.
+ */"
+
+**********************************
+**********************************
+Reflecting on property TestClass::priv
+
+isDefault():
+bool(true)
+getModifiers():
+int(1024)
+getDeclaringClass():
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(9) "TestClass"
+}
+getDocComment():
+bool(false)
+
+**********************************
diff --git a/ext/reflection/tests/reflectionProperty_constructor_error.phpt b/ext/reflection/tests/reflectionProperty_constructor_error.phpt
new file mode 100644
index 000000000..46cdc87ea
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_constructor_error.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Test ReflectionProperty class constructor errors.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+}
+
+$a = 5;
+
+echo "Non-existent class:\n";
+try {
+ $propInfo = new ReflectionProperty("NonExistentClass", "prop");
+}
+catch(Exception $e) {
+ echo $e->getMessage();
+}
+
+echo "\n\nWrong property parameter type:\n";
+try {
+ $propInfo = new ReflectionProperty($a, 'TestClass');
+}
+catch(ReflectionException $e) {
+ echo $e->getMessage();
+}
+
+echo "\n\nNon-existent property:\n";
+try {
+ $propInfo = new ReflectionProperty('TestClass', "nonExistentProperty");
+}
+catch(Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECT--
+Non-existent class:
+Class NonExistentClass does not exist
+
+Wrong property parameter type:
+The parameter class is expected to be either a string or an object
+
+Non-existent property:
+Property TestClass::$nonExistentProperty does not exist
diff --git a/ext/reflection/tests/reflectionProperty_error.phpt b/ext/reflection/tests/reflectionProperty_error.phpt
new file mode 100644
index 000000000..bae255c23
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_error.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Test ReflectionProperty class errors.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class C {
+ public static $p;
+}
+
+var_dump(new ReflectionProperty());
+var_dump(new ReflectionProperty('C::p'));
+var_dump(new ReflectionProperty('C', 'p', 'x'));
+$rp = new ReflectionProperty('C', 'p');
+var_dump($rp->getName(1));
+var_dump($rp->isPrivate(1));
+var_dump($rp->isProtected(1));
+var_dump($rp->isPublic(1));
+var_dump($rp->isStatic(1));
+var_dump($rp->getModifiers(1));
+var_dump($rp->isDefault(1));
+
+?>
+--EXPECTF--
+
+Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 0 given in %s on line %d
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(0) ""
+ ["class"]=>
+ string(0) ""
+}
+
+Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 1 given in %s on line %d
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(0) ""
+ ["class"]=>
+ string(0) ""
+}
+
+Warning: ReflectionProperty::__construct() expects exactly 2 parameters, 3 given in %s on line %d
+object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(0) ""
+ ["class"]=>
+ string(0) ""
+}
+
+Warning: Wrong parameter count for ReflectionProperty::getName() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionProperty::isPrivate() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionProperty::isProtected() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionProperty::isPublic() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionProperty::isStatic() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionProperty::getModifiers() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionProperty::isDefault() in %s on line %d
+NULL
diff --git a/ext/reflection/tests/reflectionProperty_export_basic.phpt b/ext/reflection/tests/reflectionProperty_export_basic.phpt
new file mode 100644
index 000000000..331fdb6a2
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_export_basic.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test ReflectionProperty::export() usage.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+ public $proper = 5;
+}
+
+var_dump(ReflectionProperty::export('TestClass', 'proper'));
+
+?>
+--EXPECT--
+Property [ <default> public $proper ]
+
+NULL
diff --git a/ext/reflection/tests/reflectionProperty_export_error.phpt b/ext/reflection/tests/reflectionProperty_export_error.phpt
new file mode 100644
index 000000000..9351846f6
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_export_error.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test ReflectionProperty::export() errors.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+}
+
+$a = 5;
+
+echo "Non-existent class:\n";
+try {
+ ReflectionProperty::export("NonExistentClass", "prop", true);
+}
+catch(Exception $e) {
+ echo $e->getMessage();
+}
+
+echo "\n\nWrong property parameter type:\n";
+try {
+ ReflectionProperty::export($a, 'TestClass', false);
+}
+catch(ReflectionException $e) {
+ echo $e->getMessage();
+}
+
+echo "\n\nNon-existent property:\n";
+try {
+ ReflectionProperty::export('TestClass', "nonExistentProperty", true);
+}
+catch(Exception $e) {
+ echo $e->getMessage();
+}
+
+echo "\n\nIncorrect number of args:\n";
+ReflectionProperty::export();
+ReflectionProperty::export('TestClass', "nonExistentProperty", true, false);
+
+?>
+--EXPECTF--
+Non-existent class:
+Class NonExistentClass does not exist
+
+Wrong property parameter type:
+The parameter class is expected to be either a string or an object
+
+Non-existent property:
+Property TestClass::$nonExistentProperty does not exist
+
+Incorrect number of args:
+
+Warning: ReflectionProperty::export() expects at least 2 parameters, 0 given in %s on line %d
+
+Warning: ReflectionProperty::export() expects at most 3 parameters, 4 given in %s on line %d
diff --git a/ext/reflection/tests/reflectionProperty_getDeclaringClass_variation1.phpt b/ext/reflection/tests/reflectionProperty_getDeclaringClass_variation1.phpt
new file mode 100644
index 000000000..3df3b2605
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_getDeclaringClass_variation1.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test ReflectionProperty::getDeclaringClass() with inherited properties.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class A {
+ public $prop;
+}
+
+class B extends A {
+}
+
+$propInfo = new ReflectionProperty('B', 'prop');
+var_dump($propInfo->getDeclaringClass());
+
+echo "Wrong number of params:\n";
+$propInfo->getDeclaringClass(1);
+
+?>
+--EXPECTF--
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(1) "A"
+}
+Wrong number of params:
+
+Warning: Wrong parameter count for ReflectionProperty::getDeclaringClass() in %s on line %d
diff --git a/ext/reflection/tests/reflectionProperty_getDocComment_basic.phpt b/ext/reflection/tests/reflectionProperty_getDocComment_basic.phpt
new file mode 100644
index 000000000..44416b7fc
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_getDocComment_basic.phpt
@@ -0,0 +1,102 @@
+--TEST--
+Test ReflectionProperty::getDocComment() usage.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class A {
+ /**
+ * My Doc Comment for $a
+ *
+ */
+ public $a = 2, $b, $c = 1;
+ /**
+ * My Doc Comment for $d
+ */
+ var $d;
+ /**Not a doc comment */
+ private $e;
+ /**
+ * Doc comment for $f
+ */
+ static protected $f;
+}
+
+class B extends A {
+ public $a = 2;
+ /** A doc comment for $b */
+ var $b, $c = 1;
+ /** A doc comment for $e */
+ var $e;
+}
+
+foreach(array('A', 'B') as $class) {
+ $rc = new ReflectionClass($class);
+ $rps = $rc->getProperties();
+ foreach($rps as $rp) {
+ echo "\n\n---> Doc comment for $class::$" . $rp->getName() . ":\n";
+ var_dump($rp->getDocComment());
+ }
+}
+
+?>
+--EXPECTF--
+
+---> Doc comment for A::$a:
+string(%d) "/**
+ * My Doc Comment for $a
+ *
+ */"
+
+
+---> Doc comment for A::$b:
+bool(false)
+
+
+---> Doc comment for A::$c:
+bool(false)
+
+
+---> Doc comment for A::$d:
+string(%d) "/**
+ * My Doc Comment for $d
+ */"
+
+
+---> Doc comment for A::$e:
+bool(false)
+
+
+---> Doc comment for A::$f:
+string(%d) "/**
+ * Doc comment for $f
+ */"
+
+
+---> Doc comment for B::$a:
+bool(false)
+
+
+---> Doc comment for B::$b:
+string(%d) "/** A doc comment for $b */"
+
+
+---> Doc comment for B::$c:
+bool(false)
+
+
+---> Doc comment for B::$e:
+string(%d) "/** A doc comment for $e */"
+
+
+---> Doc comment for B::$d:
+string(%d) "/**
+ * My Doc Comment for $d
+ */"
+
+
+---> Doc comment for B::$f:
+string(%d) "/**
+ * Doc comment for $f
+ */"
diff --git a/ext/reflection/tests/reflectionProperty_getDocComment_error.phpt b/ext/reflection/tests/reflectionProperty_getDocComment_error.phpt
new file mode 100644
index 000000000..8c1b68e81
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_getDocComment_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test ReflectionProperty::getDocComment() errors.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class C {
+ public $a;
+}
+
+$rc = new ReflectionProperty('C', 'a');
+var_dump($rc->getDocComment(null));
+var_dump($rc->getDocComment('X'));
+var_dump($rc->getDocComment(true));
+var_dump($rc->getDocComment(array(1, 2, 3)));
+
+?>
+--EXPECTF--
+
+Warning: Wrong parameter count for ReflectionProperty::getDocComment() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionProperty::getDocComment() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionProperty::getDocComment() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for ReflectionProperty::getDocComment() in %s on line %d
+NULL
diff --git a/ext/reflection/tests/reflectionProperty_getModifiers_basic.phpt b/ext/reflection/tests/reflectionProperty_getModifiers_basic.phpt
new file mode 100644
index 000000000..907a7e7be
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_getModifiers_basic.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test ReflectionProperty::getModifiers() usage.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class C {
+ public $a1;
+ protected $a2;
+ private $a3;
+ static public $a4;
+ static protected $a5;
+ static private $a6;
+}
+
+class D extends C {
+ public $a1;
+ protected $a2;
+ private $a3;
+ static public $a4;
+ static protected $a5;
+ static private $a6;
+}
+
+for ($i = 1;$i <= 6;$i++) {
+ $rp = new ReflectionProperty("C", "a$i");
+ echo "C::a$i: ";
+ var_dump($rp->getModifiers());
+ $rp = new ReflectionProperty("D", "a$i");
+ echo "D::a$i: ";
+ var_dump($rp->getModifiers());
+}
+
+?>
+--EXPECTF--
+C::a1: int(256)
+D::a1: int(256)
+C::a2: int(512)
+D::a2: int(512)
+C::a3: int(1024)
+D::a3: int(3072)
+C::a4: int(257)
+D::a4: int(257)
+C::a5: int(513)
+D::a5: int(513)
+C::a6: int(1025)
+D::a6: int(3073) \ No newline at end of file
diff --git a/ext/reflection/tests/reflectionProperty_getValue_error.phpt b/ext/reflection/tests/reflectionProperty_getValue_error.phpt
new file mode 100644
index 000000000..acfc3b0a0
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_getValue_error.phpt
@@ -0,0 +1,83 @@
+--TEST--
+Test ReflectionProperty::getValue() errors.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+ public $pub;
+ public $pub2 = 5;
+ static public $stat = "static property";
+ protected $prot = 4;
+ private $priv = "keepOut";
+}
+
+class AnotherClass {
+}
+
+$instance = new TestClass();
+$instanceWithNoProperties = new AnotherClass();
+$propInfo = new ReflectionProperty('TestClass', 'pub2');
+
+echo "Too few args:\n";
+var_dump($propInfo->getValue());
+
+echo "\nToo many args:\n";
+var_dump($propInfo->getValue($instance, true));
+
+echo "\nWrong type of arg:\n";
+var_dump($propInfo->getValue(true));
+
+echo "\nInstance without property:\n";
+$propInfo = new ReflectionProperty('TestClass', 'stat');
+
+echo "\nStatic property / too many args:\n";
+var_dump($propInfo->getValue($instance, true));
+
+echo "\nStatic property / wrong type of arg:\n";
+var_dump($propInfo->getValue(true));
+
+echo "\nProtected property:\n";
+try {
+ $propInfo = new ReflectionProperty('TestClass', 'prot');
+ var_dump($propInfo->getValue($instance));
+}
+catch(Exception $exc) {
+ echo $exc->getMessage();
+}
+
+echo "\n\nInstance without property:\n";
+$propInfo = new ReflectionProperty('TestClass', 'pub2');
+var_dump($propInfo->getValue($instanceWithNoProperties));
+
+?>
+--EXPECTF--
+Too few args:
+
+Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Too many args:
+
+Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Wrong type of arg:
+
+Warning: ReflectionProperty::getValue() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+
+Instance without property:
+
+Static property / too many args:
+string(15) "static property"
+
+Static property / wrong type of arg:
+string(15) "static property"
+
+Protected property:
+Cannot access non-public member TestClass::prot
+
+Instance without property:
+NULL
diff --git a/ext/reflection/tests/reflectionProperty_isDefault_basic.phpt b/ext/reflection/tests/reflectionProperty_isDefault_basic.phpt
new file mode 100644
index 000000000..57c3d0f3c
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_isDefault_basic.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test ReflectionProperty::isDefault() usage.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function reflectProperty($class, $property) {
+ $propInfo = new ReflectionProperty($class, $property);
+ echo "**********************************\n";
+ echo "Reflecting on property $class::$property\n\n";
+ echo "isDefault():\n";
+ var_dump($propInfo->isDefault());
+ echo "\n**********************************\n";
+}
+
+class TestClass {
+ public $pub;
+ static public $stat = "static property";
+ protected $prot = 4;
+ private $priv = "keepOut";
+}
+
+reflectProperty("TestClass", "pub");
+reflectProperty("TestClass", "stat");
+reflectProperty("TestClass", "prot");
+reflectProperty("TestClass", "priv");
+
+echo "Wrong number of params:\n";
+$propInfo = new ReflectionProperty('TestClass', 'pub');
+$propInfo->isDefault(1);
+
+?>
+--EXPECTF--
+**********************************
+Reflecting on property TestClass::pub
+
+isDefault():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on property TestClass::stat
+
+isDefault():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on property TestClass::prot
+
+isDefault():
+bool(true)
+
+**********************************
+**********************************
+Reflecting on property TestClass::priv
+
+isDefault():
+bool(true)
+
+**********************************
+Wrong number of params:
+
+Warning: Wrong parameter count for ReflectionProperty::isDefault() in %s on line %d
diff --git a/ext/reflection/tests/reflectionProperty_setValue_error.phpt b/ext/reflection/tests/reflectionProperty_setValue_error.phpt
new file mode 100644
index 000000000..960778235
--- /dev/null
+++ b/ext/reflection/tests/reflectionProperty_setValue_error.phpt
@@ -0,0 +1,102 @@
+--TEST--
+Test ReflectionProperty::setValue() error cases.
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+class TestClass {
+ public $pub;
+ public $pub2 = 5;
+ static public $stat = "static property";
+ protected $prot = 4;
+ private $priv = "keepOut";
+}
+
+class AnotherClass {
+}
+
+$instance = new TestClass();
+$instanceWithNoProperties = new AnotherClass();
+$propInfo = new ReflectionProperty('TestClass', 'pub2');
+
+echo "Too few args:\n";
+var_dump($propInfo->setValue());
+var_dump($propInfo->setValue($instance));
+
+echo "\nToo many args:\n";
+var_dump($propInfo->setValue($instance, "NewValue", true));
+
+echo "\nWrong type of arg:\n";
+var_dump($propInfo->setValue(true, "NewValue"));
+$propInfo = new ReflectionProperty('TestClass', 'stat');
+
+echo "\nStatic property / too many args:\n";
+var_dump($propInfo->setValue($instance, "NewValue", true));
+
+echo "\nStatic property / too few args:\n";
+var_dump($propInfo->setValue("A new value"));
+var_dump(TestClass::$stat);
+var_dump($propInfo->setValue());
+var_dump(TestClass::$stat);
+
+echo "\nStatic property / wrong type of arg:\n";
+var_dump($propInfo->setValue(true, "Another new value"));
+var_dump(TestClass::$stat);
+
+echo "\nProtected property:\n";
+try {
+ $propInfo = new ReflectionProperty('TestClass', 'prot');
+ var_dump($propInfo->setValue($instance, "NewValue"));
+}
+catch(Exception $exc) {
+ echo $exc->getMessage();
+}
+
+echo "\n\nInstance without property:\n";
+$propInfo = new ReflectionProperty('TestClass', 'pub2');
+var_dump($propInfo->setValue($instanceWithNoProperties, "NewValue"));
+var_dump($instanceWithNoProperties->pub2);
+?>
+--EXPECTF--
+Too few args:
+
+Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Too many args:
+
+Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+Wrong type of arg:
+
+Warning: ReflectionProperty::setValue() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+
+Static property / too many args:
+
+Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+Static property / too few args:
+NULL
+string(11) "A new value"
+
+Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+string(11) "A new value"
+
+Static property / wrong type of arg:
+NULL
+string(17) "Another new value"
+
+Protected property:
+Cannot access non-public member TestClass::prot
+
+Instance without property:
+NULL
+string(8) "NewValue"