]> granicus.if.org Git - php/commitdiff
Remove ZEND_ACC_DTOR flag
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 17 Apr 2020 13:31:57 +0000 (15:31 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 17 Apr 2020 13:32:47 +0000 (15:32 +0200)
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.

Zend/zend_API.c
Zend/zend_compile.c
Zend/zend_compile.h
ext/reflection/php_reflection.c
ext/reflection/tests/ReflectionMethod_basic2.phpt

index 6d23b3437295cb7953de23a5a38e3a0865693c87..7ec8806d18351f2adab9cd6b09802a38c663a8ba 100644 (file)
@@ -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));
                        }
index bb9b42fee650f49a1823696e2c14df7779a6b26a..2e30295980c4feacbde28d8a3dfe053069665e56 100644 (file)
@@ -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));
index b925c809db2e27cadfc423bfb8ef05340517a048..8631747c063001e531ad2c15b40efd4de997bd47 100644 (file)
@@ -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  |     |     */
 /*                                                        |     |     |     */
index e23f0076a966212a6aa81e98ff258db6a4da6e65..552913dd1ef02460354bfaeb56ee0afa5674405a 100644 (file)
@@ -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));
 }
 /* }}} */
 
index f7d4b9f4d6e9aba4d3478270b87384de883594e3..7af5e84ea91051916163da85ec0ba522cd41cdce 100644 (file)
@@ -126,7 +126,7 @@ string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
 Reflecting on method TestClass::__destruct()
 
 __toString():
-string(%d) "Method [ <user, dtor> public method __destruct ] {
+string(%d) "Method [ <user> public method __destruct ] {
   @@ %s 28 - 28
 }
 "