@@ -1135,7 +1135,7 @@ zend_string *zend_type_to_string_resolved(zend_type type, zend_class_entry *scop
1135
1135
} else if (ZEND_TYPE_IS_CE (type )) {
1136
1136
str = zend_string_copy (ZEND_TYPE_CE (type )-> name );
1137
1137
} else {
1138
- uint32_t type_mask = ZEND_TYPE_MASK ( ZEND_TYPE_WITHOUT_NULL ( type ) );
1138
+ uint32_t type_mask = ZEND_TYPE_PURE_MASK_WITHOUT_NULL ( type );
1139
1139
switch (type_mask ) {
1140
1140
case MAY_BE_FALSE |MAY_BE_TRUE :
1141
1141
str = ZSTR_KNOWN (ZEND_STR_BOOL );
@@ -1199,7 +1199,7 @@ static void zend_mark_function_as_generator() /* {{{ */
1199
1199
|| zend_string_equals_literal_ci (name , "Iterator" )
1200
1200
|| zend_string_equals_literal_ci (name , "Generator" );
1201
1201
} else {
1202
- valid_type = (ZEND_TYPE_MASK (return_info .type ) & MAY_BE_ITERABLE ) != 0 ;
1202
+ valid_type = (ZEND_TYPE_FULL_MASK (return_info .type ) & MAY_BE_ITERABLE ) != 0 ;
1203
1203
}
1204
1204
1205
1205
if (!valid_type ) {
@@ -2175,7 +2175,7 @@ static void zend_emit_return_type_check(
2175
2175
zend_op * opline ;
2176
2176
2177
2177
/* `return ...;` is illegal in a void function (but `return;` isn't) */
2178
- if (ZEND_TYPE_IS_MASK ( type ) && ZEND_TYPE_CONTAINS_CODE (type , IS_VOID )) {
2178
+ if (ZEND_TYPE_CONTAINS_CODE (type , IS_VOID )) {
2179
2179
if (expr ) {
2180
2180
if (expr -> op_type == IS_CONST && Z_TYPE (expr -> u .constant ) == IS_NULL ) {
2181
2181
zend_error_noreturn (E_COMPILE_ERROR ,
@@ -2201,8 +2201,7 @@ static void zend_emit_return_type_check(
2201
2201
}
2202
2202
2203
2203
if (expr && expr -> op_type == IS_CONST ) {
2204
- if (ZEND_TYPE_IS_MASK (type )
2205
- && ZEND_TYPE_CONTAINS_CODE (type , Z_TYPE (expr -> u .constant ))) {
2204
+ if (ZEND_TYPE_CONTAINS_CODE (type , Z_TYPE (expr -> u .constant ))) {
2206
2205
/* we don't need run-time check */
2207
2206
return ;
2208
2207
}
@@ -5359,11 +5358,11 @@ ZEND_API void zend_set_function_arg_flags(zend_function *func) /* {{{ */
5359
5358
n = MIN (func -> common .num_args , MAX_ARG_FLAG_NUM );
5360
5359
i = 0 ;
5361
5360
while (i < n ) {
5362
- ZEND_SET_ARG_FLAG (func , i + 1 , func -> common .arg_info [i ]. pass_by_reference );
5361
+ ZEND_SET_ARG_FLAG (func , i + 1 , ZEND_ARG_SEND_MODE ( & func -> common .arg_info [i ]) );
5363
5362
i ++ ;
5364
5363
}
5365
- if (UNEXPECTED (func -> common .fn_flags & ZEND_ACC_VARIADIC && func -> common .arg_info [i ]. pass_by_reference )) {
5366
- uint32_t pass_by_reference = func -> common .arg_info [i ]. pass_by_reference ;
5364
+ if (UNEXPECTED (func -> common .fn_flags & ZEND_ACC_VARIADIC && ZEND_ARG_SEND_MODE ( & func -> common .arg_info [i ]) )) {
5365
+ uint32_t pass_by_reference = ZEND_ARG_SEND_MODE ( & func -> common .arg_info [i ]) ;
5367
5366
while (i < MAX_ARG_FLAG_NUM ) {
5368
5367
ZEND_SET_ARG_FLAG (func , i + 1 , pass_by_reference );
5369
5368
i ++ ;
@@ -5382,7 +5381,7 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null
5382
5381
}
5383
5382
5384
5383
if (ast -> kind == ZEND_AST_TYPE ) {
5385
- return ZEND_TYPE_ENCODE_CODE ( ast -> attr , allow_null );
5384
+ return ( zend_type ) ZEND_TYPE_INIT_CODE ( ast -> attr , allow_null , 0 );
5386
5385
} else {
5387
5386
zend_string * class_name = zend_ast_get_str (ast );
5388
5387
zend_uchar type = zend_lookup_builtin_type_by_name (class_name );
@@ -5396,7 +5395,7 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null
5396
5395
if (type == IS_VOID && allow_null ) {
5397
5396
zend_error_noreturn (E_COMPILE_ERROR , "Void type cannot be nullable" );
5398
5397
}
5399
- return ZEND_TYPE_ENCODE_CODE ( type , allow_null );
5398
+ return ( zend_type ) ZEND_TYPE_INIT_CODE ( type , allow_null , 0 );
5400
5399
} else {
5401
5400
const char * correct_name ;
5402
5401
zend_string * orig_name = zend_ast_get_str (ast );
@@ -5428,7 +5427,7 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null
5428
5427
}
5429
5428
}
5430
5429
5431
- return ZEND_TYPE_ENCODE_CLASS ( class_name , allow_null );
5430
+ return ( zend_type ) ZEND_TYPE_INIT_CLASS ( class_name , allow_null , 0 );
5432
5431
}
5433
5432
}
5434
5433
}
@@ -5448,12 +5447,12 @@ static zend_bool zend_is_valid_default_value(zend_type type, zval *value)
5448
5447
if (ZEND_TYPE_CONTAINS_CODE (type , Z_TYPE_P (value ))) {
5449
5448
return 1 ;
5450
5449
}
5451
- if ((ZEND_TYPE_MASK (type ) & MAY_BE_DOUBLE ) && Z_TYPE_P (value ) == IS_LONG ) {
5450
+ if ((ZEND_TYPE_FULL_MASK (type ) & MAY_BE_DOUBLE ) && Z_TYPE_P (value ) == IS_LONG ) {
5452
5451
/* Integers are allowed as initializers for floating-point values. */
5453
5452
convert_to_double (value );
5454
5453
return 1 ;
5455
5454
}
5456
- if ((ZEND_TYPE_MASK (type ) & MAY_BE_ITERABLE ) && Z_TYPE_P (value ) == IS_ARRAY ) {
5455
+ if ((ZEND_TYPE_FULL_MASK (type ) & MAY_BE_ITERABLE ) && Z_TYPE_P (value ) == IS_ARRAY ) {
5457
5456
return 1 ;
5458
5457
}
5459
5458
return 0 ;
@@ -5470,9 +5469,9 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */
5470
5469
/* Use op_array->arg_info[-1] for return type */
5471
5470
arg_infos = safe_emalloc (sizeof (zend_arg_info ), list -> children + 1 , 0 );
5472
5471
arg_infos -> name = NULL ;
5473
- arg_infos -> pass_by_reference = (op_array -> fn_flags & ZEND_ACC_RETURN_REFERENCE ) != 0 ;
5474
- arg_infos -> is_variadic = 0 ;
5475
5472
arg_infos -> type = zend_compile_typename (return_type_ast , 0 );
5473
+ ZEND_TYPE_FULL_MASK (arg_infos -> type ) |= _ZEND_ARG_INFO_FLAGS (
5474
+ (op_array -> fn_flags & ZEND_ACC_RETURN_REFERENCE ) != 0 , /* is_variadic */ 0 );
5476
5475
arg_infos ++ ;
5477
5476
op_array -> fn_flags |= ZEND_ACC_HAS_RETURN_TYPE ;
5478
5477
} else {
@@ -5540,23 +5539,18 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */
5540
5539
5541
5540
arg_info = & arg_infos [i ];
5542
5541
arg_info -> name = zend_string_copy (name );
5543
- arg_info -> pass_by_reference = is_ref ;
5544
- arg_info -> is_variadic = is_variadic ;
5545
- arg_info -> type = ZEND_TYPE_ENCODE_NONE ();
5542
+ arg_info -> type = (zend_type ) ZEND_TYPE_INIT_NONE (0 );
5546
5543
5547
5544
if (type_ast ) {
5548
5545
uint32_t default_type = default_ast ? Z_TYPE (default_node .u .constant ) : IS_UNDEF ;
5549
5546
5550
- uint32_t arg_type ;
5551
5547
zend_bool is_class ;
5552
5548
5553
5549
op_array -> fn_flags |= ZEND_ACC_HAS_TYPE_HINTS ;
5554
5550
arg_info -> type = zend_compile_typename (type_ast , default_type == IS_NULL );
5555
-
5556
5551
is_class = ZEND_TYPE_IS_CLASS (arg_info -> type );
5557
- arg_type = !is_class ? ZEND_TYPE_MASK (arg_info -> type ) : 0 ;
5558
5552
5559
- if (arg_type & MAY_BE_VOID ) {
5553
+ if (! is_class && ( ZEND_TYPE_FULL_MASK ( arg_info -> type ) & MAY_BE_VOID ) ) {
5560
5554
zend_error_noreturn (E_COMPILE_ERROR , "void cannot be used as a parameter type" );
5561
5555
}
5562
5556
@@ -5580,6 +5574,8 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */
5580
5574
opline -> extended_value = zend_alloc_cache_slot ();
5581
5575
}
5582
5576
}
5577
+
5578
+ ZEND_TYPE_FULL_MASK (arg_info -> type ) |= _ZEND_ARG_INFO_FLAGS (is_ref , is_variadic );
5583
5579
}
5584
5580
5585
5581
/* These are assigned at the end to avoid uninitialized memory in case of an error */
@@ -6079,13 +6075,12 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t flags) /
6079
6075
zend_string * name = zval_make_interned_string (zend_ast_get_zval (name_ast ));
6080
6076
zend_string * doc_comment = NULL ;
6081
6077
zval value_zv ;
6082
- zend_type type = ZEND_TYPE_ENCODE_NONE ( );
6078
+ zend_type type = ZEND_TYPE_INIT_NONE ( 0 );
6083
6079
6084
6080
if (type_ast ) {
6085
6081
type = zend_compile_typename (type_ast , 0 );
6086
6082
6087
- if (ZEND_TYPE_IS_MASK (type )
6088
- && (ZEND_TYPE_MASK (type ) & (MAY_BE_VOID |MAY_BE_CALLABLE ))) {
6083
+ if (ZEND_TYPE_FULL_MASK (type ) & (MAY_BE_VOID |MAY_BE_CALLABLE )) {
6089
6084
zend_string * str = zend_type_to_string (type );
6090
6085
zend_error_noreturn (E_COMPILE_ERROR ,
6091
6086
"Property %s::$%s cannot have type %s" ,
0 commit comments