summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-09-26 07:55:54 +0000
committerDmitry Stogov <dmitry@php.net>2006-09-26 07:55:54 +0000
commit59d0c16391fd35d72550c270ec90ed12789bba3c (patch)
tree2dc38f4d81a783122bb7707e9b54ad5eedcd9581
parent3fca8b863027eda73ed5c5c55942738b7a78102e (diff)
downloadphp-git-59d0c16391fd35d72550c270ec90ed12789bba3c.tar.gz
Fixed bug #38942 (Double old-style-ctor inheritance)
-rwxr-xr-xZend/tests/bug38942.phpt17
-rw-r--r--Zend/zend_builtin_functions.c20
-rw-r--r--ext/reflection/php_reflection.c18
-rwxr-xr-xext/reflection/tests/bug38942.phpt34
4 files changed, 84 insertions, 5 deletions
diff --git a/Zend/tests/bug38942.phpt b/Zend/tests/bug38942.phpt
new file mode 100755
index 0000000000..85bb56d200
--- /dev/null
+++ b/Zend/tests/bug38942.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #38942 (Double old-style-ctor inheritance)
+--FILE--
+<?php
+class foo {
+ public function foo() {}
+}
+
+class bar extends foo {
+}
+print_r(get_class_methods("bar"));
+?>
+--EXPECT--
+Array
+(
+ [0] => foo
+)
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 4733f4d0cc..0bc5e35a2a 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -922,9 +922,23 @@ ZEND_FUNCTION(get_class_methods)
instanceof_function(EG(scope), mptr->common.scope TSRMLS_CC))
|| ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) &&
EG(scope) == mptr->common.scope)))) {
- MAKE_STD_ZVAL(method_name);
- ZVAL_TEXT(method_name, mptr->common.function_name, 1);
- zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &method_name, sizeof(zval *), NULL);
+ zstr key;
+ uint key_len;
+ ulong num_index;
+ uint len = UG(unicode)?u_strlen(mptr->common.function_name.u):strlen(mptr->common.function_name.s);
+
+ /* Do not display old-style inherited constructors */
+ if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
+ mptr->common.scope == ce ||
+ zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != (UG(unicode)?HASH_KEY_IS_UNICODE:HASH_KEY_IS_STRING) ||
+ (UG(unicode) ?
+ (zend_u_binary_strcasecmp(key.u, key_len-1, mptr->common.function_name.u, len) == 0) :
+ (zend_binary_strcasecmp(key.s, key_len-1, mptr->common.function_name.s, len) == 0))) {
+
+ MAKE_STD_ZVAL(method_name);
+ ZVAL_TEXT(method_name, mptr->common.function_name, 1);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &method_name, sizeof(zval *), NULL);
+ }
}
zend_hash_move_forward_ex(&ce->function_table, &pos);
}
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 14bdcff73b..43113587c4 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -511,8 +511,22 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
if (!(mptr->common.fn_flags & ZEND_ACC_STATIC)) {
- string_printf(str, "\n");
- _function_string(str, mptr, ce, sub_indent.string TSRMLS_CC);
+ zstr key;
+ uint key_len;
+ ulong num_index;
+ uint len = UG(unicode)?u_strlen(mptr->common.function_name.u):strlen(mptr->common.function_name.s);
+
+ /* Do not display old-style inherited constructors */
+ if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
+ mptr->common.scope == ce ||
+ zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != (UG(unicode)?HASH_KEY_IS_UNICODE:HASH_KEY_IS_STRING) ||
+ (UG(unicode) ?
+ (zend_u_binary_strcasecmp(key.u, key_len-1, mptr->common.function_name.u, len) == 0) :
+ (zend_binary_strcasecmp(key.s, key_len-1, mptr->common.function_name.s, len) == 0))) {
+
+ string_printf(str, "\n");
+ _function_string(str, mptr, ce, sub_indent.string TSRMLS_CC);
+ }
}
zend_hash_move_forward_ex(&ce->function_table, &pos);
}
diff --git a/ext/reflection/tests/bug38942.phpt b/ext/reflection/tests/bug38942.phpt
new file mode 100755
index 0000000000..ce0d806bf4
--- /dev/null
+++ b/ext/reflection/tests/bug38942.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Bug #38942 (Double old-style-ctor inheritance)
+--FILE--
+<?php
+class foo {
+ public function foo() {}
+}
+
+class bar extends foo {
+}
+ReflectionClass::export("bar");
+?>
+--EXPECTF--
+Class [ <user> class bar extends foo ] {
+ @@ %sbug38942.php 6-7
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [2] {
+ Method [ <user, inherits foo, ctor> public method foo ] {
+ @@ %sbug38942.php 3 - 3
+ }
+ }
+}