Skip to content
Open
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: 3 additions & 0 deletions Zend/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ static inline zend_result ct_eval_isset_dim(zval *result, uint32_t extended_valu
} else if (Z_TYPE_P(op1) == IS_STRING) {
// TODO
return FAILURE;
} else if (IS_PARTIAL_OBJECT(op1)) {
/* Objects may implement ArrayAccess or throw. */
return FAILURE;
} else {
ZVAL_BOOL(result, (extended_value & ZEND_ISEMPTY));
return SUCCESS;
Expand Down
36 changes: 36 additions & 0 deletions ext/opcache/tests/opt/sccp_isset_dim_partial_object.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
SCCP: isset()/empty() on dimension of non-escaping object must not be evaluated
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
--EXTENSIONS--
opcache
--FILE--
<?php
class P {}

function f() {
$o = new P;
return isset($o[1]);
}

function g() {
$o = new P;
return empty($o[1]);
}

try {
var_dump(f());
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(g());
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Cannot use object of type P as array
Cannot use object of type P as array
Loading