Skip to content

Commit 08c5c69

Browse files
committed
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.
1 parent 7352213 commit 08c5c69

File tree

5 files changed

+5
-12
lines changed

5 files changed

+5
-12
lines changed

Zend/zend_API.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2286,7 +2286,6 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
22862286
}
22872287
}
22882288
if (dtor) {
2289-
dtor->common.fn_flags |= ZEND_ACC_DTOR;
22902289
if (dtor->common.fn_flags & ZEND_ACC_STATIC) {
22912290
zend_error(error_type, "Destructor %s::%s() cannot be static", ZSTR_VAL(scope->name), ZSTR_VAL(dtor->common.function_name));
22922291
}

Zend/zend_compile.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6720,7 +6720,6 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
67206720
}
67216721
}
67226722
if (ce->destructor) {
6723-
ce->destructor->common.fn_flags |= ZEND_ACC_DTOR;
67246723
if (ce->destructor->common.fn_flags & ZEND_ACC_STATIC) {
67256724
zend_error_noreturn(E_COMPILE_ERROR, "Destructor %s::%s() cannot be static",
67266725
ZSTR_VAL(ce->name), ZSTR_VAL(ce->destructor->common.function_name));

Zend/zend_compile.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ typedef struct _zend_oparray_context {
275275
/* Whether this class was used in its unlinked state. | | | */
276276
#define ZEND_ACC_HAS_UNLINKED_USES (1 << 23) /* X | | | */
277277
/* | | | */
278-
/* Function Flags (unused: 17, 23, 26) | | | */
278+
/* Function Flags (unused: 17, 23, 26, 29) | | | */
279279
/* ============== | | | */
280280
/* | | | */
281281
/* deprecation flag | | | */
@@ -328,9 +328,6 @@ typedef struct _zend_oparray_context {
328328
/* functions is a constructor | | | */
329329
#define ZEND_ACC_CTOR (1 << 28) /* | X | | */
330330
/* | | | */
331-
/* function is a destructor | | | */
332-
#define ZEND_ACC_DTOR (1 << 29) /* | X | | */
333-
/* | | | */
334331
/* closure uses $this | | | */
335332
#define ZEND_ACC_USES_THIS (1 << 30) /* | X | | */
336333
/* | | | */

ext/reflection/php_reflection.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,6 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent
767767
if (fptr->common.fn_flags & ZEND_ACC_CTOR) {
768768
smart_str_appends(str, ", ctor");
769769
}
770-
if (fptr->common.fn_flags & ZEND_ACC_DTOR) {
771-
smart_str_appends(str, ", dtor");
772-
}
773770
smart_str_appends(str, "> ");
774771

775772
if (fptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
@@ -3341,7 +3338,7 @@ ZEND_METHOD(ReflectionMethod, isConstructor)
33413338
/* }}} */
33423339

33433340
/* {{{ proto public bool ReflectionMethod::isDestructor()
3344-
Returns whether this method is static */
3341+
Returns whether this method is a destructor */
33453342
ZEND_METHOD(ReflectionMethod, isDestructor)
33463343
{
33473344
reflection_object *intern;
@@ -3351,7 +3348,8 @@ ZEND_METHOD(ReflectionMethod, isDestructor)
33513348
RETURN_THROWS();
33523349
}
33533350
GET_REFLECTION_OBJECT_PTR(mptr);
3354-
RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_DTOR);
3351+
RETURN_BOOL(zend_string_equals_literal_ci(
3352+
mptr->common.function_name, ZEND_DESTRUCTOR_FUNC_NAME));
33553353
}
33563354
/* }}} */
33573355

ext/reflection/tests/ReflectionMethod_basic2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ string(%d) "Method [ <internal:Reflection, ctor> public method __construct ] {
126126
Reflecting on method TestClass::__destruct()
127127

128128
__toString():
129-
string(%d) "Method [ <user, dtor> public method __destruct ] {
129+
string(%d) "Method [ <user> public method __destruct ] {
130130
@@ %s 28 - 28
131131
}
132132
"

0 commit comments

Comments
 (0)