diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-09-27 10:49:25 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-09-27 10:49:25 +0200 |
commit | 34e7c2daf034af8a3054966c1029f04dc9cec5f2 (patch) | |
tree | ed6ff1fcee2df51f1786a5616d6093568e522c59 | |
parent | a66c60cce3cd8878284fb39388080cfb6bac8ff5 (diff) | |
parent | a6c9c7c2b8cfd4db8fcdcb66b908feac31b600af (diff) | |
download | php-git-34e7c2daf034af8a3054966c1029f04dc9cec5f2.tar.gz |
Merge branch 'PHP-7.4'
-rw-r--r-- | Zend/zend_vm_def.h | 4 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 64 | ||||
-rw-r--r-- | ext/opcache/Optimizer/zend_inference.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/array/array_combine_variation4.phpt | 12 | ||||
-rw-r--r-- | ext/standard/tests/array/array_map_variation4.phpt | 16 | ||||
-rw-r--r-- | ext/standard/tests/array/array_merge_recursive_variation4.phpt | 18 | ||||
-rw-r--r-- | ext/standard/tests/array/array_reverse_variation4.phpt | 28 | ||||
-rw-r--r-- | ext/standard/tests/array/array_unique_variation3.phpt | 8 | ||||
-rw-r--r-- | ext/standard/tests/array/array_unshift_variation4.phpt | 32 | ||||
-rwxr-xr-x | scripts/dev/bless_tests.php | 4 |
10 files changed, 147 insertions, 41 deletions
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index c2b7df4a18..22d302f9c0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -5694,6 +5694,10 @@ ZEND_VM_C_LABEL(num_index): } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; ZEND_VM_C_GOTO(num_index); + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + ZEND_VM_C_GOTO(num_index); } else if (OP2_TYPE == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index f533d525d0..4b27d0d26a 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -6119,6 +6119,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_CONST == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -8291,6 +8295,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -9244,6 +9252,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_UNUSED == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -10714,6 +10726,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_CV == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -18671,6 +18687,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_CONST == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -19087,6 +19107,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -19575,6 +19599,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_UNUSED == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -19970,6 +19998,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_CV == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -23830,6 +23862,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_CONST == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -26051,6 +26087,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -27639,6 +27679,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_UNUSED == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -29838,6 +29882,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_CV == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -41447,6 +41495,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_CONST == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -44968,6 +45020,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -46693,6 +46749,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_UNUSED == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); @@ -50189,6 +50249,10 @@ num_index: } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; goto num_index; + } else if (Z_TYPE_P(offset) == IS_RESOURCE) { + zend_use_resource_as_offset(offset); + hval = Z_RES_HANDLE_P(offset); + goto num_index; } else if (IS_CV == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); str = ZSTR_EMPTY_ALLOC(); diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index db5107af60..6f40388917 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -3242,7 +3242,7 @@ static int zend_update_type_info(const zend_op_array *op_array, if (opline->op2_type == IS_UNUSED) { tmp |= MAY_BE_ARRAY_KEY_LONG; } else { - if (t2 & (MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_DOUBLE)) { + if (t2 & (MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_DOUBLE|MAY_BE_RESOURCE)) { tmp |= MAY_BE_ARRAY_KEY_LONG; } if (t2 & (MAY_BE_STRING)) { diff --git a/ext/standard/tests/array/array_combine_variation4.phpt b/ext/standard/tests/array/array_combine_variation4.phpt index dd3187a1f0..a7ea0a9dc4 100644 --- a/ext/standard/tests/array/array_combine_variation4.phpt +++ b/ext/standard/tests/array/array_combine_variation4.phpt @@ -92,11 +92,11 @@ echo "Done"; Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Illegal offset type in %s on line %d -- Iteration 1 -- @@ -169,16 +169,20 @@ array(2) { string(6) "string" } -- Iteration 10 -- -array(1) { +array(2) { ["hello"]=> string(5) "hello" + ["resource"]=> + string(8) "resource" } -- Iteration 11 -- -array(6) { +array(7) { [1]=> int(1) ["2.2"]=> float(2.2) + ["resource"]=> + string(8) "resource" ["int"]=> string(3) "int" ["float"]=> diff --git a/ext/standard/tests/array/array_map_variation4.phpt b/ext/standard/tests/array/array_map_variation4.phpt index d99a529e3a..e5b4c062c1 100644 --- a/ext/standard/tests/array/array_map_variation4.phpt +++ b/ext/standard/tests/array/array_map_variation4.phpt @@ -79,13 +79,13 @@ echo "Done"; --EXPECTF-- *** Testing array_map() : associative array with diff. keys for 'arr1' argument *** -Warning: Illegal offset type in %s on line %d%d +Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d%d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Warning: Illegal offset type in %s on line %d%d +Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d%d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- array(0) { } @@ -157,16 +157,20 @@ array(2) { string(6) "string" } -- Iteration 10 -- -array(1) { +array(2) { [""]=> string(5) "hello" + [5]=> + string(8) "resource" } -- Iteration 11 -- -array(6) { +array(7) { ["hello"]=> int(1) ["fruit"]=> float(2.2) + [5]=> + string(8) "resource" [133]=> string(3) "int" [444]=> diff --git a/ext/standard/tests/array/array_merge_recursive_variation4.phpt b/ext/standard/tests/array/array_merge_recursive_variation4.phpt index f73dd9c628..f2c1e82a0c 100644 --- a/ext/standard/tests/array/array_merge_recursive_variation4.phpt +++ b/ext/standard/tests/array/array_merge_recursive_variation4.phpt @@ -82,7 +82,7 @@ echo "Done"; Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- -- With default argument -- array(2) { @@ -383,31 +383,35 @@ array(7) { } -- Iteration 8 -- -- With default argument -- -array(3) { +array(4) { [""]=> array(1) { [0]=> string(5) "unset" } [0]=> - int(11) + string(8) "resource" [1]=> + int(11) + [2]=> string(5) "hello" } -- With more arguments -- -array(7) { +array(8) { [""]=> array(1) { [0]=> string(5) "unset" } [0]=> - int(11) + string(8) "resource" [1]=> - string(5) "hello" + int(11) [2]=> - string(3) "one" + string(5) "hello" [3]=> + string(3) "one" + [4]=> int(2) ["string"]=> string(5) "hello" diff --git a/ext/standard/tests/array/array_reverse_variation4.phpt b/ext/standard/tests/array/array_reverse_variation4.phpt index 88f36ea025..09b2eb4bee 100644 --- a/ext/standard/tests/array/array_reverse_variation4.phpt +++ b/ext/standard/tests/array/array_reverse_variation4.phpt @@ -85,11 +85,11 @@ echo "Done"; Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- - default argument - array(0) { @@ -314,23 +314,29 @@ array(2) { } -- Iteration 10 -- - default argument - -array(1) { +array(2) { + [0]=> + string(8) "resource" [""]=> string(5) "hello" } - $preserve keys = true - -array(1) { +array(2) { + [5]=> + string(8) "resource" [""]=> string(5) "hello" } - $preserve_keys = false - -array(1) { +array(2) { + [0]=> + string(8) "resource" [""]=> string(5) "hello" } -- Iteration 11 -- - default argument - -array(6) { +array(7) { ["Hello world"]=> string(7) "heredoc" [""]=> @@ -339,13 +345,15 @@ array(6) { string(5) "float" [1]=> string(3) "int" + [2]=> + string(8) "resource" ["fruit"]=> float(2.2) ["hello"]=> int(1) } - $preserve keys = true - -array(6) { +array(7) { ["Hello world"]=> string(7) "heredoc" [""]=> @@ -354,13 +362,15 @@ array(6) { string(5) "float" [133]=> string(3) "int" + [5]=> + string(8) "resource" ["fruit"]=> float(2.2) ["hello"]=> int(1) } - $preserve_keys = false - -array(6) { +array(7) { ["Hello world"]=> string(7) "heredoc" [""]=> @@ -369,6 +379,8 @@ array(6) { string(5) "float" [1]=> string(3) "int" + [2]=> + string(8) "resource" ["fruit"]=> float(2.2) ["hello"]=> diff --git a/ext/standard/tests/array/array_unique_variation3.phpt b/ext/standard/tests/array/array_unique_variation3.phpt index 95cd1887d1..205bc3a576 100644 --- a/ext/standard/tests/array/array_unique_variation3.phpt +++ b/ext/standard/tests/array/array_unique_variation3.phpt @@ -70,7 +70,7 @@ echo "Done"; Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- array(1) { [0]=> @@ -125,10 +125,12 @@ array(2) { string(6) "string" } -- Iteration 8 -- -array(2) { +array(3) { [""]=> string(5) "hello" - [0]=> + [5]=> + string(8) "resource" + [6]=> int(11) } Done diff --git a/ext/standard/tests/array/array_unshift_variation4.phpt b/ext/standard/tests/array/array_unshift_variation4.phpt index 64bf3a8d82..7f507c98d0 100644 --- a/ext/standard/tests/array/array_unshift_variation4.phpt +++ b/ext/standard/tests/array/array_unshift_variation4.phpt @@ -103,11 +103,11 @@ echo "Done"; Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Illegal offset type in %s on line %d -Warning: Illegal offset type in %s on line %d +Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- int(1) array(1) { @@ -330,15 +330,17 @@ array(5) { string(6) "string" } -- Iteration 10 -- -int(2) -array(2) { +int(3) +array(3) { [0]=> int(10) [""]=> string(5) "hello" + [1]=> + string(8) "resource" } -int(4) -array(4) { +int(5) +array(5) { [0]=> int(10) [1]=> @@ -347,10 +349,12 @@ array(4) { string(5) "world" [""]=> string(5) "hello" + [3]=> + string(8) "resource" } -- Iteration 11 -- -int(7) -array(7) { +int(8) +array(8) { [0]=> int(10) ["hello"]=> @@ -358,16 +362,18 @@ array(7) { ["fruit"]=> float(2.2) [1]=> - string(3) "int" + string(8) "resource" [2]=> + string(3) "int" + [3]=> string(5) "float" [""]=> string(5) "unset" ["Hello world"]=> string(7) "heredoc" } -int(9) -array(9) { +int(10) +array(10) { [0]=> int(10) [1]=> @@ -379,8 +385,10 @@ array(9) { ["fruit"]=> float(2.2) [3]=> - string(3) "int" + string(8) "resource" [4]=> + string(3) "int" + [5]=> string(5) "float" [""]=> string(5) "unset" diff --git a/scripts/dev/bless_tests.php b/scripts/dev/bless_tests.php index 25a4843c07..fbbfe505c9 100755 --- a/scripts/dev/bless_tests.php +++ b/scripts/dev/bless_tests.php @@ -54,6 +54,10 @@ function normalizeOutput(string $out): string { $out = preg_replace('/^#(\d+) \/.+\(\d+\):/m', '#$1 %s(%d):', $out); $out = preg_replace('/Resource id #\d+/', 'Resource id #%d', $out); $out = preg_replace('/resource\(\d+\) of type/', 'resource(%d) of type', $out); + $out = preg_replace( + '/Resource ID#\d+ used as offset, casting to integer \(\d+\)/', + 'Resource ID#%d used as offset, casting to integer (%d)', + $out); $out = preg_replace('/string\(\d+\) "([^"]*%d)/', 'string(%d) "$1', $out); return $out; } |