mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
- Rename compatiblity mode to zend.ze2_compatibility_mode (it doesn't only affect auto-clone).
- Perform implementation checks even with simple inheritance (off when compatibility mode is enabled). - Restore default arguments in interfaces and handle it correctly. - Move registration of internal classes later in the startup sequence in order to have INI options available.
This commit is contained in:
parent
ca64573e1b
commit
eb6fd52e21
6 changed files with 21 additions and 31 deletions
16
Zend/zend.c
16
Zend/zend.c
|
@ -73,20 +73,9 @@ static ZEND_INI_MH(OnUpdateErrorReporting)
|
|||
}
|
||||
|
||||
|
||||
static ZEND_INI_MH(OnUpdateImplicitClone)
|
||||
{
|
||||
if (!new_value) {
|
||||
EG(implicit_clone) = 0;
|
||||
} else {
|
||||
EG(implicit_clone) = atoi(new_value) ? 1 : 0;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_INI_BEGIN()
|
||||
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
|
||||
ZEND_INI_ENTRY("zend2.implicit_clone", NULL, ZEND_INI_ALL, OnUpdateImplicitClone)
|
||||
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
|
||||
STD_ZEND_INI_BOOLEAN("zend.ze1_compatibility_mode", "0", ZEND_INI_ALL, OnUpdateBool, ze1_compatibility_mode, zend_executor_globals, executor_globals)
|
||||
ZEND_INI_END()
|
||||
|
||||
|
||||
|
@ -643,7 +632,6 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
|
|||
if (start_builtin_functions) {
|
||||
zend_startup_builtin_functions(TSRMLS_C);
|
||||
}
|
||||
zend_register_default_classes(TSRMLS_C);
|
||||
|
||||
zend_ini_startup(TSRMLS_C);
|
||||
|
||||
|
|
|
@ -1136,11 +1136,6 @@ void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initia
|
|||
opline->result = *var;
|
||||
opline->op1 = *offset;
|
||||
if (op == ZEND_RECV_INIT) {
|
||||
if ((CG(active_class_entry) && CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE)
|
||||
|| CG(active_op_array)->fn_flags & ZEND_ACC_ABSTRACT) {
|
||||
CG(active_op_array)->num_args--; /* invalidate the current arg_info entry */
|
||||
zend_error(E_COMPILE_ERROR, "Abstract methods cannot have default values for arguments");
|
||||
}
|
||||
opline->op2 = *initialization;
|
||||
} else {
|
||||
CG(active_op_array)->required_num_args = CG(active_op_array)->num_args;
|
||||
|
@ -1723,7 +1718,7 @@ static zend_bool zend_do_perform_implementation_check(zend_function *fe)
|
|||
}
|
||||
|
||||
/* check number of arguments */
|
||||
if (proto->common.num_args < fe->common.required_num_args
|
||||
if (proto->common.required_num_args != fe->common.required_num_args
|
||||
|| proto->common.num_args > fe->common.num_args) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1768,6 +1763,7 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f
|
|||
zend_uint child_flags;
|
||||
zend_uint parent_flags = parent->common.fn_flags;
|
||||
zend_function *child;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zend_hash_quick_find(child_function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child)==FAILURE) {
|
||||
if (parent_flags & ZEND_ACC_ABSTRACT) {
|
||||
|
@ -1818,15 +1814,22 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f
|
|||
}
|
||||
}
|
||||
|
||||
if (parent_flags & ZEND_ACC_ABSTRACT) {
|
||||
if (EG(ze1_compatibility_mode)) {
|
||||
if (parent_flags & ZEND_ACC_ABSTRACT) {
|
||||
child->common.prototype = parent;
|
||||
child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT;
|
||||
} else {
|
||||
child->common.prototype = parent->common.prototype;
|
||||
}
|
||||
} else {
|
||||
child->common.prototype = parent;
|
||||
child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT;
|
||||
} else if (parent->common.prototype) {
|
||||
child->common.prototype = parent->common.prototype;
|
||||
if (parent_flags & ZEND_ACC_ABSTRACT) {
|
||||
child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT;
|
||||
}
|
||||
}
|
||||
|
||||
if (!zend_do_perform_implementation_check(child)) {
|
||||
zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be the same as %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name);
|
||||
zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with that of %s::%s()", ZEND_FN_SCOPE_NAME(child), child->common.function_name, ZEND_FN_SCOPE_NAME(child->common.prototype), child->common.prototype->common.function_name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -382,7 +382,7 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, znode
|
|||
}
|
||||
|
||||
/* here we are sure we are dealing with an object */
|
||||
if (EG(implicit_clone)) {
|
||||
if (EG(ze1_compatibility_mode)) {
|
||||
SEPARATE_ZVAL_IF_NOT_REF(object_ptr);
|
||||
object = *object_ptr;
|
||||
}
|
||||
|
@ -2401,7 +2401,7 @@ int zend_init_ctor_call_handler(ZEND_OPCODE_HANDLER_ARGS)
|
|||
|
||||
/* We are not handling overloaded classes right now */
|
||||
EX(object) = get_zval_ptr(&opline->op1, EX(Ts), &EG(free_op1), BP_VAR_R);
|
||||
if (!PZVAL_IS_REF(EX(object)) || !EG(implicit_clone)) {
|
||||
if (!PZVAL_IS_REF(EX(object)) || !EG(ze1_compatibility_mode)) {
|
||||
EX(object)->refcount++; /* For $this pointer */
|
||||
} else {
|
||||
zval *this_ptr;
|
||||
|
@ -2459,7 +2459,7 @@ int zend_init_method_call_handler(ZEND_OPCODE_HANDLER_ARGS)
|
|||
if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
|
||||
EX(object) = NULL;
|
||||
} else {
|
||||
if (!PZVAL_IS_REF(EX(object)) || !EG(implicit_clone)) {
|
||||
if (!PZVAL_IS_REF(EX(object)) || !EG(ze1_compatibility_mode)) {
|
||||
EX(object)->refcount++; /* For $this pointer */
|
||||
} else {
|
||||
zval *this_ptr;
|
||||
|
|
|
@ -132,7 +132,6 @@ void init_executor(TSRMLS_D)
|
|||
EG(symtable_cache_ptr) = EG(symtable_cache)-1;
|
||||
EG(symtable_cache_limit)=EG(symtable_cache)+SYMTABLE_CACHE_SIZE-1;
|
||||
EG(no_extensions)=0;
|
||||
EG(implicit_clone)=0;
|
||||
|
||||
EG(function_table) = CG(function_table);
|
||||
EG(class_table) = CG(class_table);
|
||||
|
|
|
@ -193,7 +193,7 @@ struct _zend_executor_globals {
|
|||
zend_bool in_autoload;
|
||||
zend_bool bailout_set;
|
||||
zend_bool full_tables_cleanup;
|
||||
zend_bool implicit_clone;
|
||||
zend_bool ze1_compatibility_mode;
|
||||
|
||||
/* for extended information support */
|
||||
zend_bool no_extensions;
|
||||
|
|
|
@ -154,7 +154,7 @@ ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC)
|
|||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (EG(implicit_clone)) {
|
||||
if (EG(ze1_compatibility_mode)) {
|
||||
zvalue->value.obj = zvalue->value.obj.handlers->clone_obj(zvalue TSRMLS_CC);
|
||||
} else {
|
||||
Z_OBJ_HT_P(zvalue)->add_ref(zvalue TSRMLS_CC);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue