From b4262dcf17a7ca0b70bcebd300a129605056f01a Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Sun, 20 Apr 2003 14:52:40 +0000 Subject: [PATCH] Add check for final properties --- Zend/zend_compile.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 927fca5f8b..49e9fb459d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1788,9 +1788,6 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro } if (zend_hash_quick_find(&ce->properties_info, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) { - if (parent_info->flags & ZEND_ACC_FINAL) { - zend_error(E_COMPILE_ERROR, "Cannot override final property %s::$%s", parent_ce->name, hash_key->arKey); - } if ((child_info->flags & ZEND_ACC_PPP_MASK) > (parent_info->flags & ZEND_ACC_PPP_MASK)) { zend_error(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ce->name, hash_key->arKey, zend_visibility_string(parent_info->flags), parent_ce->name, (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker"); } else if (child_info->flags & ZEND_ACC_IMPLICIT_PUBLIC) { @@ -2348,6 +2345,11 @@ void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_ty zend_error(E_COMPILE_ERROR, "Properties cannot be declared abstract"); } + if (access_type & ZEND_ACC_FINAL) { + zend_error(E_COMPILE_ERROR, "Cannot declare property $%s::%s final, the final modifier is allowed only for methods", + CG(active_class_entry)->name, var_name->u.constant.value.str.val); + } + if (!(access_type & ZEND_ACC_PPP_MASK)) { access_type |= ZEND_ACC_PUBLIC; } -- 2.50.1