summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c144
-rw-r--r--ext/reflection/php_reflection.h4
-rwxr-xr-xext/reflection/tests/008.phpt2
-rwxr-xr-xext/reflection/tests/009.phpt114
-rw-r--r--ext/reflection/tests/bug29986.phpt2
-rwxr-xr-xext/reflection/tests/bug37816.phpt2
-rw-r--r--ext/reflection/tests/bug38217.phpt4
-rw-r--r--ext/reflection/tests/bug38653.phpt2
-rwxr-xr-xext/reflection/tests/bug38942.phpt2
-rw-r--r--ext/reflection/tests/bug39001.phpt2
-rw-r--r--ext/reflection/tests/bug39067.phpt2
-rw-r--r--ext/reflection/tests/bug39884.phpt24
-rw-r--r--ext/reflection/tests/bug40431.phpt140
-rw-r--r--ext/reflection/tests/bug40794.phpt38
-rwxr-xr-xext/reflection/tests/bug41061.phpt30
15 files changed, 458 insertions, 54 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 0685541ad..ac0c325c7 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 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.31 2006/10/18 16:35:15 johannes Exp $ */
+/* $Id: php_reflection.c,v 1.164.2.33.2.37 2007/04/12 18:39:46 johannes Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -179,7 +179,7 @@ static void string_free(string *str)
/* Struct for properties */
typedef struct _property_reference {
zend_class_entry *ce;
- zend_property_info *prop;
+ zend_property_info prop;
} property_reference;
/* Struct for parameters */
@@ -271,7 +271,7 @@ static zend_object_value reflection_objects_new(zend_class_entry *class_type TSR
return retval;
}
-static zval * reflection_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)
+static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
{
if (!object) {
ALLOC_ZVAL(object);
@@ -747,23 +747,27 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry
string_printf(str, "static ");
}
- /* These are mutually exclusive */
- switch (fptr->common.fn_flags & ZEND_ACC_PPP_MASK) {
- case ZEND_ACC_PUBLIC:
- string_printf(str, "public ");
- break;
- case ZEND_ACC_PRIVATE:
- string_printf(str, "private ");
- break;
- case ZEND_ACC_PROTECTED:
- string_printf(str, "protected ");
- break;
- default:
- string_printf(str, "<visibility error> ");
- break;
+ if (fptr->common.scope) {
+ /* These are mutually exclusive */
+ switch (fptr->common.fn_flags & ZEND_ACC_PPP_MASK) {
+ case ZEND_ACC_PUBLIC:
+ string_printf(str, "public ");
+ break;
+ case ZEND_ACC_PRIVATE:
+ string_printf(str, "private ");
+ break;
+ case ZEND_ACC_PROTECTED:
+ string_printf(str, "protected ");
+ break;
+ default:
+ string_printf(str, "<visibility error> ");
+ break;
+ }
+ string_printf(str, "method ");
+ } else {
+ string_printf(str, "function ");
}
- string_printf(str, fptr->common.scope ? "method " : "function ");
if (fptr->op_array.return_reference) {
string_printf(str, "&");
}
@@ -1026,7 +1030,7 @@ PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSR
MAKE_STD_ZVAL(name);
ZVAL_STRINGL(name, ce->name, ce->name_length, 1);
- reflection_instanciate(reflection_class_ptr, object TSRMLS_CC);
+ reflection_instantiate(reflection_class_ptr, object TSRMLS_CC);
intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
intern->ptr = ce;
intern->free_ptr = 0;
@@ -1052,7 +1056,7 @@ static void reflection_extension_factory(zval *object, char *name_str TSRMLS_DC)
}
free_alloca(lcname);
- reflection_instanciate(reflection_extension_ptr, object TSRMLS_CC);
+ reflection_instantiate(reflection_extension_ptr, object TSRMLS_CC);
intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
MAKE_STD_ZVAL(name);
ZVAL_STRINGL(name, module->name, name_len, 1);
@@ -1076,7 +1080,7 @@ static void reflection_parameter_factory(zend_function *fptr, struct _zend_arg_i
} else {
ZVAL_NULL(name);
}
- reflection_instanciate(reflection_parameter_ptr, object TSRMLS_CC);
+ reflection_instantiate(reflection_parameter_ptr, object TSRMLS_CC);
intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
reference = (parameter_reference*) emalloc(sizeof(parameter_reference));
reference->arg_info = arg_info;
@@ -1099,7 +1103,7 @@ static void reflection_function_factory(zend_function *function, zval *object TS
MAKE_STD_ZVAL(name);
ZVAL_STRING(name, function->common.function_name, 1);
- reflection_instanciate(reflection_function_ptr, object TSRMLS_CC);
+ reflection_instantiate(reflection_function_ptr, object TSRMLS_CC);
intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
intern->ptr = function;
intern->free_ptr = 0;
@@ -1119,7 +1123,7 @@ static void reflection_method_factory(zend_class_entry *ce, zend_function *metho
MAKE_STD_ZVAL(classname);
ZVAL_STRING(name, method->common.function_name, 1);
ZVAL_STRINGL(classname, ce->name, ce->name_length, 1);
- reflection_instanciate(reflection_method_ptr, object TSRMLS_CC);
+ reflection_instantiate(reflection_method_ptr, object TSRMLS_CC);
intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
intern->ptr = method;
intern->free_ptr = 0;
@@ -1142,14 +1146,19 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
if (!(prop->flags & ZEND_ACC_PRIVATE)) {
/* we have to search the class hierarchy for this (implicit) public or protected property */
- zend_class_entry *tmp_ce = ce;
- zend_property_info *tmp_info;
-
+ zend_class_entry *tmp_ce = ce, *store_ce = ce;
+ zend_property_info *tmp_info = NULL;
+
while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) != SUCCESS) {
ce = tmp_ce;
- prop = tmp_info;
tmp_ce = tmp_ce->parent;
}
+
+ if (tmp_info && !(tmp_info->flags & ZEND_ACC_SHADOW)) { /* found something and it's not a parent's private */
+ prop = tmp_info;
+ } else { /* not found, use initial value */
+ ce = store_ce;
+ }
}
MAKE_STD_ZVAL(name);
@@ -1157,11 +1166,11 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
ZVAL_STRING(name, prop_name, 1);
ZVAL_STRINGL(classname, ce->name, ce->name_length, 1);
- reflection_instanciate(reflection_property_ptr, object TSRMLS_CC);
+ reflection_instantiate(reflection_property_ptr, object TSRMLS_CC);
intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
reference = (property_reference*) emalloc(sizeof(property_reference));
reference->ce = ce;
- reference->prop = prop;
+ reference->prop = *prop;
intern->ptr = reference;
intern->free_ptr = 1;
intern->ce = ce;
@@ -1995,7 +2004,40 @@ ZEND_METHOD(reflection_parameter, getClass)
GET_REFLECTION_OBJECT_PTR(param);
if (param->arg_info->class_name) {
- if (zend_lookup_class(param->arg_info->class_name, param->arg_info->class_name_len, &pce TSRMLS_CC) == FAILURE) {
+ /* Class name is stored as a string, we might also get "self" or "parent"
+ * - For "self", simply use the function scope. If scope is NULL then
+ * the function is global and thus self does not make any sense
+ *
+ * - For "parent", use the function scope's parent. If scope is NULL then
+ * the function is global and thus parent does not make any sense.
+ * If the parent is NULL then the class does not extend anything and
+ * thus parent does not make any sense, either.
+ *
+ * TODO: Think about moving these checks to the compiler or some sort of
+ * lint-mode.
+ */
+ if (0 == strncmp(param->arg_info->class_name, "self", sizeof("self")- 1)) {
+ zend_class_entry *ce= param->fptr->common.scope;
+ if (!ce) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
+ "Parameter uses 'self' as type hint but function is not a class member!");
+ return;
+ }
+ pce= &ce;
+ } else if (0 == strncmp(param->arg_info->class_name, "parent", sizeof("parent")- 1)) {
+ zend_class_entry *ce= param->fptr->common.scope;
+ if (!ce) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
+ "Parameter uses 'parent' as type hint but function is not a class member!");
+ return;
+ }
+ if (!ce->parent) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
+ "Parameter uses 'parent' as type hint although class does not have a parent!");
+ return;
+ }
+ pce= &ce->parent;
+ } else if (zend_lookup_class(param->arg_info->class_name, param->arg_info->class_name_len, &pce TSRMLS_CC) == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Class %s does not exist", param->arg_info->class_name);
return;
@@ -3165,7 +3207,7 @@ static int _adddynproperty(zval **pptr, int num_args, va_list args, zend_hash_ke
ZVAL_STRINGL(&member, hash_key->arKey, hash_key->nKeyLength-1, 0);
if (zend_get_property_info(ce, &member, 1 TSRMLS_CC) == &EG(std_property_info)) {
- ALLOC_ZVAL(property);
+ MAKE_STD_ZVAL(property);
reflection_property_factory(ce, &EG(std_property_info), property TSRMLS_CC);
add_next_index_zval(retval, property);
}
@@ -3804,7 +3846,7 @@ ZEND_METHOD(reflection_property, __construct)
reference = (property_reference*) emalloc(sizeof(property_reference));
reference->ce = ce;
- reference->prop = property_info;
+ reference->prop = *property_info;
intern->ptr = reference;
intern->free_ptr = 1;
intern->ce = ce;
@@ -3822,7 +3864,7 @@ ZEND_METHOD(reflection_property, __toString)
METHOD_NOTSTATIC_NUMPARAMS(reflection_property_ptr, 0);
GET_REFLECTION_OBJECT_PTR(ref);
string_init(&str);
- _property_string(&str, ref->prop, NULL, "" TSRMLS_CC);
+ _property_string(&str, &ref->prop, NULL, "" TSRMLS_CC);
RETURN_STRINGL(str.string, str.len - 1, 0);
}
/* }}} */
@@ -3843,7 +3885,7 @@ static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask)
METHOD_NOTSTATIC_NUMPARAMS(reflection_property_ptr, 0);
GET_REFLECTION_OBJECT_PTR(ref);
- RETURN_BOOL(ref->prop->flags & mask);
+ RETURN_BOOL(ref->prop.flags & mask);
}
/* {{{ proto public bool ReflectionProperty::isPublic()
@@ -3896,7 +3938,7 @@ ZEND_METHOD(reflection_property, getModifiers)
METHOD_NOTSTATIC_NUMPARAMS(reflection_property_ptr, 0);
GET_REFLECTION_OBJECT_PTR(ref);
- RETURN_LONG(ref->prop->flags);
+ RETURN_LONG(ref->prop.flags);
}
/* }}} */
@@ -3912,7 +3954,7 @@ ZEND_METHOD(reflection_property, getValue)
METHOD_NOTSTATIC(reflection_property_ptr);
GET_REFLECTION_OBJECT_PTR(ref);
- if (!(ref->prop->flags & ZEND_ACC_PUBLIC)) {
+ if (!(ref->prop.flags & ZEND_ACC_PUBLIC)) {
_default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
@@ -3920,10 +3962,10 @@ ZEND_METHOD(reflection_property, getValue)
return;
}
- if ((ref->prop->flags & ZEND_ACC_STATIC)) {
+ if ((ref->prop.flags & ZEND_ACC_STATIC)) {
zend_update_class_constants(intern->ce TSRMLS_CC);
- if (zend_hash_quick_find(CE_STATIC_MEMBERS(intern->ce), ref->prop->name, ref->prop->name_length + 1, ref->prop->h, (void **) &member) == FAILURE) {
- zend_error(E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop->name);
+ if (zend_hash_quick_find(CE_STATIC_MEMBERS(intern->ce), ref->prop.name, ref->prop.name_length + 1, ref->prop.h, (void **) &member) == FAILURE) {
+ zend_error(E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name);
/* Bails out */
}
*return_value= **member;
@@ -3933,7 +3975,7 @@ ZEND_METHOD(reflection_property, getValue)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) {
return;
}
- member_p = zend_read_property(Z_OBJCE_P(object), object, ref->prop->name, ref->prop->name_length, 1 TSRMLS_CC);
+ member_p = zend_read_property(Z_OBJCE_P(object), object, ref->prop.name, ref->prop.name_length, 1 TSRMLS_CC);
*return_value= *member_p;
zval_copy_ctor(return_value);
INIT_PZVAL(return_value);
@@ -3961,7 +4003,7 @@ ZEND_METHOD(reflection_property, setValue)
METHOD_NOTSTATIC(reflection_property_ptr);
GET_REFLECTION_OBJECT_PTR(ref);
- if (!(ref->prop->flags & ZEND_ACC_PUBLIC)) {
+ if (!(ref->prop.flags & ZEND_ACC_PUBLIC)) {
_default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
@@ -3969,7 +4011,7 @@ ZEND_METHOD(reflection_property, setValue)
return;
}
- if ((ref->prop->flags & ZEND_ACC_STATIC)) {
+ if ((ref->prop.flags & ZEND_ACC_STATIC)) {
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &tmp, &value) == FAILURE) {
return;
@@ -3978,8 +4020,8 @@ ZEND_METHOD(reflection_property, setValue)
zend_update_class_constants(intern->ce TSRMLS_CC);
prop_table = CE_STATIC_MEMBERS(intern->ce);
- if (zend_hash_quick_find(prop_table, ref->prop->name, ref->prop->name_length + 1, ref->prop->h, (void **) &variable_ptr) == FAILURE) {
- zend_error(E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop->name);
+ if (zend_hash_quick_find(prop_table, ref->prop.name, ref->prop.name_length + 1, ref->prop.h, (void **) &variable_ptr) == FAILURE) {
+ zend_error(E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name);
/* Bails out */
}
if (*variable_ptr == value) {
@@ -4002,13 +4044,13 @@ ZEND_METHOD(reflection_property, setValue)
if (PZVAL_IS_REF(value)) {
SEPARATE_ZVAL(&value);
}
- zend_hash_quick_update(prop_table, ref->prop->name, ref->prop->name_length+1, ref->prop->h, &value, sizeof(zval *), (void **) &foo);
+ zend_hash_quick_update(prop_table, ref->prop.name, ref->prop.name_length+1, ref->prop.h, &value, sizeof(zval *), (void **) &foo);
}
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oz", &object, &value) == FAILURE) {
return;
}
- zend_update_property(Z_OBJCE_P(object), object, ref->prop->name, ref->prop->name_length, value TSRMLS_CC);
+ zend_update_property(Z_OBJCE_P(object), object, ref->prop.name, ref->prop.name_length, value TSRMLS_CC);
}
}
/* }}} */
@@ -4027,7 +4069,7 @@ ZEND_METHOD(reflection_property, getDeclaringClass)
METHOD_NOTSTATIC_NUMPARAMS(reflection_property_ptr, 0);
GET_REFLECTION_OBJECT_PTR(ref);
- if (zend_unmangle_property_name(ref->prop->name, ref->prop->name_length, &class_name, &prop_name) != SUCCESS) {
+ if (zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name) != SUCCESS) {
RETURN_FALSE;
}
@@ -4055,8 +4097,8 @@ ZEND_METHOD(reflection_property, getDocComment)
METHOD_NOTSTATIC_NUMPARAMS(reflection_property_ptr, 0);
GET_REFLECTION_OBJECT_PTR(ref);
- if (ref->prop->doc_comment) {
- RETURN_STRINGL(ref->prop->doc_comment, ref->prop->doc_comment_len, 1);
+ if (ref->prop.doc_comment) {
+ RETURN_STRINGL(ref->prop.doc_comment, ref->prop.doc_comment_len, 1);
}
RETURN_FALSE;
}
@@ -4851,7 +4893,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.31 2006/10/18 16:35:15 johannes Exp $");
+ php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.33.2.37 2007/04/12 18:39:46 johannes Exp $");
php_info_print_table_end();
} /* }}} */
diff --git a/ext/reflection/php_reflection.h b/ext/reflection/php_reflection.h
index 78a10aa8c..8ebeffb63 100644
--- a/ext/reflection/php_reflection.h
+++ b/ext/reflection/php_reflection.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 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.1 2006/06/10 00:40:57 bjori Exp $ */
+/* $Id: php_reflection.h,v 1.4.2.3.2.2 2007/01/01 09:36:05 sebastian Exp $ */
#ifndef PHP_REFLECTION_H
#define PHP_REFLECTION_H
diff --git a/ext/reflection/tests/008.phpt b/ext/reflection/tests/008.phpt
index 2abdcdb57..c5ee5b33e 100755
--- a/ext/reflection/tests/008.phpt
+++ b/ext/reflection/tests/008.phpt
@@ -1,5 +1,7 @@
--TEST--
ReflectionMethod::__construct() tests
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/009.phpt b/ext/reflection/tests/009.phpt
new file mode 100755
index 000000000..bfe37c52f
--- /dev/null
+++ b/ext/reflection/tests/009.phpt
@@ -0,0 +1,114 @@
+--TEST--
+ReflectionFunction basic tests
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+/**
+hoho
+*/
+function test ($a, $b = 1, $c = "") {
+ static $var = 1;
+}
+
+$func = new ReflectionFunction("test");
+
+var_dump($func->export("test"));
+echo "--getName--\n";
+var_dump($func->getName());
+echo "--isInternal--\n";
+var_dump($func->isInternal());
+echo "--isUserDefined--\n";
+var_dump($func->isUserDefined());
+echo "--getFilename--\n";
+var_dump($func->getFilename());
+echo "--getStartline--\n";
+var_dump($func->getStartline());
+echo "--getEndline--\n";
+var_dump($func->getEndline());
+echo "--getDocComment--\n";
+var_dump($func->getDocComment());
+echo "--getStaticVariables--\n";
+var_dump($func->getStaticVariables());
+echo "--invoke--\n";
+var_dump($func->invoke(array(1,2,3)));
+echo "--invokeArgs--\n";
+var_dump($func->invokeArgs(array(1,2,3)));
+echo "--returnsReference--\n";
+var_dump($func->returnsReference());
+echo "--getParameters--\n";
+var_dump($func->getParameters());
+echo "--getNumberOfParameters--\n";
+var_dump($func->getNumberOfParameters());
+echo "--getNumberOfRequiredParameters--\n";
+var_dump($func->getNumberOfRequiredParameters());
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+/**
+hoho
+*/
+Function [ <user> function test ] {
+ @@ %s009.php 6 - 8
+
+ - Parameters [3] {
+ Parameter #0 [ <required> $a ]
+ Parameter #1 [ <optional> $b = 1 ]
+ Parameter #2 [ <optional> $c = '' ]
+ }
+}
+
+NULL
+--getName--
+string(4) "test"
+--isInternal--
+bool(false)
+--isUserDefined--
+bool(true)
+--getFilename--
+string(%d) "%s009.php"
+--getStartline--
+int(6)
+--getEndline--
+int(8)
+--getDocComment--
+string(11) "/**
+hoho
+*/"
+--getStaticVariables--
+array(1) {
+ ["var"]=>
+ int(1)
+}
+--invoke--
+NULL
+--invokeArgs--
+NULL
+--returnsReference--
+bool(false)
+--getParameters--
+array(3) {
+ [0]=>
+ &object(ReflectionParameter)#2 (1) {
+ ["name"]=>
+ string(1) "a"
+ }
+ [1]=>
+ &object(ReflectionParameter)#3 (1) {
+ ["name"]=>
+ string(1) "b"
+ }
+ [2]=>
+ &object(ReflectionParameter)#4 (1) {
+ ["name"]=>
+ string(1) "c"
+ }
+}
+--getNumberOfParameters--
+int(3)
+--getNumberOfRequiredParameters--
+int(1)
+Done
diff --git a/ext/reflection/tests/bug29986.phpt b/ext/reflection/tests/bug29986.phpt
index 997bcf7cc..062eff6f9 100644
--- a/ext/reflection/tests/bug29986.phpt
+++ b/ext/reflection/tests/bug29986.phpt
@@ -1,5 +1,7 @@
--TEST--
Reflection Bug #29986 (Class constants won't work with predefined constants when using ReflectionClass)
+--INI--
+precision=14
--SKIPIF--
<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
diff --git a/ext/reflection/tests/bug37816.phpt b/ext/reflection/tests/bug37816.phpt
index 18a49046d..1121d5418 100755
--- a/ext/reflection/tests/bug37816.phpt
+++ b/ext/reflection/tests/bug37816.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #37816 (ReflectionProperty does not throw exception when accessing protected attribute)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/bug38217.phpt b/ext/reflection/tests/bug38217.phpt
index 55e0c4664..590d7f79e 100644
--- a/ext/reflection/tests/bug38217.phpt
+++ b/ext/reflection/tests/bug38217.phpt
@@ -1,5 +1,7 @@
--TEST--
-#38217 (ReflectionClass::newInstanceArgs() tries to allocate too much memory)
+Bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too much memory)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/bug38653.phpt b/ext/reflection/tests/bug38653.phpt
index 68781d2ab..0e6fcd035 100644
--- a/ext/reflection/tests/bug38653.phpt
+++ b/ext/reflection/tests/bug38653.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #38653 (memory leak in ReflectionClass::getConstant())
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/bug38942.phpt b/ext/reflection/tests/bug38942.phpt
index f66f2552b..a1ba05ba0 100755
--- a/ext/reflection/tests/bug38942.phpt
+++ b/ext/reflection/tests/bug38942.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #38942 (Double old-style-ctor inheritance)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class foo {
diff --git a/ext/reflection/tests/bug39001.phpt b/ext/reflection/tests/bug39001.phpt
index 1ed675f02..59bab0291 100644
--- a/ext/reflection/tests/bug39001.phpt
+++ b/ext/reflection/tests/bug39001.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #39001 (ReflectionProperty returns incorrect declaring class for protected properties)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/bug39067.phpt b/ext/reflection/tests/bug39067.phpt
index 8a7a6044e..020ae74e4 100644
--- a/ext/reflection/tests/bug39067.phpt
+++ b/ext/reflection/tests/bug39067.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #39067 (getDeclaringClass() and private properties)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/bug39884.phpt b/ext/reflection/tests/bug39884.phpt
new file mode 100644
index 000000000..8022954bf
--- /dev/null
+++ b/ext/reflection/tests/bug39884.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #39884 (ReflectionParameter::getClass() throws exception for type hint self)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+class stubParamTest
+{
+ function paramTest(self $param)
+ {
+ // nothing to do
+ }
+}
+$test1 = new stubParamTest();
+$test2 = new stubParamTest();
+$test1->paramTest($test2);
+$refParam = new ReflectionParameter(array('stubParamTest', 'paramTest'), 'param');
+var_dump($refParam->getClass());
+?>
+--EXPECT--
+object(ReflectionClass)#4 (1) {
+ ["name"]=>
+ string(13) "stubParamTest"
+}
diff --git a/ext/reflection/tests/bug40431.phpt b/ext/reflection/tests/bug40431.phpt
new file mode 100644
index 000000000..2f2b2d932
--- /dev/null
+++ b/ext/reflection/tests/bug40431.phpt
@@ -0,0 +1,140 @@
+--TEST--
+Bug #40431 (dynamic properties may cause crash in ReflectionProperty methods)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+echo "=== 1st test ===\n";
+
+$Obj->value = 'value';
+$RefObj = new ReflectionObject($Obj);
+
+$props = $RefObj->getProperties();
+
+var_dump($props);
+var_dump($props[0]->isStatic());
+var_dump($props[0]->isPrivate());
+var_dump($props[0]->isPublic());
+var_dump($props[0]->isProtected());
+
+echo "=== 2nd test ===\n";
+
+class test1 {
+}
+
+class test2 extends test1{
+}
+
+$Obj = new test2;
+$Obj->value = 'value';
+$RefObj = new ReflectionObject($Obj);
+
+$props = $RefObj->getProperties();
+
+var_dump($props);
+var_dump($props[0]->isStatic());
+var_dump($props[0]->isPrivate());
+var_dump($props[0]->isPublic());
+var_dump($props[0]->isProtected());
+
+echo "=== 3rd test ===\n";
+
+class test3 {
+}
+
+$Obj = new test3;
+$Obj->value = 'value';
+$RefObj = new ReflectionObject($Obj);
+
+$props = $RefObj->getProperties();
+
+var_dump($props);
+var_dump($props[0]->isStatic());
+var_dump($props[0]->isPrivate());
+var_dump($props[0]->isPublic());
+var_dump($props[0]->isProtected());
+
+echo "=== 4th test ===\n";
+
+class test5 {
+ private $value = 1;
+}
+
+class test4 extends test5{
+}
+
+$Obj = new test4;
+$Obj->value = 'value';
+$RefObj = new ReflectionObject($Obj);
+
+$props = $RefObj->getProperties();
+
+var_dump($props);
+var_dump($props[0]->isStatic());
+var_dump($props[0]->isPrivate());
+var_dump($props[0]->isPublic());
+var_dump($props[0]->isProtected());
+
+echo "Done\n";
+?>
+--EXPECTF--
+=== 1st test ===
+
+Strict Standards: Creating default object from empty value in %s on line %d
+array(1) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "value"
+ ["class"]=>
+ string(8) "stdClass"
+ }
+}
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+=== 2nd test ===
+array(1) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "value"
+ ["class"]=>
+ string(5) "test2"
+ }
+}
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+=== 3rd test ===
+array(1) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "value"
+ ["class"]=>
+ string(5) "test3"
+ }
+}
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+=== 4th test ===
+array(1) {
+ [0]=>
+ &object(ReflectionProperty)#%d (2) {
+ ["name"]=>
+ string(5) "value"
+ ["class"]=>
+ string(5) "test4"
+ }
+}
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+Done
diff --git a/ext/reflection/tests/bug40794.phpt b/ext/reflection/tests/bug40794.phpt
new file mode 100644
index 000000000..ca4f3e92b
--- /dev/null
+++ b/ext/reflection/tests/bug40794.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #40794 (ReflectionObject::getValues() may crash when used with dynamic properties)
+--SKIPIF--
+<?php
+if (!extension_loaded("reflection")) {
+ die("skip");
+}
+?>
+--FILE--
+<?php
+
+$obj = new stdClass();
+$obj->prop1 = '1';
+$obj->prop2 = '2';
+$obj->prop3 = '3';
+
+$reflect = new ReflectionObject($obj);
+
+$array = array();
+foreach($reflect->getProperties() as $prop)
+{
+ $array[$prop->getName()] = $prop->getValue($obj);
+}
+
+var_dump($array);
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(3) {
+ ["prop1"]=>
+ string(1) "1"
+ ["prop2"]=>
+ string(1) "2"
+ ["prop3"]=>
+ string(1) "3"
+}
+Done
diff --git a/ext/reflection/tests/bug41061.phpt b/ext/reflection/tests/bug41061.phpt
new file mode 100755
index 000000000..977828ef6
--- /dev/null
+++ b/ext/reflection/tests/bug41061.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Reflection Bug #41061 ("visibility error" in ReflectionFunction::export())
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function foo() {
+}
+
+class bar {
+ private function foo() {
+ }
+}
+
+Reflection::export(new ReflectionFunction('foo'));
+Reflection::export(new ReflectionMethod('bar', 'foo'));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Function [ <user> function foo ] {
+ @@ %sbug41061.php 3 - 4
+}
+
+Method [ <user> private method foo ] {
+ @@ %sbug41061.php 7 - 8
+}
+
+===DONE===