]> granicus.if.org Git - php/commitdiff
Add check for final properties
authorSterling Hughes <sterling@php.net>
Sun, 20 Apr 2003 14:52:40 +0000 (14:52 +0000)
committerSterling Hughes <sterling@php.net>
Sun, 20 Apr 2003 14:52:40 +0000 (14:52 +0000)
Zend/zend_compile.c

index 927fca5f8b644d6d42c51ca8221502eee0c116a7..49e9fb459d5ca6f74bd4ac854cf88799969ca09e 100644 (file)
@@ -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;
        }