Skip to content

Commit fa8ace8

Browse files
Merge branch 'php:master' into master
2 parents 072c44e + 5033f6f commit fa8ace8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1202
-743
lines changed

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ PHP 8.3 UPGRADE NOTES
3232
- Posix
3333
. posix_getrlimit() now takes an optional $res parameter to allow fetching a
3434
single resource limit.
35+
. posix_isatty() now raises type warnings for integers following the usual ZPP semantics
36+
. posix_ttyname() now raises type warnings for integers following the usual ZPP semantics
37+
and value warnings for invalid file descriptor integers.
3538

3639
========================================
3740
3. Changes in SAPI modules

Zend/Optimizer/zend_inference.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,8 @@ static void float_div(zend_long a, zend_long b, zend_long *r1, zend_long *r2) {
561561
}
562562

563563
static bool zend_inference_calc_binary_op_range(
564-
const zend_op_array *op_array, zend_ssa *ssa,
565-
zend_op *opline, zend_ssa_op *ssa_op, zend_uchar opcode, zend_ssa_range *tmp) {
564+
const zend_op_array *op_array, const zend_ssa *ssa,
565+
const zend_op *opline, const zend_ssa_op *ssa_op, zend_uchar opcode, zend_ssa_range *tmp) {
566566
zend_long op1_min, op2_min, op1_max, op2_max, t1, t2, t3, t4;
567567

568568
switch (opcode) {
@@ -845,22 +845,22 @@ static bool zend_inference_calc_binary_op_range(
845845
return 0;
846846
}
847847

848-
static bool zend_inference_calc_range(const zend_op_array *op_array, zend_ssa *ssa, int var, int widening, int narrowing, zend_ssa_range *tmp)
848+
static bool zend_inference_calc_range(const zend_op_array *op_array, const zend_ssa *ssa, int var, int widening, int narrowing, zend_ssa_range *tmp)
849849
{
850850
uint32_t line;
851-
zend_op *opline;
852-
zend_ssa_op *ssa_op;
851+
const zend_op *opline;
852+
const zend_ssa_op *ssa_op;
853853

854854
if (ssa->vars[var].definition_phi) {
855-
zend_ssa_phi *p = ssa->vars[var].definition_phi;
855+
const zend_ssa_phi *p = ssa->vars[var].definition_phi;
856856
int i;
857857

858858
tmp->underflow = 0;
859859
tmp->min = ZEND_LONG_MAX;
860860
tmp->max = ZEND_LONG_MIN;
861861
tmp->overflow = 0;
862862
if (p->pi >= 0 && p->has_range_constraint) {
863-
zend_ssa_range_constraint *constraint = &p->constraint.range;
863+
const zend_ssa_range_constraint *constraint = &p->constraint.range;
864864
if (constraint->negative) {
865865
int src1 = p->sources[0];
866866

@@ -879,7 +879,7 @@ static bool zend_inference_calc_range(const zend_op_array *op_array, zend_ssa *s
879879
case ZEND_PRE_DEC:
880880
case ZEND_POST_DEC:
881881
if (!tmp->underflow) {
882-
zend_ssa_phi *p = ssa->vars[ssa->ops[line].op1_use].definition_phi;
882+
const zend_ssa_phi *p = ssa->vars[ssa->ops[line].op1_use].definition_phi;
883883

884884
if (p && p->pi < 0
885885
&& ssa->cfg.blocks[p->block].predecessors_count == 2
@@ -893,7 +893,7 @@ static bool zend_inference_calc_range(const zend_op_array *op_array, zend_ssa *s
893893
case ZEND_PRE_INC:
894894
case ZEND_POST_INC:
895895
if (!tmp->overflow) {
896-
zend_ssa_phi *p = ssa->vars[ssa->ops[line].op1_use].definition_phi;
896+
const zend_ssa_phi *p = ssa->vars[ssa->ops[line].op1_use].definition_phi;
897897

898898
if (p && p->pi < 0
899899
&& ssa->cfg.blocks[p->block].predecessors_count == 2
@@ -1026,7 +1026,7 @@ static bool zend_inference_calc_range(const zend_op_array *op_array, zend_ssa *s
10261026
return zend_inference_propagate_range(op_array, ssa, opline, ssa_op, var, tmp);
10271027
}
10281028

1029-
ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp)
1029+
ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp)
10301030
{
10311031
tmp->underflow = 0;
10321032
tmp->overflow = 0;
@@ -1326,8 +1326,8 @@ ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, zend
13261326
case ZEND_DO_UCALL:
13271327
case ZEND_DO_FCALL_BY_NAME:
13281328
if (ssa_op->result_def == var) {
1329-
zend_func_info *func_info = ZEND_FUNC_INFO(op_array);
1330-
zend_call_info *call_info;
1329+
const zend_func_info *func_info = ZEND_FUNC_INFO(op_array);
1330+
const zend_call_info *call_info;
13311331
if (!func_info || !func_info->call_map) {
13321332
break;
13331333
}
@@ -1499,7 +1499,7 @@ static bool zend_check_inner_cycles(const zend_op_array *op_array, zend_ssa *ssa
14991499
}
15001500
#endif
15011501

1502-
static void zend_infer_ranges_warmup(const zend_op_array *op_array, zend_ssa *ssa, int *scc_var, int *next_scc_var, int scc)
1502+
static void zend_infer_ranges_warmup(const zend_op_array *op_array, zend_ssa *ssa, const int *scc_var, const int *next_scc_var, int scc)
15031503
{
15041504
int worklist_len = zend_bitset_len(ssa->vars_count);
15051505
int j, n;
@@ -2153,13 +2153,13 @@ static uint32_t zend_convert_type(const zend_script *script, zend_type type, zen
21532153
return tmp;
21542154
}
21552155

2156-
ZEND_API uint32_t zend_fetch_arg_info_type(const zend_script *script, zend_arg_info *arg_info, zend_class_entry **pce)
2156+
ZEND_API uint32_t zend_fetch_arg_info_type(const zend_script *script, const zend_arg_info *arg_info, zend_class_entry **pce)
21572157
{
21582158
return zend_convert_type(script, arg_info->type, pce);
21592159
}
21602160

2161-
static zend_property_info *lookup_prop_info(zend_class_entry *ce, zend_string *name, zend_class_entry *scope) {
2162-
zend_property_info *prop_info;
2161+
static const zend_property_info *lookup_prop_info(const zend_class_entry *ce, zend_string *name, zend_class_entry *scope) {
2162+
const zend_property_info *prop_info;
21632163

21642164
/* If the class is linked, reuse the precise runtime logic. */
21652165
if ((ce->ce_flags & ZEND_ACC_LINKED)
@@ -2185,11 +2185,11 @@ static zend_property_info *lookup_prop_info(zend_class_entry *ce, zend_string *n
21852185
return NULL;
21862186
}
21872187

2188-
static zend_property_info *zend_fetch_prop_info(const zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, zend_ssa_op *ssa_op)
2188+
static const zend_property_info *zend_fetch_prop_info(const zend_op_array *op_array, zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op)
21892189
{
2190-
zend_property_info *prop_info = NULL;
2190+
const zend_property_info *prop_info = NULL;
21912191
if (opline->op2_type == IS_CONST) {
2192-
zend_class_entry *ce = NULL;
2192+
const zend_class_entry *ce = NULL;
21932193

21942194
if (opline->op1_type == IS_UNUSED) {
21952195
ce = op_array->scope;
@@ -2208,9 +2208,9 @@ static zend_property_info *zend_fetch_prop_info(const zend_op_array *op_array, z
22082208
return prop_info;
22092209
}
22102210

2211-
static zend_property_info *zend_fetch_static_prop_info(const zend_script *script, const zend_op_array *op_array, zend_ssa *ssa, zend_op *opline)
2211+
static const zend_property_info *zend_fetch_static_prop_info(const zend_script *script, const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline)
22122212
{
2213-
zend_property_info *prop_info = NULL;
2213+
const zend_property_info *prop_info = NULL;
22142214
if (opline->op1_type == IS_CONST) {
22152215
zend_class_entry *ce = NULL;
22162216
if (opline->op2_type == IS_UNUSED) {
@@ -2244,7 +2244,7 @@ static zend_property_info *zend_fetch_static_prop_info(const zend_script *script
22442244
return prop_info;
22452245
}
22462246

2247-
static uint32_t zend_fetch_prop_type(const zend_script *script, zend_property_info *prop_info, zend_class_entry **pce)
2247+
static uint32_t zend_fetch_prop_type(const zend_script *script, const zend_property_info *prop_info, zend_class_entry **pce)
22482248
{
22492249
if (!prop_info) {
22502250
if (pce) {
@@ -2280,7 +2280,7 @@ static zend_always_inline zend_result _zend_update_type_info(
22802280
zend_ssa *ssa,
22812281
const zend_script *script,
22822282
zend_bitset worklist,
2283-
zend_op *opline,
2283+
const zend_op *opline,
22842284
zend_ssa_op *ssa_op,
22852285
const zend_op **ssa_opcodes,
22862286
zend_long optimization_level,
@@ -2490,7 +2490,7 @@ static zend_always_inline zend_result _zend_update_type_info(
24902490
case ZEND_ASSIGN_OBJ_OP:
24912491
case ZEND_ASSIGN_STATIC_PROP_OP:
24922492
{
2493-
zend_property_info *prop_info = NULL;
2493+
const zend_property_info *prop_info = NULL;
24942494
orig = 0;
24952495
tmp = 0;
24962496
if (opline->opcode == ZEND_ASSIGN_OBJ_OP) {
@@ -3454,13 +3454,13 @@ static zend_always_inline zend_result _zend_update_type_info(
34543454
tmp |= MAY_BE_NULL;
34553455
}
34563456
if (opline->op1_type == IS_UNUSED || (t1 & MAY_BE_OBJECT)) {
3457-
zend_property_info *prop_info = zend_fetch_prop_info(op_array, ssa, opline, ssa_op);
3457+
const zend_property_info *prop_info = zend_fetch_prop_info(op_array, ssa, opline, ssa_op);
34583458
tmp |= zend_fetch_prop_type(script, prop_info, &ce);
34593459
if (opline->opcode != ZEND_FETCH_OBJ_R && opline->opcode != ZEND_FETCH_OBJ_IS) {
34603460
tmp |= MAY_BE_REF | MAY_BE_INDIRECT;
34613461
ce = NULL;
34623462
} else if (!(opline->op1_type & (IS_VAR|IS_TMP_VAR)) || !(t1 & MAY_BE_RC1)) {
3463-
zend_class_entry *ce = NULL;
3463+
const zend_class_entry *ce = NULL;
34643464

34653465
if (opline->op1_type == IS_UNUSED) {
34663466
ce = op_array->scope;
@@ -4487,7 +4487,7 @@ ZEND_API zend_result zend_ssa_inference(zend_arena **arena, const zend_op_array
44874487
}
44884488
/* }}} */
44894489

4490-
ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, uint32_t t1, uint32_t t2)
4490+
ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, const zend_ssa *ssa, uint32_t t1, uint32_t t2)
44914491
{
44924492
if (opline->op1_type == IS_CV) {
44934493
if (t1 & MAY_BE_UNDEF) {
@@ -4765,8 +4765,8 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
47654765
}
47664766
}
47674767
if (ssa_op->op1_use) {
4768-
zend_ssa_var_info *var_info = ssa->var_info + ssa_op->op1_use;
4769-
zend_class_entry *ce = var_info->ce;
4768+
const zend_ssa_var_info *var_info = ssa->var_info + ssa_op->op1_use;
4769+
const zend_class_entry *ce = var_info->ce;
47704770

47714771
if (var_info->is_instanceof ||
47724772
!ce || ce->create_object || ce->__get || ce->__set || ce->parent) {
@@ -4813,7 +4813,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
48134813
}
48144814
if (op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
48154815
uint32_t arg_num = opline->op1.num;
4816-
zend_arg_info *cur_arg_info;
4816+
const zend_arg_info *cur_arg_info;
48174817

48184818
if (EXPECTED(arg_num <= op_array->num_args)) {
48194819
cur_arg_info = &op_array->arg_info[arg_num-1];
@@ -4889,7 +4889,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
48894889
}
48904890
}
48914891

4892-
ZEND_API bool zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa)
4892+
ZEND_API bool zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, const zend_ssa *ssa)
48934893
{
48944894
return zend_may_throw_ex(opline, ssa_op, op_array, ssa, OP1_INFO(), OP2_INFO());
48954895
}

Zend/Optimizer/zend_inference.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,18 @@ ZEND_API int zend_ssa_inference(zend_arena **raena, const zend_op_array *op_arra
222222

223223
ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert);
224224

225-
ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp);
225+
ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp);
226226

227227
ZEND_API uint32_t zend_fetch_arg_info_type(
228-
const zend_script *script, zend_arg_info *arg_info, zend_class_entry **pce);
228+
const zend_script *script, const zend_arg_info *arg_info, zend_class_entry **pce);
229229
ZEND_API void zend_init_func_return_info(
230230
const zend_op_array *op_array, const zend_script *script, zend_ssa_var_info *ret);
231231
uint32_t zend_get_return_info_from_signature_only(
232232
const zend_function *func, const zend_script *script,
233233
zend_class_entry **ce, bool *ce_is_instanceof, bool use_tentative_return_info);
234234

235-
ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, uint32_t t1, uint32_t t2);
236-
ZEND_API bool zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa);
235+
ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, const zend_ssa *ssa, uint32_t t1, uint32_t t2);
236+
ZEND_API bool zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, const zend_ssa *ssa);
237237

238238
ZEND_API zend_result zend_update_type_info(
239239
const zend_op_array *op_array, zend_ssa *ssa, const zend_script *script,

Zend/Optimizer/zend_ssa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ static bool will_rejoin(
5757
return 0;
5858
}
5959

60-
static bool needs_pi(const zend_op_array *op_array, zend_dfg *dfg, zend_ssa *ssa, int from, int to, int var) /* {{{ */
60+
static bool needs_pi(const zend_op_array *op_array, const zend_dfg *dfg, const zend_ssa *ssa, int from, int to, int var) /* {{{ */
6161
{
62-
zend_basic_block *from_block, *to_block;
62+
const zend_basic_block *from_block, *to_block;
6363
int other_successor;
6464

6565
if (!DFG_ISSET(dfg->in, dfg->size, to, var)) {

Zend/tests/gh10200.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
GH-10200 (zif_get_object_vars: Assertion `!(((__ht)->u.flags & (1<<2)) != 0)' failed.)
3+
--EXTENSIONS--
4+
simplexml
35
--FILE--
46
<?php
57

Zend/zend_API.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32
477477
return !EG(exception);
478478
}
479479

480-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
480+
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(const zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
481481
{
482482
if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
483483
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("bool", arg_num)) {
@@ -491,7 +491,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, bool *dest, uint
491491
}
492492
/* }}} */
493493

494-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
494+
ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(const zval *arg, bool *dest, uint32_t arg_num) /* {{{ */
495495
{
496496
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
497497
return 0;
@@ -500,7 +500,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, bool *dest, uint
500500
}
501501
/* }}} */
502502

503-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, uint32_t arg_num) /* {{{ */
503+
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, zend_long *dest, uint32_t arg_num) /* {{{ */
504504
{
505505
if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
506506
if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) {
@@ -570,7 +570,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest,
570570
}
571571
/* }}} */
572572

573-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest, uint32_t arg_num) /* {{{ */
573+
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(const zval *arg, zend_long *dest, uint32_t arg_num) /* {{{ */
574574
{
575575
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
576576
return 0;
@@ -579,7 +579,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest,
579579
}
580580
/* }}} */
581581

582-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest, uint32_t arg_num) /* {{{ */
582+
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(const zval *arg, double *dest, uint32_t arg_num) /* {{{ */
583583
{
584584
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
585585
*dest = (double)Z_LVAL_P(arg);
@@ -611,7 +611,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest,
611611
}
612612
/* }}} */
613613

614-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest, uint32_t arg_num) /* {{{ */
614+
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(const zval *arg, double *dest, uint32_t arg_num) /* {{{ */
615615
{
616616
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
617617
/* SSTH Exception: IS_LONG may be accepted instead as IS_DOUBLE */
@@ -4904,7 +4904,7 @@ ZEND_API ZEND_COLD const char *zend_get_object_type_case(const zend_class_entry
49044904
}
49054905
/* }}} */
49064906

4907-
ZEND_API bool zend_is_iterable(zval *iterable) /* {{{ */
4907+
ZEND_API bool zend_is_iterable(const zval *iterable) /* {{{ */
49084908
{
49094909
switch (Z_TYPE_P(iterable)) {
49104910
case IS_ARRAY:
@@ -4917,7 +4917,7 @@ ZEND_API bool zend_is_iterable(zval *iterable) /* {{{ */
49174917
}
49184918
/* }}} */
49194919

4920-
ZEND_API bool zend_is_countable(zval *countable) /* {{{ */
4920+
ZEND_API bool zend_is_countable(const zval *countable) /* {{{ */
49214921
{
49224922
switch (Z_TYPE_P(countable)) {
49234923
case IS_ARRAY:

0 commit comments

Comments
 (0)