Commit c6a9d69356f for php.net
commit c6a9d69356f6ebf22dd60df047a8df8ae04ee74e
Author: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Date: Tue Sep 15 21:48:12 2026 +0200
Zend: use ZVAL_COPY_DEREF when possible (#23694)
Cleaner, but also an optimized macro.
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 062ba0f3b18..9702a335d46 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -462,8 +462,7 @@ ZEND_METHOD(Exception, getCode)
ZEND_PARSE_PARAMETERS_NONE();
prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_CODE);
- ZVAL_DEREF(prop);
- ZVAL_COPY(return_value, prop);
+ ZVAL_COPY_DEREF(return_value, prop);
}
/* }}} */
@@ -475,8 +474,7 @@ ZEND_METHOD(Exception, getTrace)
ZEND_PARSE_PARAMETERS_NONE();
prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_TRACE);
- ZVAL_DEREF(prop);
- ZVAL_COPY(return_value, prop);
+ ZVAL_COPY_DEREF(return_value, prop);
}
/* }}} */
@@ -488,8 +486,7 @@ ZEND_METHOD(ErrorException, getSeverity)
ZEND_PARSE_PARAMETERS_NONE();
prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_SEVERITY);
- ZVAL_DEREF(prop);
- ZVAL_COPY(return_value, prop);
+ ZVAL_COPY_DEREF(return_value, prop);
}
/* }}} */
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 14a340ffee3..9047550cafb 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1080,8 +1080,7 @@ static zend_never_inline zval* zend_assign_to_typed_prop(const zend_property_inf
}
}
- ZVAL_DEREF(value);
- ZVAL_COPY(&tmp, value);
+ ZVAL_COPY_DEREF(&tmp, value);
if (UNEXPECTED(!i_zend_verify_property_type(info, &tmp, EX_USES_STRICT_TYPES()))) {
zval_ptr_dtor(&tmp);