Skip to content

Commit 07a1efb

Browse files
committed
Flip is_lax to is_strict
1 parent baa50d5 commit 07a1efb

File tree

7 files changed

+28
-29
lines changed

7 files changed

+28
-29
lines changed

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8176,12 +8176,12 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op
81768176
return 1;
81778177
}
81788178

8179-
if ((opcode == ZEND_MOD && zval_get_long_func(op2, /* lax */ true) == 0)
8179+
if ((opcode == ZEND_MOD && zval_get_long(op2) == 0)
81808180
|| (opcode == ZEND_DIV && zval_get_double(op2) == 0.0)) {
81818181
/* Division by zero throws an error. */
81828182
return 1;
81838183
}
8184-
if ((opcode == ZEND_SL || opcode == ZEND_SR) && zval_get_long_func(op2, /* lax */ true) < 0) {
8184+
if ((opcode == ZEND_SL || opcode == ZEND_SR) && zval_get_long(op2) < 0) {
81858185
/* Shift by negative number throws an error. */
81868186
return 1;
81878187
}

Zend/zend_execute.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type
14561456
break;
14571457
}
14581458

1459-
offset = zval_get_long_func(dim, /* lax */ true);
1459+
offset = zval_get_long_func(dim, /* is_strict */ false);
14601460
} else {
14611461
offset = Z_LVAL_P(dim);
14621462
}
@@ -2430,7 +2430,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
24302430
break;
24312431
}
24322432

2433-
offset = zval_get_long_func(dim, /* is_lax */ true);
2433+
offset = zval_get_long_func(dim, /* is_strict */ false);
24342434
} else {
24352435
offset = Z_LVAL_P(dim);
24362436
}
@@ -2575,7 +2575,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container,
25752575
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
25762576
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
25772577
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
2578-
lval = zval_get_long_ex(offset, /* is_lax */ false);
2578+
lval = zval_get_long_ex(offset, /* is_strict */ true);
25792579
goto str_offset;
25802580
}
25812581
return 0;
@@ -2614,7 +2614,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *containe
26142614
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
26152615
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
26162616
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
2617-
lval = zval_get_long_ex(offset, /* is_lax */ false);
2617+
lval = zval_get_long_ex(offset, /* is_strict */ true);
26182618
goto str_offset;
26192619
}
26202620
return 1;

Zend/zend_operators.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo
342342
* We use use saturating conversion to emulate strtol()'s
343343
* behaviour.
344344
*/
345-
lval = zend_dval_to_lval_cap(dval);
345+
lval = zend_dval_to_lval_cap(dval);
346346
if (!zend_is_long_compatible(dval, lval)) {
347347
zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s",
348348
Z_STRVAL_P(op));
@@ -448,7 +448,6 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo
448448
} \
449449
} while (0);
450450

451-
/* TODO Should this warn? */
452451
ZEND_API void ZEND_FASTCALL convert_to_long(zval *op) /* {{{ */
453452
{
454453
zend_long tmp;
@@ -810,7 +809,7 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */
810809
}
811810
/* }}} */
812811

