Skip to content

Commit 393aa51

Browse files
committed
Added Nikita's suggestion
1 parent f03663f commit 393aa51

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

Zend/tests/falsetoarray.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ $false[] = 42;
107107
print "[021]\n";
108108
$false2[] = 42;
109109

110+
print "[022]\n";
111+
$a = false;
112+
unset($a[0][0]);
113+
114+
print "[023]\n";
115+
$a = false;
116+
unset($a[0]);
117+
110118
?>
111119
--EXPECTF--
112120
[001]
@@ -177,4 +185,10 @@ Deprecated: Automatic conversion of false to array is deprecated in %s
177185
Deprecated: Automatic conversion of false to array is deprecated in %s
178186
[021]
179187

180-
Deprecated: Automatic conversion of false to array is deprecated in %s
188+
Deprecated: Automatic conversion of false to array is deprecated in %s
189+
[022]
190+
191+
Deprecated: Automatic conversion of false to array is deprecated in %s
192+
[023]
193+
194+
Deprecated: Unsetting offset in a false variable is deprecated in %s

Zend/zend_execute.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,10 +2344,10 @@ static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *
23442344
if (type != BP_VAR_W && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
23452345
ZVAL_UNDEFINED_OP1();
23462346
}
2347+
if (Z_TYPE_P(container) == IS_FALSE) {
2348+
zend_error(E_DEPRECATED, "Automatic conversion of false to array is deprecated");
2349+
}
23472350
if (type != BP_VAR_UNSET) {
2348-
if (Z_TYPE_P(container) == IS_FALSE) {
2349-
zend_error(E_DEPRECATED, "Automatic conversion of false to array is deprecated");
2350-
}
23512351
array_init(container);
23522352
goto fetch_from_array;
23532353
} else {

Zend/zend_vm_def.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6471,6 +6471,8 @@ ZEND_VM_C_LABEL(num_index_dim):
64716471
zend_throw_error(NULL, "Cannot unset string offsets");
64726472
} else if (UNEXPECTED(Z_TYPE_P(container) > IS_FALSE)) {
64736473
zend_throw_error(NULL, "Cannot unset offset in a non-array variable");
6474+
} else if (UNEXPECTED(Z_TYPE_P(container) == IS_FALSE)) {
6475+
zend_error(E_DEPRECATED, "Unsetting offset in a false variable is deprecated");
64746476
}
64756477
} while (0);
64766478

Zend/zend_vm_execute.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24589,6 +24589,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDL
2458924589
zend_throw_error(NULL, "Cannot unset string offsets");
2459024590
} else if (UNEXPECTED(Z_TYPE_P(container) > IS_FALSE)) {
2459124591
zend_throw_error(NULL, "Cannot unset offset in a non-array variable");
24592+
} else if (UNEXPECTED(Z_TYPE_P(container) == IS_FALSE)) {
24593+
zend_error(E_DEPRECATED, "Unsetting offset in a false variable is deprecated");
2459224594
}
2459324595
} while (0);
2459424596

@@ -26785,6 +26787,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMPVAR_HAND
2678526787
zend_throw_error(NULL, "Cannot unset string offsets");
2678626788
} else if (UNEXPECTED(Z_TYPE_P(container) > IS_FALSE)) {
2678726789
zend_throw_error(NULL, "Cannot unset offset in a non-array variable");
26790+
} else if (UNEXPECTED(Z_TYPE_P(container) == IS_FALSE)) {
26791+
zend_error(E_DEPRECATED, "Unsetting offset in a false variable is deprecated");
2678826792
}
2678926793
} while (0);
2679026794

@@ -30825,6 +30829,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(
3082530829
zend_throw_error(NULL, "Cannot unset string offsets");
3082630830
} else if (UNEXPECTED(Z_TYPE_P(container) > IS_FALSE)) {
3082730831
zend_throw_error(NULL, "Cannot unset offset in a non-array variable");
30832+
} else if (UNEXPECTED(Z_TYPE_P(container) == IS_FALSE)) {
30833+
zend_error(E_DEPRECATED, "Unsetting offset in a false variable is deprecated");
3082830834
}
3082930835
} while (0);
3083030836

@@ -42089,6 +42095,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLE
4208942095
zend_throw_error(NULL, "Cannot unset string offsets");
4209042096
} else if (UNEXPECTED(Z_TYPE_P(container) > IS_FALSE)) {
4209142097
zend_throw_error(NULL, "Cannot unset offset in a non-array variable");
42098+
} else if (UNEXPECTED(Z_TYPE_P(container) == IS_FALSE)) {
42099+
zend_error(E_DEPRECATED, "Unsetting offset in a false variable is deprecated");
4209242100
}
4209342101
} while (0);
4209442102

@@ -45578,6 +45586,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMPVAR_HANDL
4557845586
zend_throw_error(NULL, "Cannot unset string offsets");
4557945587
} else if (UNEXPECTED(Z_TYPE_P(container) > IS_FALSE)) {
4558045588
zend_throw_error(NULL, "Cannot unset offset in a non-array variable");
45589+
} else if (UNEXPECTED(Z_TYPE_P(container) == IS_FALSE)) {
45590+
zend_error(E_DEPRECATED, "Unsetting offset in a false variable is deprecated");
4558145591
}
4558245592
} while (0);
4558345593

@@ -50723,6 +50733,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(Z
5072350733
zend_throw_error(NULL, "Cannot unset string offsets");
5072450734
} else if (UNEXPECTED(Z_TYPE_P(container) > IS_FALSE)) {
5072550735
zend_throw_error(NULL, "Cannot unset offset in a non-array variable");
50736+
} else if (UNEXPECTED(Z_TYPE_P(container) == IS_FALSE)) {
50737+
zend_error(E_DEPRECATED, "Unsetting offset in a false variable is deprecated");
5072650738
}
5072750739
} while (0);
5072850740

0 commit comments

Comments
 (0)