- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
- index c3c35eb..b1feb7a 100644
- --- a/Zend/zend_compile.c
- +++ b/Zend/zend_compile.c
- @@ -6089,7 +6089,19 @@ void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC
- zend_do_end_variable_parse(variable, BP_VAR_IS, 0 TSRMLS_CC);
- - zend_check_writable_variable(variable);
- + if (type == ZEND_ISEMPTY) {
- + // if the empty() argument is the result of a function call we already
- + // know that the variable exists, so we can just convert the empty()
- + // call to a boolean not
- + if (zend_is_function_or_method_call(variable)) {
- + zend_do_unary_op(ZEND_BOOL_NOT, result, variable TSRMLS_CC);
- + return;
- + }
- + } else {
- + // it doesn't make sense to pass the result of a function call to
- + // isset() as it will always be bool(true). Thus disallow them here
- + zend_check_writable_variable(variable);
- + }
- if (variable->op_type == IS_CV) {
- last_op = get_next_op(CG(active_op_array) TSRMLS_CC);
- diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
- index d0730b7..1a9d212 100644
- --- a/Zend/zend_language_parser.y
- +++ b/Zend/zend_language_parser.y
- @@ -1149,6 +1149,7 @@ encaps_var_offset:
- internal_functions_in_yacc:
- T_ISSET '(' isset_variables ')' { $$ = $3; }
- | T_EMPTY '(' variable ')' { zend_do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 TSRMLS_CC); }
- + | T_EMPTY '(' expr_without_variable ')' { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$3 TSRMLS_CC); }
- | T_INCLUDE expr { zend_do_include_or_eval(ZEND_INCLUDE, &$$, &$2 TSRMLS_CC); }
- | T_INCLUDE_ONCE expr { zend_do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 TSRMLS_CC); }
- | T_EVAL '(' expr ')' { zend_do_include_or_eval(ZEND_EVAL, &$$, &$3 TSRMLS_CC); }