diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2016-04-21 10:15:57 +0300 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2016-04-21 10:15:57 +0300 |
| commit | c026ca6cdccc74ca78d8b0ab203281c19b93cdde (patch) | |
| tree | b74b4d46fba2974ac44b5d4492912e8f6b797cbe /Zend/zend_compile.c | |
| parent | 650c1c0a7d94d3bb052a93407b6e280df9c265a4 (diff) | |
| parent | ecf6392243b90e6c8f5597076b11b4959bac9dc1 (diff) | |
| download | php-git-c026ca6cdccc74ca78d8b0ab203281c19b93cdde.tar.gz | |
Merge branch 'master' into safe_timeout
* master:
Fixed bug #72059 - Reference the bug id directly in NEWS
Fix magic constants (__LINE__) with ?? for constant scalar exprs
Add NEWS entry for ?? in constant scalar expressions
allow null coalescing (??) on constant expressions
Fix intl tests for ICU < 52
Fix ZTS builds by adding a missing TSRMLS_FETCH().
Fix bug #71737
Update NEWS
Fix RECV opcode to handle all kinds of exceptions
Fix RECV opcode to handle all kinds of exceptions
Diffstat (limited to 'Zend/zend_compile.c')
| -rw-r--r-- | Zend/zend_compile.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index fe9139b609..af2d2e95cb 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4903,8 +4903,9 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ zend_error_noreturn(E_COMPILE_ERROR, "Redefinition of parameter $%s", ZSTR_VAL(name)); } else if (zend_string_equals_literal(name, "this")) { - if (op_array->scope && (op_array->fn_flags & ZEND_ACC_STATIC) == 0) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot re-assign $this"); + if ((op_array->scope || (op_array->fn_flags & ZEND_ACC_CLOSURE)) + && (op_array->fn_flags & ZEND_ACC_STATIC) == 0) { + zend_error_noreturn(E_COMPILE_ERROR, "Cannot use $this as parameter"); } op_array->this_var = var_node.u.op.var; } @@ -7313,7 +7314,7 @@ zend_bool zend_is_allowed_in_const_expr(zend_ast_kind kind) /* {{{ */ || kind == ZEND_AST_CONDITIONAL || kind == ZEND_AST_DIM || kind == ZEND_AST_ARRAY || kind == ZEND_AST_ARRAY_ELEM || kind == ZEND_AST_CONST || kind == ZEND_AST_CLASS_CONST - || kind == ZEND_AST_MAGIC_CONST; + || kind == ZEND_AST_MAGIC_CONST || kind == ZEND_AST_COALESCE; } /* }}} */ @@ -7447,14 +7448,16 @@ void zend_const_expr_to_zval(zval *result, zend_ast *ast) /* {{{ */ zend_compile_const_expr(&ast); if (ast->kind == ZEND_AST_ZVAL) { ZVAL_COPY_VALUE(result, zend_ast_get_zval(ast)); - - /* Kill this branch of the original AST, as it was already destroyed. - * It would be nice to find a better solution to this problem in the - * future. */ - orig_ast->kind = 0; } else { ZVAL_NEW_AST(result, zend_ast_copy(ast)); + /* destroy the ast here, it might have been replaced */ + zend_ast_destroy(ast); } + + /* Kill this branch of the original AST, as it was already destroyed. + * It would be nice to find a better solution to this problem in the + * future. */ + orig_ast->kind = 0; } /* }}} */ @@ -7865,6 +7868,26 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ return; } break; + case ZEND_AST_COALESCE: + zend_eval_const_expr(&ast->child[0]); + + if (ast->child[0]->kind != ZEND_AST_ZVAL) { + /* ensure everything was compile-time evaluated at least once */ + zend_eval_const_expr(&ast->child[1]); + return; + } + + if (Z_TYPE_P(zend_ast_get_zval(ast->child[0])) == IS_NULL) { + zend_eval_const_expr(&ast->child[1]); + *ast_ptr = ast->child[1]; + ast->child[1] = NULL; + zend_ast_destroy(ast); + } else { + *ast_ptr = ast->child[0]; + ast->child[0] = NULL; + zend_ast_destroy(ast); + } + return; case ZEND_AST_CONDITIONAL: { zend_ast **child, *child_ast; |
