Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Zend/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,6 @@ static inline zend_result ct_eval_array_key_exists(zval *result, const zval *op1
if (Z_TYPE_P(op2) != IS_ARRAY && !IS_PARTIAL_ARRAY(op2)) {
return FAILURE;
}
if (Z_TYPE_P(op1) != IS_STRING && Z_TYPE_P(op1) != IS_LONG && Z_TYPE_P(op1) != IS_NULL) {
return FAILURE;
}
if (fetch_array_elem(&value, op2, op1) == FAILURE) {
return FAILURE;
}
Expand Down
45 changes: 45 additions & 0 deletions ext/opcache/tests/opt/sccp_array_key_exists.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--TEST--
SCCP: Evaluate array_key_exists with boolean and integral float keys, but not NAN or null
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.opt_debug_level=0x20000
opcache.preload=
--EXTENSIONS--
opcache
--FILE--
<?php
function test() {
var_dump(
array_key_exists(true, [1 => null]),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test with NAN and null as the first argument, it must not be evaluated at compile time.

array_key_exists(false, [1 => null]),
array_key_exists(-1.0, [-1 => null]),
array_key_exists(2.0, [1 => null]),
array_key_exists(NAN, [0 => null]),
array_key_exists(null, ['' => null]),
);
}
?>
--EXPECTF--
$_main:
; (lines=1, args=0, vars=0, tmps=0)
; (after optimizer)
; %s:%d-%d
0000 RETURN int(1)

test:
; (lines=11, args=0, vars=0, tmps=1)
; (after optimizer)
; %s:%d-%d
0000 INIT_FCALL 6 %d string("var_dump")
0001 SEND_VAL bool(true) 1
0002 SEND_VAL bool(false) 2
0003 SEND_VAL bool(true) 3
0004 SEND_VAL bool(false) 4
0005 T0 = ARRAY_KEY_EXISTS float(%r[Nn][Aa][Nn]%r) array(...)
0006 SEND_VAL T0 5
0007 T0 = ARRAY_KEY_EXISTS null array(...)
0008 SEND_VAL T0 6
0009 DO_ICALL
0010 RETURN null
Loading