From: Nikita Popov Date: Fri, 17 Apr 2020 13:31:57 +0000 (+0200) Subject: Remove ZEND_ACC_DTOR flag X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=08c5c69eff6f0110b373c55ee2246591d14cc82b;p=php Remove ZEND_ACC_DTOR flag This is only used in reflection, where doing a simple string check is acceptable. I'm also dropping the "dtor" printing in the reflection dump. Dtors are just one of many magic methods, I don't think there's a point in explicitly highlighting them, when the name is already unambiguous. --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 6d23b34372..7ec8806d18 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2286,7 +2286,6 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio } } 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)); } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index bb9b42fee6..2e30295980 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6720,7 +6720,6 @@ zend_op *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 b925c809db..8631747c06 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -275,7 +275,7 @@ typedef struct _zend_oparray_context { /* Whether this class was used in its unlinked state. | | | */ #define ZEND_ACC_HAS_UNLINKED_USES (1 << 23) /* X | | | */ /* | | | */ -/* Function Flags (unused: 17, 23, 26) | | | */ +/* Function Flags (unused: 17, 23, 26, 29) | | | */ /* ============== | | | */ /* | | | */ /* deprecation flag | | | */ @@ -328,9 +328,6 @@ typedef struct _zend_oparray_context { /* functions is a constructor | | | */ #define ZEND_ACC_CTOR (1 << 28) /* | X | | */ /* | | | */ -/* function is a destructor | | | */ -#define ZEND_ACC_DTOR (1 << 29) /* | X | | */ -/* | | | */ /* closure uses $this | | | */ #define ZEND_ACC_USES_THIS (1 << 30) /* | X | | */ /* | | | */ diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index e23f0076a9..552913dd1e 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -767,9 +767,6 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent if (fptr->common.fn_flags & ZEND_ACC_CTOR) { smart_str_appends(str, ", ctor"); } - if (fptr->common.fn_flags & ZEND_ACC_DTOR) { - smart_str_appends(str, ", dtor"); - } smart_str_appends(str, "> "); if (fptr->common.fn_flags & ZEND_ACC_ABSTRACT) { @@ -3341,7 +3338,7 @@ ZEND_METHOD(ReflectionMethod, isConstructor) /* }}} */ /* {{{ proto public bool ReflectionMethod::isDestructor() - Returns whether this method is static */ + Returns whether this method is a destructor */ ZEND_METHOD(ReflectionMethod, isDestructor) { reflection_object *intern; @@ -3351,7 +3348,8 @@ ZEND_METHOD(ReflectionMethod, isDestructor) RETURN_THROWS(); } GET_REFLECTION_OBJECT_PTR(mptr); - RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_DTOR); + RETURN_BOOL(zend_string_equals_literal_ci( + mptr->common.function_name, ZEND_DESTRUCTOR_FUNC_NAME)); } /* }}} */ diff --git a/ext/reflection/tests/ReflectionMethod_basic2.phpt b/ext/reflection/tests/ReflectionMethod_basic2.phpt index f7d4b9f4d6..7af5e84ea9 100644 --- a/ext/reflection/tests/ReflectionMethod_basic2.phpt +++ b/ext/reflection/tests/ReflectionMethod_basic2.phpt @@ -126,7 +126,7 @@ string(%d) "Method [ public method __construct ] { Reflecting on method TestClass::__destruct() __toString(): -string(%d) "Method [ public method __destruct ] { +string(%d) "Method [ public method __destruct ] { @@ %s 28 - 28 } "