Skip to content

Commit 03b9359

Browse files
committed
Flip is_lax to is_strict
1 parent 9b16025 commit 03b9359

File tree

7 files changed

+29
-30
lines changed

7 files changed

+29
-30
lines changed

Zend/zend_compile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7695,7 +7695,7 @@ static void zend_compile_enum_case(zend_ast *ast)
76957695
}
76967696

76977697
if (enum_class->enum_backing_type != Z_TYPE(case_value_zv)) {
7698-
zend_error_noreturn(E_COMPILE_ERROR, "Enum case type %s does not match enum backing type %s",
7698+
zend_error_noreturn(E_COMPILE_ERROR, "Enum case type %s does not match enum backing type %s",
76997699
zend_get_type_by_const(Z_TYPE(case_value_zv)),
77007700
zend_get_type_by_const(enum_class->enum_backing_type));
77017701
}
@@ -8148,12 +8148,12 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op
81488148
return 1;
81498149
}
81508150

8151-
if ((opcode == ZEND_MOD && zval_get_long_func(op2, /* lax */ true) == 0)
8151+
if ((opcode == ZEND_MOD && zval_get_long(op2) == 0)
81528152
|| (opcode == ZEND_DIV && zval_get_double(op2) == 0.0)) {
81538153
/* Division by zero throws an error. */
81548154
return 1;
81558155
}
8156-
if ((opcode == ZEND_SL || opcode == ZEND_SR) && zval_get_long_func(op2, /* lax */ true) < 0) {
8156+
if ((opcode == ZEND_SL || opcode == ZEND_SR) && zval_get_long(op2) < 0) {
81578157
/* Shift by negative number throws an error. */
81588158
return 1;
81598159
}

Zend/zend_execute.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type
14461446
break;
14471447
}
14481448

1449-
offset = zval_get_long_func(dim, /* lax */ true);
1449+
offset = zval_get_long_func(dim, /* is_strict */ false);
14501450
} else {
14511451
offset = Z_LVAL_P(dim);
14521452
}
@@ -2420,7 +2420,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
24202420
break;
24212421
}
24222422

2423-
offset = zval_get_long_func(dim, /* is_lax */ true);
2423+
offset = zval_get_long_func(dim, /* is_strict */ false);
24242424
} else {
24252425
offset = Z_LVAL_P(dim);
24262426
}
@@ -2565,7 +2565,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container,
25652565
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
25662566
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
25672567
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
2568-
lval = zval_get_long_ex(offset, /* is_lax */ false);
2568+
lval = zval_get_long_ex(offset, /* is_strict */ true);
25692569
goto str_offset;
25702570
}
25712571
return 0;
@@ -2604,7 +2604,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *containe
26042604
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
26052605
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
26062606
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
2607-
lval = zval_get_long_ex(offset, /* is_lax */ false);
2607+
lval = zval_get_long_ex(offset, /* is_strict */ true);
26082608
goto str_offset;
26092609
}
26102610
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
@@ -5223,7 +5223,7 @@ ZEND_VM_C_LABEL(send_array):
52235223
zval *op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
52245224
uint32_t skip = opline->extended_value;
52255225
uint32_t count = zend_hash_num_elements(ht);
5226-
zend_long len = zval_get_long_ex(op2, /* is_lax */ false);
5226+
zend_long len = zval_get_long_ex(op2, /* is_strict */ true);
52275227

52285228
if (len < 0) {
52295229
len += (zend_long)(count - skip);
@@ -9021,7 +9021,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED)
90219021
zval retval;
90229022

90239023
zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
9024-
// TODO Should this use zval_get_long_ex(&retval, /* is lax */ false);
9024+
// TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false);
90259025
count = zval_get_long(&retval);
90269026
zval_ptr_dtor(&retval);
90279027
break;
@@ -9594,7 +9594,7 @@ ZEND_VM_C_LABEL(fetch_dim_r_index_array):
95949594
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
95959595
offset = Z_LVAL_P(dim);
95969596
} else {
9597-
offset = zval_get_long_ex(dim, /* is_lax */ false);
9597+
offset = zval_get_long_ex(dim, /* is_strict */ true);
95989598
}
95999599
ht = Z_ARRVAL_P(container);
96009600
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;
@@ -42545,7 +42545,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_
4254542545
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
4254642546
offset = Z_LVAL_P(dim);
4254742547
} else {
42548-
offset = zval_get_long_ex(dim, /* is_lax */ false);
42548+
offset = zval_get_long_ex(dim, /* is_strict */ true);
4254942549
}
4255042550
ht = Z_ARRVAL_P(container);
4255142551
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -42597,7 +42597,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_
4259742597
if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) {
4259842598
offset = Z_LVAL_P(dim);
4259942599
} else {
42600-
offset = zval_get_long_ex(dim, /* is_lax */ false);
42600+
offset = zval_get_long_ex(dim, /* is_strict */ true);
4260142601
}
4260242602
ht = Z_ARRVAL_P(container);
4260342603
ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef);
@@ -47539,7 +47539,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z
4753947539
zval retval;
4754047540

4754147541
zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval);
47542-
// TODO Should this use zval_get_long_ex(&retval, /* is lax */ false);
47542+
// TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false);
4754347543
count = zval_get_long(&retval);
4754447544
zval_ptr_dtor(&retval);
4754547545
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)