Skip to content

Commit e758d88

Browse files
authored
zend_types: Remove Z_*CONSTANT_*() (#22295)
This macro is very rarely used and badly named by neither including the `IS` nor the `AST` in its name.
1 parent d6be30e commit e758d88

7 files changed

Lines changed: 13 additions & 15 deletions

File tree

UPGRADING.INTERNALS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ PHP 8.6 INTERNALS UPGRADE NOTES
120120
. Added ZEND_CONTAINER_OF().
121121
. The OPENBASEDIR_CHECKPATH() compatibility macro has been removed, instead
122122
use php_check_open_basedir() directly.
123+
. The Z_CONSTANT(), Z_CONSTANT_P(), Z_OPT_CONSTANT(), and
124+
Z_OPT_CONSTANT_P() macros have been removed. Check for IS_CONSTANT_AST
125+
directly.
123126
. Added zend_reflection_property_set_raw_value_without_lazy_initialization(),
124127
zend_reflection_property_set_raw_value() to expose the functionality of
125128
ReflectionProperty::setRawValueWithoutLazyInitialization() and

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9224,7 +9224,7 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f
92249224
if (*value_ast_ptr) {
92259225
zend_const_expr_to_zval(&value_zv, value_ast_ptr, /* allow_dynamic */ false);
92269226

9227-
if (ZEND_TYPE_IS_SET(type) && !Z_CONSTANT(value_zv)
9227+
if (ZEND_TYPE_IS_SET(type) && Z_TYPE(value_zv) != IS_CONSTANT_AST
92289228
&& !zend_is_valid_default_value(type, &value_zv)) {
92299229
zend_string *str = zend_type_to_string(type);
92309230
if (Z_TYPE(value_zv) == IS_NULL && !ZEND_TYPE_IS_INTERSECTION(type)) {
@@ -9348,7 +9348,7 @@ static void zend_compile_class_const_decl(zend_ast *ast, uint32_t flags, zend_as
93489348

93499349
zend_const_expr_to_zval(&value_zv, value_ast_ptr, /* allow_dynamic */ false);
93509350

9351-
if (!Z_CONSTANT(value_zv) && ZEND_TYPE_IS_SET(type) && !zend_is_valid_default_value(type, &value_zv)) {
9351+
if (Z_TYPE(value_zv) != IS_CONSTANT_AST && ZEND_TYPE_IS_SET(type) && !zend_is_valid_default_value(type, &value_zv)) {
93529352
zend_string *type_str = zend_type_to_string(type);
93539353

93549354
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use %s as value for class constant %s::%s of type %s",

Zend/zend_ini_parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static void zend_ini_get_constant(zval *result, zval *name)
151151
&& (c = zend_get_constant(Z_STR_P(name))) != 0) {
152152
if (Z_TYPE_P(c) != IS_STRING) {
153153
ZVAL_COPY_OR_DUP(&tmp, c);
154-
if (Z_OPT_CONSTANT(tmp)) {
154+
if (Z_OPT_TYPE(tmp) == IS_CONSTANT_AST) {
155155
zval_update_constant_ex(&tmp, NULL);
156156
}
157157
convert_to_string(&tmp);

Zend/zend_types.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,6 @@ static zend_always_inline uint32_t zend_gc_delref_ex(zend_refcounted_h *p, uint3
10171017
} while(0)
10181018

10191019
/* All data types < IS_STRING have their constructor/destructors skipped */
1020-
#define Z_CONSTANT(zval) (Z_TYPE(zval) == IS_CONSTANT_AST)
1021-
#define Z_CONSTANT_P(zval_p) Z_CONSTANT(*(zval_p))
10221020

10231021
#if 1
10241022
/* This optimized version assumes that we have a single "type_flag" */
@@ -1036,9 +1034,6 @@ static zend_always_inline uint32_t zend_gc_delref_ex(zend_refcounted_h *p, uint3
10361034
#define Z_OPT_TYPE(zval) (Z_TYPE_INFO(zval) & Z_TYPE_MASK)
10371035
#define Z_OPT_TYPE_P(zval_p) Z_OPT_TYPE(*(zval_p))
10381036

1039-
#define Z_OPT_CONSTANT(zval) (Z_OPT_TYPE(zval) == IS_CONSTANT_AST)
1040-
#define Z_OPT_CONSTANT_P(zval_p) Z_OPT_CONSTANT(*(zval_p))
1041-
10421037
#define Z_OPT_REFCOUNTED(zval) Z_TYPE_INFO_REFCOUNTED(Z_TYPE_INFO(zval))
10431038
#define Z_OPT_REFCOUNTED_P(zval_p) Z_OPT_REFCOUNTED(*(zval_p))
10441039

Zend/zend_vm_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8323,7 +8323,7 @@ ZEND_VM_HANDLER(143, ZEND_DECLARE_CONST, CONST, CONST)
83238323
val = GET_OP2_ZVAL_PTR(BP_VAR_R);
83248324

83258325
ZVAL_COPY(&c.value, val);
8326-
if (Z_OPT_CONSTANT(c.value)) {
8326+
if (Z_OPT_TYPE(c.value) == IS_CONSTANT_AST) {
83278327
if (UNEXPECTED(zval_update_constant_ex(&c.value, EX(func)->op_array.scope) != SUCCESS)) {
83288328
zval_ptr_dtor_nogc(&c.value);
83298329
FREE_OP1();
@@ -8355,7 +8355,7 @@ ZEND_VM_HANDLER(210, ZEND_DECLARE_ATTRIBUTED_CONST, CONST, CONST)
83558355
val = GET_OP2_ZVAL_PTR(BP_VAR_R);
83568356

83578357
ZVAL_COPY(&c.value, val);
8358-
if (Z_OPT_CONSTANT(c.value)) {
8358+
if (Z_OPT_TYPE(c.value) == IS_CONSTANT_AST) {
83598359
if (UNEXPECTED(zval_update_constant_ex(&c.value, EX(func)->op_array.scope) != SUCCESS)) {
83608360
zval_ptr_dtor_nogc(&c.value);
83618361
FREE_OP1();

Zend/zend_vm_execute.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/opcache/jit/zend_jit_ir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10924,7 +10924,7 @@ static int zend_jit_recv_init(zend_jit_ctx *jit, const zend_op *opline, const ze
1092410924
zv, true);
1092510925
}
1092610926

10927-
if (Z_CONSTANT_P(zv)) {
10927+
if (Z_TYPE_P(zv) == IS_CONSTANT_AST) {
1092810928
jit_SET_EX_OPLINE(jit, opline);
1092910929
ref = ir_CALL_2(IR_I32, ir_CONST_FC_FUNC(zval_update_constant_ex),
1093010930
jit_ZVAL_ADDR(jit, res_addr),

0 commit comments

Comments
 (0)