mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Add final classes
This commit is contained in:
parent
2df990c803
commit
60c7abac61
3 changed files with 5 additions and 0 deletions
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue