]> granicus.if.org Git - php/commitdiff
Add final classes
authorMarcus Boerger <helly@php.net>
Sat, 21 Jun 2003 21:56:06 +0000 (21:56 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 21 Jun 2003 21:56:06 +0000 (21:56 +0000)
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_language_parser.y

index 3f2b8048000e27745d63cb3bd35e998b4ea6eccf..a876e941ac5d38238220da41c062ee1f36cfa2dd 100644 (file)
@@ -1834,6 +1834,9 @@ void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce)
                && !(parent_ce->ce_flags & ZEND_ACC_INTERFACE)) {
                zend_error(E_ERROR, "Interface %s may not inherit from class (%s)", ce->name, parent_ce->name);
        }
+       if (parent_ce->ce_flags & ZEND_ACC_FINAL_CLASS) {
+               zend_error(E_ERROR, "Class %s may not inherit from final class (%s)", ce->name, parent_ce->name);
+       }
 
        ce->parent = parent_ce;
        /* Inherit interfaces */
index 1a4ec937be5a18a3991cd77f4114ab2ab79e5316..5f8f4890306f65dd4bdc286f53f4e83ac84b826e 100644 (file)
@@ -99,6 +99,7 @@ typedef struct _zend_brk_cont_element {
 #define ZEND_ACC_FINAL                 0x04
 #define ZEND_ACC_INTERFACE             0x08
 #define ZEND_ACC_ABSTRACT_CLASS        0x10
+#define ZEND_ACC_FINAL_CLASS   0x20
 
 /* The order of those must be kept - public < protected < private */
 #define ZEND_ACC_PUBLIC                0x100
index 0cd1e0703341e802df3488b1343707be95f510a6..c2beb4a2648fc19e62f6ad84f6398f5a8da5d05f 100644 (file)
@@ -277,6 +277,7 @@ unticked_class_declaration_statement:
 class_entry_type:
                T_CLASS                 {  $$.u.constant.value.lval = 0; }
        |       T_ABSTRACT T_CLASS { $$.u.constant.value.lval = ZEND_ACC_ABSTRACT_CLASS; }
+       |       T_FINAL T_CLASS { $$.u.constant.value.lval = ZEND_ACC_FINAL_CLASS; }
        |       T_INTERFACE             { $$.u.constant.value.lval = ZEND_ACC_INTERFACE; }
 ;