813-
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{{ */
812+
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* {{{ */
814813
{
815814
try_again:
816815
switch (Z_TYPE_P(op)) {
@@ -827,7 +826,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{
827826
case IS_DOUBLE: {
828827
double dval = Z_DVAL_P(op);
829828
zend_long lval = zend_dval_to_lval(dval);
830-
if (EXPECTED(!is_lax)) {
829+
if (UNEXPECTED(is_strict)) {
831830
if (!zend_is_long_compatible(dval, lval)) {
832831
zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", dval);
833832
// TODO Need to handle this here?
@@ -853,7 +852,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{
853852
*/
854853
/* Most usages are expected to not be (int) casts */
855854
lval = zend_dval_to_lval_cap(dval);
856-
if (EXPECTED(!is_lax)) {
855+
if (UNEXPECTED(is_strict)) {
857856
if (!zend_is_long_compatible(dval, lval)) {
858857
zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s",
859858
Z_STRVAL_P(op));

Zend/zend_operators.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,16 @@ ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op);
281281
ZEND_API void ZEND_FASTCALL convert_to_array(zval *op);
282282
ZEND_API void ZEND_FASTCALL convert_to_object(zval *op);
283283

284-
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax);
284+
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict);
285285
ZEND_API double ZEND_FASTCALL zval_get_double_func(zval *op);
286286
ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op);
287287
ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op);
288288

289289
static zend_always_inline zend_long zval_get_long(zval *op) {
290-
return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, true);
290+
return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, false);
291291
}
292-
static zend_always_inline zend_long zval_get_long_ex(zval *op, bool is_lax) {
293-
return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, is_lax);
292+
static zend_always_inline zend_long zval_get_long_ex(zval *op, bool is_strict) {
293+
return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, is_strict);
294294
}
295295
static zend_always_inline double zval_get_double(zval *op) {
296296
return EXPECTED(Z_TYPE_P(op) == IS_DOUBLE) ? Z_DVAL_P(op) : zval_get_double_func(op);

Zend/zend_vm_def.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5230,7 +5230,7 @@ ZEND_VM_C_LABEL(send_array):
52305230
zval *op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
52315231
uint32_t skip = opline->extended_value;
52325232
uint32_t count = zend_hash_num_elements(ht);
5233-
zend_long len = zval_get_long_ex(op2, /* is_lax */ false);
5233+
zend_long len = zval_get_long_ex(op2, /* is_strict */ true);
52345234

52355235
if (len < 0) {
52365236
len += (zend_long)(count - skip);
@@ -9028,7 +9028,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED)
90289028
zval retval;
90299029

90309030
zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
9031-
// TODO Should this use zval_get_long_ex(&retval, /* is lax */ false);
9031+
// TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false);
90329032
count = zval_get_long(&retval);
90339033
zval_ptr_dtor(&retval);
90349034
break;
@@ -9601,7 +9601,7 @@ ZEND_VM_C_LABEL(fetch_dim_r_index_array):
96019601
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
96029602
offset = Z_LVAL_P(dim);
96039603
} else {
9604-
offset = zval_get_long_ex(dim, /* is_lax */ false);
9604+
offset = zval_get_long_ex(dim, /* is_strict */ true);
96059605
}
96069606
ht = Z_ARRVAL_P(container);
96079607
ZEND_HASH_INDEX_FIND(ht, offset, value, ZEND_VM_C_LABEL(fetch_dim_r_index_undef));

Zend/zend_vm_execute.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,7 +2337,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O
23372337
zval *op2 = get_zval_ptr(opline->op2_type, opline->op2, BP_VAR_R);
23382338
uint32_t skip = opline->extended_value;
23392339
uint32_t count = zend_hash_num_elements(ht);
2340-
zend_long len = zval_get_long_ex(op2, /* is_lax */ false);
2340+
zend_long len = zval_get_long_ex(op2, /* is_strict */ true);
23412341

23422342
if (len < 0) {
23432343
len += (zend_long)(count - skip);
@@ -8294,7 +8294,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_
82948294
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
82958295
offset = Z_LVAL_P(dim);
82968296
} else {
8297-
offset = zval_get_long_ex(dim, /* is_lax */ false);
8297+
offset = zval_get_long_ex(dim, /* is_strict */ true);
82988298
}
82998299
ht = Z_ARRVAL_P(container);
83008300
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -10528,7 +10528,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_
1052810528
zval retval;
1052910529

1053010530
zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
10531-
// TODO Should this use zval_get_long_ex(&retval, /* is lax */ false);
10531+
// TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false);
1053210532
count = zval_get_long(&retval);
1053310533
zval_ptr_dtor(&retval);
1053410534
break;
@@ -16089,7 +16089,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_
1608916089
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
1609016090
offset = Z_LVAL_P(dim);
1609116091
} else {
16092-
offset = zval_get_long_ex(dim, /* is_lax */ false);
16092+
offset = zval_get_long_ex(dim, /* is_strict */ true);
1609316093
}
1609416094
ht = Z_ARRVAL_P(container);
1609516095
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -16141,7 +16141,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_
1614116141
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
1614216142
offset = Z_LVAL_P(dim);
1614316143
} else {
16144-
offset = zval_get_long_ex(dim, /* is_lax */ false);
16144+
offset = zval_get_long_ex(dim, /* is_strict */ true);
1614516145
}
1614616146
ht = Z_ARRVAL_P(container);
1614716147
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -17783,7 +17783,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL
1778317783
zval retval;
1778417784

1778517785
zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
17786-
// TODO Should this use zval_get_long_ex(&retval, /* is lax */ false);
17786+
// TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false);
1778717787
count = zval_get_long(&retval);
1778817788
zval_ptr_dtor(&retval);
1778917789
break;
@@ -42552,7 +42552,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_
4255242552
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
4255342553
offset = Z_LVAL_P(dim);
4255442554
} else {
42555-
offset = zval_get_long_ex(dim, /* is_lax */ false);
42555+
offset = zval_get_long_ex(dim, /* is_strict */ true);
4255642556
}
4255742557
ht = Z_ARRVAL_P(container);
4255842558
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -42604,7 +42604,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_
4260442604
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
4260542605
offset = Z_LVAL_P(dim);
4260642606
} else {
42607-
offset = zval_get_long_ex(dim, /* is_lax */ false);
42607+
offset = zval_get_long_ex(dim, /* is_strict */ true);
4260842608
}
4260942609
ht = Z_ARRVAL_P(container);
4261042610
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -47546,7 +47546,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z
4754647546
zval retval;
4754747547

4754847548
zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
47549-
// TODO Should this use zval_get_long_ex(&retval, /* is lax */ false);
47549+
// TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false);
4755047550
count = zval_get_long(&retval);
4755147551
zval_ptr_dtor(&retval);
4755247552
break;

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim/*, int typ
732732
break;
733733
}
734734

735-
return zval_get_long_func(dim, /* is_lax */ true);
735+
return zval_get_long_func(dim, /* is_strict */ false);
736736
}
737737

738738
static zend_always_inline zend_string* zend_jit_fetch_dim_str_offset(zend_string *str, zend_long offset)
@@ -799,7 +799,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zend_string *str, zva
799799
break;
800800
}
801801

802-
offset = zval_get_long_func(dim, /* is_lax */ true);
802+
offset = zval_get_long_func(dim, /* is_strict */ false);
803803
} else {
804804
offset = Z_LVAL_P(dim);
805805
}

0 commit comments

Comments
 (0)