From 8939c4d96b8382abe84f35e69f4f6ebd6f0f749d Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 5 Sep 2018 13:16:10 +0300 Subject: [PATCH] Get rid of ZEND_ACC_CTOR, ZEND_ACC_DTOR and ZEND_ACC_IMPLEMENTED_ABSTRACT --- UPGRADING.INTERNALS | 8 + Zend/zend_API.c | 6 +- Zend/zend_builtin_functions.c | 2 +- Zend/zend_compile.c | 2 - Zend/zend_compile.h | 7 - Zend/zend_inheritance.c | 154 ++++++++++-------- Zend/zend_interfaces.c | 2 +- ext/curl/curl_file.c | 2 +- ext/date/php_date.c | 10 +- ext/hash/hash.c | 2 +- ext/intl/collator/collator_class.c | 2 +- ext/intl/converter/converter.c | 2 +- ext/intl/dateformat/dateformat_class.c | 2 +- ext/intl/formatter/formatter_class.c | 2 +- ext/intl/msgformat/msgformat_class.c | 2 +- .../resourcebundle/resourcebundle_class.c | 2 +- ext/intl/spoofchecker/spoofchecker_class.c | 2 +- .../transliterator/transliterator_class.c | 2 +- ext/reflection/php_reflection.c | 10 +- ext/sqlite3/sqlite3.c | 6 +- 20 files changed, 117 insertions(+), 110 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 9981b56f8b..882a8a650d 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -3,6 +3,7 @@ PHP 7.4 INTERNALS UPGRADE NOTES 1. Internal API changes a. php_sys_symlink() and php_sys_link() b. zend_lookup_class_ex() and zend_fetch_class_by_name() + c. Function flags 2. Build system changes a. Unix build system changes @@ -22,6 +23,13 @@ PHP 7.4 INTERNALS UPGRADE NOTES changed to accept optional lower-case class name as zend_string*, instead of zval*. + c. Function flags changes + - ZEND_ACC_CTOR and ZEND_ACC_DTOR are removed. It's pissible to check if + method is a constructor/destructor using the following condintion + (func->commpon.scope->constructor == func). + - ZEND_ACC_IMPLEMENTED_ABSTRACT is removed (it was used only internally + during inheritance). + ======================== 2. Build system changes ======================== diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 87d6272980..0cf6ef0c08 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2410,14 +2410,12 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio scope->__isset = __isset; scope->__debugInfo = __debugInfo; if (ctor) { - ctor->common.fn_flags |= ZEND_ACC_CTOR; if (ctor->common.fn_flags & ZEND_ACC_STATIC) { zend_error(error_type, "Constructor %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(ctor->common.function_name)); } ctor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (dtor) { - dtor->common.fn_flags |= ZEND_ACC_DTOR; if (dtor->common.fn_flags & ZEND_ACC_STATIC) { zend_error(error_type, "Destructor %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(dtor->common.function_name)); } @@ -2477,11 +2475,11 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio } } - if (ctor && ctor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && ctor->common.fn_flags & ZEND_ACC_CTOR) { + if (ctor && (ctor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE)) { zend_error_noreturn(E_CORE_ERROR, "Constructor %s::%s() cannot declare a return type", ZSTR_VAL(scope->name), ZSTR_VAL(ctor->common.function_name)); } - if (dtor && dtor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && dtor->common.fn_flags & ZEND_ACC_DTOR) { + if (dtor && (dtor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE)) { zend_error_noreturn(E_CORE_ERROR, "Destructor %s::%s() cannot declare a return type", ZSTR_VAL(scope->name), ZSTR_VAL(dtor->common.function_name)); } diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 5b7ecd8c86..d83169cac8 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1300,7 +1300,7 @@ ZEND_FUNCTION(get_class_methods) if (!key) { ZVAL_STR_COPY(&method_name, mptr->common.function_name); zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name); - } else if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 || + } else if (mptr->common.scope->constructor != mptr || mptr->common.scope == ce || zend_binary_strcasecmp(ZSTR_VAL(key), ZSTR_LEN(key), ZSTR_VAL(mptr->common.function_name), len) == 0) { diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 5831f6605c..4764329b57 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6296,7 +6296,6 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ } if (ce->constructor) { - ce->constructor->common.fn_flags |= ZEND_ACC_CTOR; if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) { zend_error_noreturn(E_COMPILE_ERROR, "Constructor %s::%s() cannot be static", ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name)); @@ -6308,7 +6307,6 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ } } if (ce->destructor) { - ce->destructor->common.fn_flags |= ZEND_ACC_DTOR; if (ce->destructor->common.fn_flags & ZEND_ACC_STATIC) { zend_error_noreturn(E_COMPILE_ERROR, "Destructor %s::%s() cannot be static", ZSTR_VAL(ce->name), ZSTR_VAL(ce->destructor->common.function_name)); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 96f09878bb..b7f7014281 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -271,18 +271,11 @@ typedef struct _zend_oparray_context { /* Abstarct method | | | */ #define ZEND_ACC_ABSTRACT (1 << 1) /* | X | | */ /* | | | */ -/* TODO: used only during inheritance ??? | | | */ -#define ZEND_ACC_IMPLEMENTED_ABSTRACT (1 << 3) /* | X | | */ -/* | | | */ #define ZEND_ACC_FAKE_CLOSURE (1 << 6) /* | X | | */ /* | | | */ /* method flag used by Closure::__invoke() | | | */ #define ZEND_ACC_USER_ARG_INFO (1 << 7) /* | X | | */ /* | | | */ -/* method flags (special method detection) | | | */ -#define ZEND_ACC_CTOR (1 << 13) /* | X | | */ -#define ZEND_ACC_DTOR (1 << 14) /* | X | | */ -/* | | | */ /* "main" op_array with | | | */ /* ZEND_DECLARE_INHERITED_CLASS_DELAYED opcodes | | | */ #define ZEND_ACC_EARLY_BINDING (1 << 15) /* | X | | */ diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index d9711977bf..c6a89754c9 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -90,22 +90,24 @@ static zend_function *zend_duplicate_function(zend_function *func, zend_class_en static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */ { - ZEND_ASSERT(ce->parent != NULL); + zend_class_entry *parent = ce->parent; + + ZEND_ASSERT(parent != NULL); /* You cannot change create_object */ - ce->create_object = ce->parent->create_object; + ce->create_object = parent->create_object; /* Inherit special functions if needed */ if (EXPECTED(!ce->get_iterator)) { - ce->get_iterator = ce->parent->get_iterator; + ce->get_iterator = parent->get_iterator; } - if (EXPECTED(!ce->iterator_funcs_ptr) && UNEXPECTED(ce->parent->iterator_funcs_ptr)) { + if (EXPECTED(!ce->iterator_funcs_ptr) && UNEXPECTED(parent->iterator_funcs_ptr)) { if (ce->type == ZEND_INTERNAL_CLASS) { ce->iterator_funcs_ptr = calloc(1, sizeof(zend_class_iterator_funcs)); - if (ce->parent->iterator_funcs_ptr->zf_new_iterator) { + if (parent->iterator_funcs_ptr->zf_new_iterator) { ce->iterator_funcs_ptr->zf_new_iterator = zend_hash_str_find_ptr(&ce->function_table, "getiterator", sizeof("getiterator") - 1); } - if (ce->parent->iterator_funcs_ptr->zf_current) { + if (parent->iterator_funcs_ptr->zf_current) { ce->iterator_funcs_ptr->zf_rewind = zend_hash_str_find_ptr(&ce->function_table, "rewind", sizeof("rewind") - 1); ce->iterator_funcs_ptr->zf_valid = zend_hash_str_find_ptr(&ce->function_table, "valid", sizeof("valid") - 1); ce->iterator_funcs_ptr->zf_key = zend_hash_str_find_ptr(&ce->function_table, "key", sizeof("key") - 1); @@ -118,52 +120,52 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */ } } if (EXPECTED(!ce->__get)) { - ce->__get = ce->parent->__get; + ce->__get = parent->__get; } if (EXPECTED(!ce->__set)) { - ce->__set = ce->parent->__set; + ce->__set = parent->__set; } if (EXPECTED(!ce->__unset)) { - ce->__unset = ce->parent->__unset; + ce->__unset = parent->__unset; } if (EXPECTED(!ce->__isset)) { - ce->__isset = ce->parent->__isset; + ce->__isset = parent->__isset; } if (EXPECTED(!ce->__call)) { - ce->__call = ce->parent->__call; + ce->__call = parent->__call; } if (EXPECTED(!ce->__callstatic)) { - ce->__callstatic = ce->parent->__callstatic; + ce->__callstatic = parent->__callstatic; } if (EXPECTED(!ce->__tostring)) { - ce->__tostring = ce->parent->__tostring; + ce->__tostring = parent->__tostring; } if (EXPECTED(!ce->clone)) { - ce->clone = ce->parent->clone; + ce->clone = parent->clone; } if (EXPECTED(!ce->serialize)) { - ce->serialize = ce->parent->serialize; + ce->serialize = parent->serialize; } if (EXPECTED(!ce->unserialize)) { - ce->unserialize = ce->parent->unserialize; + ce->unserialize = parent->unserialize; } if (!ce->destructor) { - ce->destructor = ce->parent->destructor; + ce->destructor = parent->destructor; } if (EXPECTED(!ce->__debugInfo)) { - ce->__debugInfo = ce->parent->__debugInfo; + ce->__debugInfo = parent->__debugInfo; } if (ce->constructor) { - if (ce->parent->constructor && UNEXPECTED(ce->parent->constructor->common.fn_flags & ZEND_ACC_FINAL)) { + if (parent->constructor && UNEXPECTED(parent->constructor->common.fn_flags & ZEND_ACC_FINAL)) { zend_error_noreturn(E_ERROR, "Cannot override final %s::%s() with %s::%s()", - ZSTR_VAL(ce->parent->name), ZSTR_VAL(ce->parent->constructor->common.function_name), + ZSTR_VAL(parent->name), ZSTR_VAL(parent->constructor->common.function_name), ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name)); } return; } - ce->constructor = ce->parent->constructor; + ce->constructor = parent->constructor; } /* }}} */ @@ -284,14 +286,14 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c * we still need to do the arg number checks. We are only willing to ignore this for internal * functions because extensions don't always define arg_info. */ - if (!proto || (!proto->common.arg_info && proto->common.type != ZEND_USER_FUNCTION)) { + if (!proto->common.arg_info && proto->common.type != ZEND_USER_FUNCTION) { return 1; } /* Checks for constructors only if they are declared in an interface, * or explicitly marked as abstract */ - if ((fe->common.fn_flags & ZEND_ACC_CTOR) + if ((fe->common.scope->constructor == fe) && ((proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0 && (proto->common.fn_flags & ZEND_ACC_ABSTRACT) == 0)) { return 1; @@ -584,55 +586,64 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function * zend_error_noreturn(E_COMPILE_ERROR, "Cannot make non abstract method %s::%s() abstract in class %s", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child)); } - /* Prevent derived classes from restricting access that was available in parent classes (except deriving from non-abstract ctors) */ - if (UNEXPECTED((!(child_flags & ZEND_ACC_CTOR) || (parent_flags & (ZEND_ACC_ABSTRACT | ZEND_ACC_IMPLEMENTED_ABSTRACT))) && - (child_flags & ZEND_ACC_PPP_MASK) > (parent_flags & ZEND_ACC_PPP_MASK))) { - zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::%s() must be %s (as in class %s)%s", ZEND_FN_SCOPE_NAME(child), ZSTR_VAL(child->common.function_name), zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker"); - } - if ((child_flags & ZEND_ACC_PRIVATE) < (parent_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_CHANGED))) { child->common.fn_flags |= ZEND_ACC_CHANGED; } - if (parent_flags & ZEND_ACC_PRIVATE) { - child->common.prototype = NULL; - } else if (parent_flags & ZEND_ACC_ABSTRACT) { - child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; - child->common.prototype = parent; - } else if (!(parent->common.fn_flags & ZEND_ACC_CTOR)) { - child->common.prototype = parent->common.prototype ? parent->common.prototype : parent; - } else if (parent->common.prototype && (parent->common.prototype->common.scope->ce_flags & ZEND_ACC_INTERFACE)) { - /* ctors only have a prototype if it comes from an interface */ - child->common.prototype = parent->common.prototype ? parent->common.prototype : parent; - /* and if that is the case, we want to check inheritance against it */ - parent = child->common.prototype; - } - - if (UNEXPECTED(!zend_do_perform_implementation_check(child, parent))) { - int error_level; - const char *error_verb; - zend_string *method_prototype = zend_get_function_declaration(parent); - zend_string *child_prototype = zend_get_function_declaration(child); - - if (child->common.prototype && ( - child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT - )) { - error_level = E_COMPILE_ERROR; - error_verb = "must"; - } else if ((parent->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) && - (!(child->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) || - !zend_do_perform_type_hint_check(child, child->common.arg_info - 1, parent, parent->common.arg_info - 1) || - (ZEND_TYPE_ALLOW_NULL(child->common.arg_info[-1].type) && !ZEND_TYPE_ALLOW_NULL(parent->common.arg_info[-1].type)))) { - error_level = E_COMPILE_ERROR; - error_verb = "must"; - } else { - error_level = E_WARNING; - error_verb = "should"; + do { + if (!(parent_flags & ZEND_ACC_PRIVATE)) { + if (parent_flags & ZEND_ACC_ABSTRACT) { + child->common.prototype = parent; + } else { + zend_function *proto = parent->common.prototype; + + if (parent->common.scope->constructor != parent) { + child->common.prototype = proto ? proto : parent; + } else if (proto) { + if (proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) { + /* ctors only have a prototype if it comes from an interface */ + child->common.prototype = proto; + /* and if that is the case, we want to check inheritance against it */ + parent = proto; + } else if (!(proto->common.fn_flags & ZEND_ACC_ABSTRACT)) { + break; + } + } else { + break; + } + } + /* Prevent derived classes from restricting access that was available in parent classes (except deriving from non-abstract ctors) */ + if ((child_flags & ZEND_ACC_PPP_MASK) > (parent_flags & ZEND_ACC_PPP_MASK)) { + zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::%s() must be %s (as in class %s)%s", ZEND_FN_SCOPE_NAME(child), ZSTR_VAL(child->common.function_name), zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker"); + } + + if (UNEXPECTED(!zend_do_perform_implementation_check(child, parent))) { + int error_level; + const char *error_verb; + zend_string *method_prototype = zend_get_function_declaration(parent); + zend_string *child_prototype = zend_get_function_declaration(child); + + if (child->common.prototype && ( + child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT + )) { + error_level = E_COMPILE_ERROR; + error_verb = "must"; + } else if ((parent->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) && + (!(child->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) || + !zend_do_perform_type_hint_check(child, child->common.arg_info - 1, parent, parent->common.arg_info - 1) || + (ZEND_TYPE_ALLOW_NULL(child->common.arg_info[-1].type) && !ZEND_TYPE_ALLOW_NULL(parent->common.arg_info[-1].type)))) { + error_level = E_COMPILE_ERROR; + error_verb = "must"; + } else { + error_level = E_WARNING; + error_verb = "should"; + } + zend_error(error_level, "Declaration of %s %s be compatible with %s", ZSTR_VAL(child_prototype), error_verb, ZSTR_VAL(method_prototype)); + zend_string_efree(child_prototype); + zend_string_efree(method_prototype); + } } - zend_error(error_level, "Declaration of %s %s be compatible with %s", ZSTR_VAL(child_prototype), error_verb, ZSTR_VAL(method_prototype)); - zend_string_efree(child_prototype); - zend_string_efree(method_prototype); - } + } while (0); } /* }}} */ @@ -1202,11 +1213,10 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen zend_string *lowercase_name = zend_string_tolower(ce->name); lowercase_name = zend_new_interned_string(lowercase_name); if (!memcmp(ZSTR_VAL(mname), ZSTR_VAL(lowercase_name), ZSTR_LEN(mname))) { - if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) { + if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) { zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name)); } ce->constructor = fe; - fe->common.fn_flags |= ZEND_ACC_CTOR; } zend_string_release_ex(lowercase_name, 0); } else if (ZSTR_VAL(mname)[0] != '_' || ZSTR_VAL(mname)[1] != '_') { @@ -1217,9 +1227,9 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) { zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name)); } - ce->constructor = fe; fe->common.fn_flags |= ZEND_ACC_CTOR; + ce->constructor = fe; } else if (zend_string_equals_literal(mname, ZEND_DESTRUCTOR_FUNC_NAME)) { - ce->destructor = fe; fe->common.fn_flags |= ZEND_ACC_DTOR; + ce->destructor = fe; } else if (zend_string_equals_literal(mname, ZEND_GET_FUNC_NAME)) { ce->__get = fe; ce->ce_flags |= ZEND_ACC_USE_GUARDS; @@ -1903,7 +1913,7 @@ static void zend_verify_abstract_class_function(zend_function *fn, zend_abstract if (ai->cnt < MAX_ABSTRACT_INFO_CNT) { ai->afn[ai->cnt] = fn; } - if (fn->common.fn_flags & ZEND_ACC_CTOR) { + if (fn->common.scope->constructor == fn) { if (!ai->ctor) { ai->cnt++; ai->ctor = 1; diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index cf92cbf4d7..64d46c75e2 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -548,7 +548,7 @@ ZEND_END_ARG_INFO() static const zend_function_entry zend_funcs_serializable[] = { ZEND_ABSTRACT_ME(serializable, serialize, NULL) - ZEND_FENTRY(unserialize, NULL, arginfo_serializable_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT|ZEND_ACC_CTOR) + ZEND_FENTRY(unserialize, NULL, arginfo_serializable_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT) ZEND_FE_END }; diff --git a/ext/curl/curl_file.c b/ext/curl/curl_file.c index f6657a17a8..eca7741f17 100644 --- a/ext/curl/curl_file.c +++ b/ext/curl/curl_file.c @@ -152,7 +152,7 @@ ZEND_END_ARG_INFO() static const zend_function_entry curlfile_funcs[] = { - PHP_ME(CURLFile, __construct, arginfo_curlfile_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(CURLFile, __construct, arginfo_curlfile_create, ZEND_ACC_PUBLIC) PHP_ME(CURLFile, getFilename, NULL, ZEND_ACC_PUBLIC) PHP_ME(CURLFile, getMimeType, NULL, ZEND_ACC_PUBLIC) PHP_ME(CURLFile, setMimeType, arginfo_curlfile_name, ZEND_ACC_PUBLIC) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 507bdb4738..d1f94dcd22 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -477,7 +477,7 @@ static const zend_function_entry date_funcs_interface[] = { }; static const zend_function_entry date_funcs_date[] = { - PHP_ME(DateTime, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DateTime, __construct, arginfo_date_create, ZEND_ACC_PUBLIC) PHP_ME(DateTime, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DateTime, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(DateTime, createFromImmutable, arginfo_date_method_create_from_immutable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) @@ -500,7 +500,7 @@ static const zend_function_entry date_funcs_date[] = { }; static const zend_function_entry date_funcs_immutable[] = { - PHP_ME(DateTimeImmutable, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DateTimeImmutable, __construct, arginfo_date_create, ZEND_ACC_PUBLIC) PHP_ME(DateTime, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DateTimeImmutable, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME_MAPPING(createFromFormat, date_create_immutable_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) @@ -523,7 +523,7 @@ static const zend_function_entry date_funcs_immutable[] = { }; static const zend_function_entry date_funcs_timezone[] = { - PHP_ME(DateTimeZone, __construct, arginfo_timezone_open, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DateTimeZone, __construct, arginfo_timezone_open, ZEND_ACC_PUBLIC) PHP_ME(DateTimeZone, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DateTimeZone, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME_MAPPING(getName, timezone_name_get, arginfo_timezone_method_name_get, 0) @@ -536,7 +536,7 @@ static const zend_function_entry date_funcs_timezone[] = { }; static const zend_function_entry date_funcs_interval[] = { - PHP_ME(DateInterval, __construct, arginfo_date_interval_construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DateInterval, __construct, arginfo_date_interval_construct, ZEND_ACC_PUBLIC) PHP_ME(DateInterval, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DateInterval, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME_MAPPING(format, date_interval_format, arginfo_date_method_interval_format, 0) @@ -545,7 +545,7 @@ static const zend_function_entry date_funcs_interval[] = { }; static const zend_function_entry date_funcs_period[] = { - PHP_ME(DatePeriod, __construct, arginfo_date_period_construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(DatePeriod, __construct, arginfo_date_period_construct, ZEND_ACC_PUBLIC) PHP_ME(DatePeriod, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(DatePeriod, __set_state, arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(DatePeriod, getStartDate, NULL, ZEND_ACC_PUBLIC) diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 6bd52e2596..d3b4a07c5a 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -888,7 +888,7 @@ static PHP_METHOD(HashContext, __construct) { /* }}} */ static const zend_function_entry php_hashcontext_methods[] = { - PHP_ME(HashContext, __construct, NULL, ZEND_ACC_PRIVATE | ZEND_ACC_CTOR) + PHP_ME(HashContext, __construct, NULL, ZEND_ACC_PRIVATE) PHP_FE_END }; diff --git a/ext/intl/collator/collator_class.c b/ext/intl/collator/collator_class.c index d7d6ed4ed9..0dcc134042 100644 --- a/ext/intl/collator/collator_class.c +++ b/ext/intl/collator/collator_class.c @@ -97,7 +97,7 @@ ZEND_END_ARG_INFO() */ static const zend_function_entry Collator_class_functions[] = { - PHP_ME( Collator, __construct, collator_1_arg, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR ) + PHP_ME( Collator, __construct, collator_1_arg, ZEND_ACC_PUBLIC ) ZEND_FENTRY( create, ZEND_FN( collator_create ), collator_1_arg, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) PHP_NAMED_FE( compare, ZEND_FN( collator_compare ), collator_2_args ) PHP_NAMED_FE( sort, ZEND_FN( collator_sort ), collator_sort_args ) diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 95b0e6592c..eada568a80 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -969,7 +969,7 @@ static PHP_METHOD(UConverter, getStandards) { /* }}} */ static const zend_function_entry php_converter_methods[] = { - PHP_ME(UConverter, __construct, php_converter_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + PHP_ME(UConverter, __construct, php_converter_arginfo, ZEND_ACC_PUBLIC) /* Encoding selection */ PHP_ME(UConverter, setSourceEncoding, php_converter_set_encoding_arginfo, ZEND_ACC_PUBLIC) diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.c index fc2be15e1e..b923f70508 100644 --- a/ext/intl/dateformat/dateformat_class.c +++ b/ext/intl/dateformat/dateformat_class.c @@ -158,7 +158,7 @@ ZEND_END_ARG_INFO() * Every 'IntlDateFormatter' class method has an entry in this table */ static const zend_function_entry IntlDateFormatter_class_functions[] = { - PHP_ME( IntlDateFormatter, __construct, arginfo_intldateformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR ) + PHP_ME( IntlDateFormatter, __construct, arginfo_intldateformatter___construct, ZEND_ACC_PUBLIC ) ZEND_FENTRY( create, ZEND_FN( datefmt_create ), arginfo_intldateformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) PHP_NAMED_FE( getDateType, ZEND_FN( datefmt_get_datetype ), arginfo_intldateformatter_getdatetype ) PHP_NAMED_FE( getTimeType, ZEND_FN( datefmt_get_timetype ), arginfo_intldateformatter_getdatetype ) diff --git a/ext/intl/formatter/formatter_class.c b/ext/intl/formatter/formatter_class.c index d2356d5759..0b1066f29c 100644 --- a/ext/intl/formatter/formatter_class.c +++ b/ext/intl/formatter/formatter_class.c @@ -151,7 +151,7 @@ ZEND_END_ARG_INFO() * Every 'NumberFormatter' class method has an entry in this table */ static const zend_function_entry NumberFormatter_class_functions[] = { - PHP_ME( NumberFormatter, __construct, arginfo_numberformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR ) + PHP_ME( NumberFormatter, __construct, arginfo_numberformatter___construct, ZEND_ACC_PUBLIC ) ZEND_FENTRY( create, ZEND_FN( numfmt_create ), arginfo_numberformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) PHP_NAMED_FE( format, ZEND_FN( numfmt_format ), arginfo_numberformatter_format ) PHP_NAMED_FE( parse, ZEND_FN( numfmt_parse ), number_parse_arginfo ) diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c index 8501a2fe65..cccc4f5c75 100644 --- a/ext/intl/msgformat/msgformat_class.c +++ b/ext/intl/msgformat/msgformat_class.c @@ -125,7 +125,7 @@ ZEND_END_ARG_INFO() * Every 'MessageFormatter' class method has an entry in this table */ static const zend_function_entry MessageFormatter_class_functions[] = { - PHP_ME( MessageFormatter, __construct, arginfo_messageformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR ) + PHP_ME( MessageFormatter, __construct, arginfo_messageformatter___construct, ZEND_ACC_PUBLIC ) ZEND_FENTRY( create, ZEND_FN( msgfmt_create ), arginfo_messageformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) PHP_NAMED_FE( format, ZEND_FN( msgfmt_format ), arginfo_messageformatter_format ) ZEND_FENTRY( formatMessage, ZEND_FN( msgfmt_format_message ), arginfo_messageformatter_formatmessage, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index 5b142a54d1..64f510e0fd 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -423,7 +423,7 @@ PHP_FUNCTION( resourcebundle_get_error_message ) * Every 'ResourceBundle' class method has an entry in this table */ static const zend_function_entry ResourceBundle_class_functions[] = { - PHP_ME( ResourceBundle, __construct, arginfo_resourcebundle___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR ) + PHP_ME( ResourceBundle, __construct, arginfo_resourcebundle___construct, ZEND_ACC_PUBLIC ) ZEND_NAMED_ME( create, ZEND_FN( resourcebundle_create ), arginfo_resourcebundle___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC ) ZEND_NAMED_ME( get, ZEND_FN(resourcebundle_get), arginfo_resourcebundle_get, ZEND_ACC_PUBLIC ) ZEND_NAMED_ME( count, ZEND_FN(resourcebundle_count), arginfo_resourcebundle_count, ZEND_ACC_PUBLIC ) diff --git a/ext/intl/spoofchecker/spoofchecker_class.c b/ext/intl/spoofchecker/spoofchecker_class.c index f24eed3869..03d4caaad5 100644 --- a/ext/intl/spoofchecker/spoofchecker_class.c +++ b/ext/intl/spoofchecker/spoofchecker_class.c @@ -96,7 +96,7 @@ ZEND_END_ARG_INFO() */ static const zend_function_entry Spoofchecker_class_functions[] = { - PHP_ME(Spoofchecker, __construct, spoofchecker_0_args, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_ME(Spoofchecker, __construct, spoofchecker_0_args, ZEND_ACC_PUBLIC) PHP_ME(Spoofchecker, isSuspicious, spoofchecker_is_suspicous, ZEND_ACC_PUBLIC) PHP_ME(Spoofchecker, areConfusable, spoofchecker_are_confusable, ZEND_ACC_PUBLIC) PHP_ME(Spoofchecker, setAllowedLocales, spoofchecker_set_allowed_locales, ZEND_ACC_PUBLIC) diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.c index 3c58b43324..e06ebd5c25 100644 --- a/ext/intl/transliterator/transliterator_class.c +++ b/ext/intl/transliterator/transliterator_class.c @@ -311,7 +311,7 @@ ZEND_END_ARG_INFO() * Every 'Transliterator' class method has an entry in this table */ static const zend_function_entry Transliterator_class_functions[] = { - PHP_ME( Transliterator, __construct, ainfo_trans_void, ZEND_ACC_PRIVATE | ZEND_ACC_CTOR | ZEND_ACC_FINAL ) + PHP_ME( Transliterator, __construct, ainfo_trans_void, ZEND_ACC_PRIVATE | ZEND_ACC_FINAL ) PHP_ME_MAPPING( create, transliterator_create, ainfo_trans_create, ZEND_ACC_STATIC |ZEND_ACC_PUBLIC ) PHP_ME_MAPPING( createFromRules,transliterator_create_from_rules, ainfo_trans_create_from_rules, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC ) PHP_ME_MAPPING( createInverse, transliterator_create_inverse, ainfo_trans_void, ZEND_ACC_PUBLIC ) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index e20479837b..8fe8da071a 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -472,7 +472,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char size_t len = ZSTR_LEN(mptr->common.function_name); /* Do not display old-style inherited constructors */ - if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 + if (mptr->common.scope->constructor != mptr || mptr->common.scope == ce || !key || zend_binary_strcasecmp(ZSTR_VAL(key), ZSTR_LEN(key), ZSTR_VAL(mptr->common.function_name), len) == 0) @@ -744,10 +744,10 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent if (fptr->common.prototype && fptr->common.prototype->common.scope) { smart_str_append_printf(str, ", prototype %s", ZSTR_VAL(fptr->common.prototype->common.scope->name)); } - if (fptr->common.fn_flags & ZEND_ACC_CTOR) { + if (fptr->common.scope && fptr->common.scope->constructor == fptr) { smart_str_appends(str, ", ctor"); } - if (fptr->common.fn_flags & ZEND_ACC_DTOR) { + if (fptr->common.scope && fptr->common.scope->destructor == fptr) { smart_str_appends(str, ", dtor"); } smart_str_appends(str, "> "); @@ -3407,7 +3407,7 @@ ZEND_METHOD(reflection_method, isConstructor) /* we need to check if the ctor is the ctor of the class level we we * looking at since we might be looking at an inherited old style ctor * defined in base class. */ - RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_CTOR && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope); + RETURN_BOOL(intern->ce->constructor == mptr); } /* }}} */ @@ -3422,7 +3422,7 @@ ZEND_METHOD(reflection_method, isDestructor) return; } GET_REFLECTION_OBJECT_PTR(mptr); - RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_DTOR); + RETURN_BOOL(intern->ce->destructor == mptr); } /* }}} */ diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 2c269fc337..c91aec17cd 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -2014,7 +2014,7 @@ static const zend_function_entry php_sqlite3_class_methods[] = { PHP_ME(sqlite3, openBlob, arginfo_sqlite3_openblob, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, enableExceptions, arginfo_sqlite3_enableexceptions, ZEND_ACC_PUBLIC) /* Aliases */ - PHP_MALIAS(sqlite3, __construct, open, arginfo_sqlite3_open, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_MALIAS(sqlite3, __construct, open, arginfo_sqlite3_open, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ @@ -2029,7 +2029,7 @@ static const zend_function_entry php_sqlite3_stmt_class_methods[] = { PHP_ME(sqlite3stmt, bindParam, arginfo_sqlite3stmt_bindparam, ZEND_ACC_PUBLIC) PHP_ME(sqlite3stmt, bindValue, arginfo_sqlite3stmt_bindvalue, ZEND_ACC_PUBLIC) PHP_ME(sqlite3stmt, readOnly, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3stmt, __construct, arginfo_sqlite3stmt_construct, ZEND_ACC_PRIVATE|ZEND_ACC_CTOR) + PHP_ME(sqlite3stmt, __construct, arginfo_sqlite3stmt_construct, ZEND_ACC_PRIVATE) PHP_FE_END }; /* }}} */ @@ -2042,7 +2042,7 @@ static const zend_function_entry php_sqlite3_result_class_methods[] = { PHP_ME(sqlite3result, fetchArray, arginfo_sqlite3result_fetcharray, ZEND_ACC_PUBLIC) PHP_ME(sqlite3result, reset, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) PHP_ME(sqlite3result, finalize, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3result, __construct, arginfo_sqlite3_void, ZEND_ACC_PRIVATE|ZEND_ACC_CTOR) + PHP_ME(sqlite3result, __construct, arginfo_sqlite3_void, ZEND_ACC_PRIVATE) PHP_FE_END }; /* }}} */ -- 2.40.0