summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2004-01-28 11:53:52 +0000
committerZeev Suraski <zeev@php.net>2004-01-28 11:53:52 +0000
commitbe7d41b90556c498059ce093e67519d2abcb24e3 (patch)
tree6608c7b079e000dab9f7376815369b053114cf72
parenta7ff369cacb00ffb7775fe46bfa7413bbae0ea5d (diff)
downloadphp-git-be7d41b90556c498059ce093e67519d2abcb24e3.tar.gz
- Error message fix
- Prevent inheritance of the same constant from two interfaces
-rw-r--r--Zend/zend_compile.c14
1 files 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);