Skip to content

Commit bab7581

Browse files
Handle numeric strings
1 parent 14bfe93 commit bab7581

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

Zend/tests/list_keyed_constants.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $arr = [
1010

1111
const COMPILE_TIME_RESOLVABLE = 1;
1212

13-
define('PROBABLY_NOT_COMPILE_TIME_RESOLVABLE', (int)file_get_contents("data:text/plain,2"));
13+
define('PROBABLY_NOT_COMPILE_TIME_RESOLVABLE', file_get_contents("data:text/plain,2"));
1414

1515
list(
1616
COMPILE_TIME_RESOLVABLE => $one,

Zend/tests/list_keyed_conversions.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ $results = [
1212
list(NULL => $NULL, 1.5 => $float, FALSE => $FALSE, TRUE => $TRUE) = $results;
1313
var_dump($NULL, $float, $FALSE, $TRUE);
1414

15+
echo PHP_EOL;
16+
17+
list("0" => $zeroString, "1" => $oneString) = $results;
18+
var_dump($zeroString, $oneString);
19+
1520
list(STDIN => $resource) = [];
1621

1722
?>
@@ -21,4 +26,7 @@ int(1)
2126
int(0)
2227
int(1)
2328

29+
int(0)
30+
int(1)
31+
2432
Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d

Zend/zend_vm_def.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,11 @@ ZEND_VM_C_LABEL(num_index_list):
20932093
}
20942094
} else if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
20952095
str = Z_STR_P(offset);
2096+
2097+
if (ZEND_HANDLE_NUMERIC(str, hval)) {
2098+
ZEND_VM_C_GOTO(num_index_list);
2099+
}
2100+
20962101
ZEND_VM_C_LABEL(str_index_list):
20972102
value = zend_hash_find(Z_ARRVAL_P(container), str);
20982103

Zend/zend_vm_execute.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5773,6 +5773,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_CONST_CONST_HA
57735773
}
57745774
} else if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
57755775
str = Z_STR_P(offset);
5776+
5777+
if (ZEND_HANDLE_NUMERIC(str, hval)) {
5778+
goto num_index_list;
5779+
}
5780+
57765781
str_index_list:
57775782
value = zend_hash_find(Z_ARRVAL_P(container), str);
57785783

@@ -11387,6 +11392,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_CONST_TMPVAR_H
1138711392
}
1138811393
} else if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
1138911394
str = Z_STR_P(offset);
11395+
11396+
if (ZEND_HANDLE_NUMERIC(str, hval)) {
11397+
goto num_index_list;
11398+
}
11399+
1139011400
str_index_list:
1139111401
value = zend_hash_find(Z_ARRVAL_P(container), str);
1139211402

@@ -38022,6 +38032,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_CV_CONST_HANDL
3802238032
}
3802338033
} else if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
3802438034
str = Z_STR_P(offset);
38035+
38036+
if (ZEND_HANDLE_NUMERIC(str, hval)) {
38037+
goto num_index_list;
38038+
}
38039+
3802538040
str_index_list:
3802638041
value = zend_hash_find(Z_ARRVAL_P(container), str);
3802738042

@@ -48006,6 +48021,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_CV_TMPVAR_HAND
4800648021
}
4800748022
} else if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
4800848023
str = Z_STR_P(offset);
48024+
48025+
if (ZEND_HANDLE_NUMERIC(str, hval)) {
48026+
goto num_index_list;
48027+
}
48028+
4800948029
str_index_list:
4801048030
value = zend_hash_find(Z_ARRVAL_P(container), str);
4801148031

@@ -51309,6 +51329,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_TMPVAR_CONST_H
5130951329
}
5131051330
} else if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
5131151331
str = Z_STR_P(offset);
51332+
51333+
if (ZEND_HANDLE_NUMERIC(str, hval)) {
51334+
goto num_index_list;
51335+
}
51336+
5131251337
str_index_list:
5131351338
value = zend_hash_find(Z_ARRVAL_P(container), str);
5131451339

@@ -54793,6 +54818,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_LIST_SPEC_TMPVAR_TMPVAR_
5479354818
}
5479454819
} else if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
5479554820
str = Z_STR_P(offset);
54821+
54822+
if (ZEND_HANDLE_NUMERIC(str, hval)) {
54823+
goto num_index_list;
54824+
}
54825+
5479654826
str_index_list:
5479754827
value = zend_hash_find(Z_ARRVAL_P(container), str);
5479854828

0 commit comments

Comments
 (0)