From be7d41b90556c498059ce093e67519d2abcb24e3 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Wed, 28 Jan 2004 11:53:52 +0000 Subject: [PATCH] - Error message fix - Prevent inheritance of the same constant from two interfaces --- Zend/zend_compile.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index f83dc2ac46..ee1afa651c 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1739,7 +1739,7 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f zend_error(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)", parent->common.scope->name, child->common.function_name, - child->common.scope->name); + child->common.prototype ? child->common.prototype->common.scope->name : child->common.scope->name); } if (parent_flags & ZEND_ACC_FINAL) { @@ -1935,9 +1935,19 @@ void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRML } +static zend_bool do_inherit_constant_check(HashTable *child_constants_table, zval *parent_constant, zend_hash_key *hash_key, zend_class_entry *iface) +{ + if (zend_hash_quick_exists(child_constants_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h)) { + zend_error(E_COMPILE_ERROR, "Cannot inherit previously-inherited constant %s from interface %s", hash_key->arKey, iface->name); + return 0; + } + return 1; +} + + ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) { - zend_hash_merge(&ce->constants_table, &iface->constants_table, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0); + zend_hash_merge_ex(&ce->constants_table, &iface->constants_table, (copy_ctor_func_t) zval_add_ref, sizeof(zval *), do_inherit_constant_check, iface); zend_hash_merge_ex(&ce->function_table, &iface->function_table, (copy_ctor_func_t) do_inherit_method, sizeof(zend_function), (merge_checker_func_t) do_inherit_method_check, ce); do_implement_interface(ce, iface TSRMLS_CC); -- 2.50.1