FREE_OP2();
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
{
USE_OPLINE
zend_free_op free_op1;
- zval *expr, tmp;
+ zval *expr;
- zval *result = &EX_T(opline->result.var).tmp_var;
+ zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
- expr = GET_OP1_ZVAL_PTR(BP_VAR_R);
+ expr = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
- if (opline->extended_value != IS_STRING) {
- ZVAL_COPY_VALUE(result, expr);
- if (!IS_OP1_TMP_FREE()) {
- zendi_zval_copy_ctor(*result);
- }
- }
switch (opline->extended_value) {
case IS_NULL:
- convert_to_null(result);
+ /* This code is taken from convert_to_null. However, it does not seems very useful,
+ * because a conversion to null always results in the same value. This could only
+ * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
+#if 0
+ if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
+ ZVAL_DEREF(expr);
+ }
+ if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
+ if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL TSRMLS_CC) == SUCCESS) {
+ break;
+ }
+ }
+#endif
+
+ ZVAL_NULL(result);
break;
- case IS_BOOL:
- convert_to_boolean(result);
+ case _IS_BOOL:
+ ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC));
break;
case IS_LONG:
- convert_to_long(result);
+ ZVAL_LONG(result, zval_get_long(expr));
break;
case IS_DOUBLE:
- convert_to_double(result);
+ ZVAL_DOUBLE(result, zval_get_double(expr));
+ break;
+ case IS_STRING:
+ ZVAL_STR(result, zval_get_string(expr));
break;
- case IS_STRING: {
- zval var_copy;
- int use_copy;
+ default:
+ /* If value is already of correct type, return it directly */
+ if (Z_TYPE_P(expr) == opline->extended_value) {
+ ZVAL_COPY_VALUE(result, expr);
+ if (OP1_TYPE == IS_CONST) {
+ if (UNEXPECTED(Z_OPT_COPYABLE_P(result))) {
+ zval_copy_ctor_func(result);
+ }
+ } else if (OP1_TYPE != IS_TMP_VAR) {
+ if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
+ }
- zend_make_printable_zval(expr, &var_copy, &use_copy);
- if (use_copy) {
- ZVAL_COPY_VALUE(result, &var_copy);
- if (IS_OP1_TMP_FREE()) {
- FREE_OP1();
+ FREE_OP1();
+ CHECK_EXCEPTION();
+ ZEND_VM_NEXT_OPCODE();
+ }
+
+ if (opline->extended_value == IS_ARRAY) {
+ if (Z_TYPE_P(expr) != IS_OBJECT) {
+ ZVAL_NEW_ARR(result);
+ zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0);
+ if (Z_TYPE_P(expr) != IS_NULL) {
+ expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr);
+ if (OP1_TYPE == IS_CONST) {
+ if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
+ zval_copy_ctor_func(expr);
+ }
+ } else if (OP1_TYPE != IS_TMP_VAR) {
+ if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
+ }
+ }
+ } else {
+ ZVAL_COPY_VALUE(result, expr);
+ if (!IS_OP1_TMP_FREE()) {
+ zval_opt_copy_ctor(result);
+ }
+ convert_to_array(result);
}
} else {
- ZVAL_COPY_VALUE(result, expr);
- if (!IS_OP1_TMP_FREE()) {
- zendi_zval_copy_ctor(*result);
+ if (Z_TYPE_P(expr) != IS_ARRAY) {
+ object_init(result);
+ if (Z_TYPE_P(expr) != IS_NULL) {
+ expr = zend_hash_str_add_new(Z_OBJPROP_P(result), "scalar", sizeof("scalar")-1, expr);
+ if (OP1_TYPE == IS_CONST) {
+ if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
+ zval_copy_ctor_func(expr);
+ }
+ } else if (OP1_TYPE != IS_TMP_VAR) {
+ if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
+ }
+ }
+ } else {
+ ZVAL_COPY_VALUE(result, expr);
+ if (!IS_OP1_TMP_FREE()) {
+ zval_opt_copy_ctor(result);
+ }
+ convert_to_object(result);
}
}
- break;
- }
- case IS_ARRAY:
- convert_to_array(result);
- break;
- case IS_OBJECT:
- convert_to_object(result);
- break;
+
+ FREE_OP1_IF_VAR();
+ CHECK_EXCEPTION();
+ ZEND_VM_NEXT_OPCODE();
}
- FREE_OP1_IF_VAR();
+ FREE_OP1();
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED)
{
USE_OPLINE
- zend_function *op_array;
+ zval *zfunc;
+ int closure_is_static, closure_is_being_defined_inside_static_context;
SAVE_OPLINE();
zend_error_noreturn(E_ERROR, "Base lambda function for closure not found");
}
- zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC);
- closure_is_static = op_array->common.fn_flags & ZEND_ACC_STATIC;
++ closure_is_static = Z_FUNC_P(zfunc)->common.fn_flags & ZEND_ACC_STATIC;
+ closure_is_being_defined_inside_static_context = EX(prev_execute_data) && EX(prev_execute_data)->function_state.function->common.fn_flags & ZEND_ACC_STATIC;
+ if (closure_is_static || closure_is_being_defined_inside_static_context) {
- zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(called_scope), NULL TSRMLS_CC);
++ zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(called_scope), NULL TSRMLS_CC);
+ } else {
- zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(scope), EG(This) TSRMLS_CC);
++ zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC);
+ }
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
{
USE_OPLINE
- zval *expr, tmp;
+ zval *expr;
- zval *result = &EX_T(opline->result.var).tmp_var;
+ zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
expr = opline->op1.zv;
static int ZEND_FASTCALL ZEND_DECLARE_LAMBDA_FUNCTION_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
USE_OPLINE
- zend_function *op_array;
+ zval *zfunc;
+ int closure_is_static, closure_is_being_defined_inside_static_context;
SAVE_OPLINE();
zend_error_noreturn(E_ERROR, "Base lambda function for closure not found");
}
- zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC);
- closure_is_static = op_array->common.fn_flags & ZEND_ACC_STATIC;
++ closure_is_static = Z_FUNC_P(zfunc)->common.fn_flags & ZEND_ACC_STATIC;
+ closure_is_being_defined_inside_static_context = EX(prev_execute_data) && EX(prev_execute_data)->function_state.function->common.fn_flags & ZEND_ACC_STATIC;
+ if (closure_is_static || closure_is_being_defined_inside_static_context) {
- zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(called_scope), NULL TSRMLS_CC);
++ zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(called_scope), NULL TSRMLS_CC);
+ } else {
- zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(scope), EG(This) TSRMLS_CC);
++ zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC);
+ }
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
{
USE_OPLINE
zend_free_op free_op1;
- zval *expr, tmp;
+ zval *expr;
- zval *result = &EX_T(opline->result.var).tmp_var;
+ zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
expr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
zval_dtor(free_op2.var);
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
}
} else {
if (UNEXPECTED(EG(exception) != NULL)) {
- zval_ptr_dtor_nogc(&free_op2.var);
+ zval_ptr_dtor_nogc(free_op2.var);
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
{
USE_OPLINE
zend_free_op free_op1;
- zval *expr, tmp;
+ zval *expr;
- zval *result = &EX_T(opline->result.var).tmp_var;
+ zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
- expr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
+ expr = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
- if (opline->extended_value != IS_STRING) {
- ZVAL_COPY_VALUE(result, expr);
- if (!0) {
- zendi_zval_copy_ctor(*result);
- }
- }
switch (opline->extended_value) {
case IS_NULL:
- convert_to_null(result);
+ /* This code is taken from convert_to_null. However, it does not seems very useful,
+ * because a conversion to null always results in the same value. This could only
+ * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
+#if 0
+ if (IS_VAR == IS_VAR || IS_VAR == IS_CV) {
+ ZVAL_DEREF(expr);
+ }
+ if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
+ if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL TSRMLS_CC) == SUCCESS) {
+ break;
+ }
+ }
+#endif
+
+ ZVAL_NULL(result);
break;
- case IS_BOOL:
- convert_to_boolean(result);
+ case _IS_BOOL:
+ ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC));
break;
case IS_LONG:
- convert_to_long(result);
+ ZVAL_LONG(result, zval_get_long(expr));
break;
case IS_DOUBLE:
- convert_to_double(result);
+ ZVAL_DOUBLE(result, zval_get_double(expr));
+ break;
+ case IS_STRING:
+ ZVAL_STR(result, zval_get_string(expr));
break;
- case IS_STRING: {
- zval var_copy;
- int use_copy;
+ default:
+ /* If value is already of correct type, return it directly */
+ if (Z_TYPE_P(expr) == opline->extended_value) {
+ ZVAL_COPY_VALUE(result, expr);
+ if (IS_VAR == IS_CONST) {
+ if (UNEXPECTED(Z_OPT_COPYABLE_P(result))) {
+ zval_copy_ctor_func(result);
+ }
+ } else if (IS_VAR != IS_TMP_VAR) {
+ if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
+ }
- zend_make_printable_zval(expr, &var_copy, &use_copy);
- if (use_copy) {
- ZVAL_COPY_VALUE(result, &var_copy);
- if (0) {
- zval_ptr_dtor_nogc(&free_op1.var);
+ zval_ptr_dtor_nogc(free_op1.var);
+ CHECK_EXCEPTION();
+ ZEND_VM_NEXT_OPCODE();
+ }
+
+ if (opline->extended_value == IS_ARRAY) {
+ if (Z_TYPE_P(expr) != IS_OBJECT) {
+ ZVAL_NEW_ARR(result);
+ zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0);
+ if (Z_TYPE_P(expr) != IS_NULL) {
+ expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr);
+ if (IS_VAR == IS_CONST) {
+ if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
+ zval_copy_ctor_func(expr);
+ }
+ } else if (IS_VAR != IS_TMP_VAR) {
+ if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
+ }
+ }
+ } else {
+ ZVAL_COPY_VALUE(result, expr);
+ if (!0) {
+ zval_opt_copy_ctor(result);
+ }
+ convert_to_array(result);
}
} else {
- ZVAL_COPY_VALUE(result, expr);
- if (!0) {
- zendi_zval_copy_ctor(*result);
+ if (Z_TYPE_P(expr) != IS_ARRAY) {
+ object_init(result);
+ if (Z_TYPE_P(expr) != IS_NULL) {
+ expr = zend_hash_str_add_new(Z_OBJPROP_P(result), "scalar", sizeof("scalar")-1, expr);
+ if (IS_VAR == IS_CONST) {
+ if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
+ zval_copy_ctor_func(expr);
+ }
+ } else if (IS_VAR != IS_TMP_VAR) {
+ if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
+ }
+ }
+ } else {
+ ZVAL_COPY_VALUE(result, expr);
+ if (!0) {
+ zval_opt_copy_ctor(result);
+ }
+ convert_to_object(result);
}
}
- break;
- }
- case IS_ARRAY:
- convert_to_array(result);
- break;
- case IS_OBJECT:
- convert_to_object(result);
- break;
+
+ zval_ptr_dtor_nogc(free_op1.var);
+ CHECK_EXCEPTION();
+ ZEND_VM_NEXT_OPCODE();
}
- zval_ptr_dtor_nogc(&free_op1.var);
+ zval_ptr_dtor_nogc(free_op1.var);
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
zval_dtor(free_op2.var);
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
}
} else {
if (UNEXPECTED(EG(exception) != NULL)) {
- zval_ptr_dtor_nogc(&free_op2.var);
+ zval_ptr_dtor_nogc(free_op2.var);
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
zval_dtor(free_op2.var);
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
}
} else {
if (UNEXPECTED(EG(exception) != NULL)) {
- zval_ptr_dtor_nogc(&free_op2.var);
+ zval_ptr_dtor_nogc(free_op2.var);
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
{
USE_OPLINE
- zval *expr, tmp;
+ zval *expr;
- zval *result = &EX_T(opline->result.var).tmp_var;
+ zval *result = EX_VAR(opline->result.var);
SAVE_OPLINE();
- expr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC);
+ expr = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC);
- if (opline->extended_value != IS_STRING) {
- ZVAL_COPY_VALUE(result, expr);
- if (!0) {
- zendi_zval_copy_ctor(*result);
- }
- }
switch (opline->extended_value) {
case IS_NULL:
- convert_to_null(result);
+ /* This code is taken from convert_to_null. However, it does not seems very useful,
+ * because a conversion to null always results in the same value. This could only
+ * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
+#if 0
+ if (IS_CV == IS_VAR || IS_CV == IS_CV) {
+ ZVAL_DEREF(expr);
+ }
+ if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
+ if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL TSRMLS_CC) == SUCCESS) {
+ break;
+ }
+ }
+#endif
+
+ ZVAL_NULL(result);
break;
- case IS_BOOL:
- convert_to_boolean(result);
+ case _IS_BOOL:
+ ZVAL_BOOL(result, zend_is_true(expr TSRMLS_CC));
break;
case IS_LONG:
- convert_to_long(result);
+ ZVAL_LONG(result, zval_get_long(expr));
break;
case IS_DOUBLE:
- convert_to_double(result);
+ ZVAL_DOUBLE(result, zval_get_double(expr));
break;
- case IS_STRING: {
- zval var_copy;
- int use_copy;
+ case IS_STRING:
+ ZVAL_STR(result, zval_get_string(expr));
+ break;
+ default:
+ /* If value is already of correct type, return it directly */
+ if (Z_TYPE_P(expr) == opline->extended_value) {
+ ZVAL_COPY_VALUE(result, expr);
+ if (IS_CV == IS_CONST) {
+ if (UNEXPECTED(Z_OPT_COPYABLE_P(result))) {
+ zval_copy_ctor_func(result);
+ }
+ } else if (IS_CV != IS_TMP_VAR) {
+ if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
+ }
- zend_make_printable_zval(expr, &var_copy, &use_copy);
- if (use_copy) {
- ZVAL_COPY_VALUE(result, &var_copy);
- if (0) {
+ CHECK_EXCEPTION();
+ ZEND_VM_NEXT_OPCODE();
+ }
+ if (opline->extended_value == IS_ARRAY) {
+ if (Z_TYPE_P(expr) != IS_OBJECT) {
+ ZVAL_NEW_ARR(result);
+ zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0);
+ if (Z_TYPE_P(expr) != IS_NULL) {
+ expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr);
+ if (IS_CV == IS_CONST) {
+ if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
+ zval_copy_ctor_func(expr);
+ }
+ } else if (IS_CV != IS_TMP_VAR) {
+ if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
+ }
+ }
+ } else {
+ ZVAL_COPY_VALUE(result, expr);
+ if (!0) {
+ zval_opt_copy_ctor(result);
+ }
+ convert_to_array(result);
}
} else {
- ZVAL_COPY_VALUE(result, expr);
- if (!0) {
- zendi_zval_copy_ctor(*result);
+ if (Z_TYPE_P(expr) != IS_ARRAY) {
+ object_init(result);
+ if (Z_TYPE_P(expr) != IS_NULL) {
+ expr = zend_hash_str_add_new(Z_OBJPROP_P(result), "scalar", sizeof("scalar")-1, expr);
+ if (IS_CV == IS_CONST) {
+ if (UNEXPECTED(Z_OPT_COPYABLE_P(expr))) {
+ zval_copy_ctor_func(expr);
+ }
+ } else if (IS_CV != IS_TMP_VAR) {
+ if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
+ }
+ }
+ } else {
+ ZVAL_COPY_VALUE(result, expr);
+ if (!0) {
+ zval_opt_copy_ctor(result);
+ }
+ convert_to_object(result);
}
}
- break;
- }
- case IS_ARRAY:
- convert_to_array(result);
- break;
- case IS_OBJECT:
- convert_to_object(result);
- break;
+
+ CHECK_EXCEPTION();
+ ZEND_VM_NEXT_OPCODE();
}
CHECK_EXCEPTION();
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
zval_dtor(free_op2.var);
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
}
} else {
if (UNEXPECTED(EG(exception) != NULL)) {
- zval_ptr_dtor_nogc(&free_op2.var);
+ zval_ptr_dtor_nogc(free_op2.var);
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
HANDLE_EXCEPTION();
}
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", Z_STRVAL_P(function_name));
- zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", function_name_strval, zend_get_type_by_const(Z_TYPE_P(call->object)));
++ zend_error_noreturn(E_ERROR, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
}
if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &setting, &setting_len) == FAILURE) {
return;
}
-
- if (setting_len) {
- char *p, **env;
- putenv_entry pe;
+
+ if(setting_len == 0 || setting[0] == '=') {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter syntax");
+ RETURN_FALSE;
+ }
+
+ pe.putenv_string = estrndup(setting, setting_len);
+ pe.key = estrndup(setting, setting_len);
+ if ((p = strchr(pe.key, '='))) { /* nullify the '=' if there is one */
+ *p = '\0';
#ifdef PHP_WIN32
- char *value = NULL;
- int equals = 0;
- int error_code;
+ equals = 1;
#endif
+ }
- pe.putenv_string = estrndup(setting, setting_len);
- pe.key = estrndup(setting, setting_len);
- if ((p = strchr(pe.key, '='))) { /* nullify the '=' if there is one */
- *p = '\0';
- #ifdef PHP_WIN32
- equals = 1;
- #endif
- }
-
- pe.key_len = strlen(pe.key);
+ pe.key_len = strlen(pe.key);
#ifdef PHP_WIN32
- if (equals) {
- if (pe.key_len < setting_len - 1) {
- value = p + 1;
- } else {
- /* empty string*/
- value = p;
- }
+ if (equals) {
+ if (pe.key_len < setting_len - 1) {
+ value = p + 1;
+ } else {
+ /* empty string*/
+ value = p;
}
+ }
#endif
- zend_hash_str_del(&BG(putenv_ht), pe.key, pe.key_len);
- zend_hash_del(&BG(putenv_ht), pe.key, pe.key_len+1);
++ zend_hash_str_del(&BG(putenv_ht), pe.key, pe.key_len);
- /* find previous value */
- pe.previous_value = NULL;
- for (env = environ; env != NULL && *env != NULL; env++) {
- if (!strncmp(*env, pe.key, pe.key_len) && (*env)[pe.key_len] == '=') { /* found it */
+ /* find previous value */
+ pe.previous_value = NULL;
+ for (env = environ; env != NULL && *env != NULL; env++) {
+ if (!strncmp(*env, pe.key, pe.key_len) && (*env)[pe.key_len] == '=') { /* found it */
#if defined(PHP_WIN32)
- /* must copy previous value because MSVCRT's putenv can free the string without notice */
- pe.previous_value = estrdup(*env);
+ /* must copy previous value because MSVCRT's putenv can free the string without notice */
+ pe.previous_value = estrdup(*env);
#else
- pe.previous_value = *env;
+ pe.previous_value = *env;
#endif
- break;
- }
+ break;
}
+ }
#if HAVE_UNSETENV
- if (!p) { /* no '=' means we want to unset it */
- unsetenv(pe.putenv_string);
- }
- if (!p || putenv(pe.putenv_string) == 0) { /* success */
+ if (!p) { /* no '=' means we want to unset it */
+ unsetenv(pe.putenv_string);
+ }
+ if (!p || putenv(pe.putenv_string) == 0) { /* success */
#else
# ifndef PHP_WIN32
- if (putenv(pe.putenv_string) == 0) { /* success */
+ if (putenv(pe.putenv_string) == 0) { /* success */
# else
- error_code = SetEnvironmentVariable(pe.key, value);
+ error_code = SetEnvironmentVariable(pe.key, value);
# if _MSC_VER < 1500
- /* Yet another VC6 bug, unset may return env not found */
- if (error_code != 0 ||
- (error_code == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)) {
+ /* Yet another VC6 bug, unset may return env not found */
+ if (error_code != 0 ||
+ (error_code == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)) {
# else
- if (error_code != 0) { /* success */
+ if (error_code != 0) { /* success */
# endif
# endif
#endif
- zend_hash_str_add_mem(&BG(putenv_ht), pe.key, pe.key_len, &pe, sizeof(putenv_entry));
- zend_hash_add(&BG(putenv_ht), pe.key, pe.key_len + 1, (void **) &pe, sizeof(putenv_entry), NULL);
++ zend_hash_str_add_mem(&BG(putenv_ht), pe.key, pe.key_len, &pe, sizeof(putenv_entry));
#ifdef HAVE_TZSET
- if (!strncmp(pe.key, "TZ", pe.key_len)) {
- tzset();
- }
- #endif
- RETURN_TRUE;
- } else {
- efree(pe.putenv_string);
- efree(pe.key);
- RETURN_FALSE;
+ if (!strncmp(pe.key, "TZ", pe.key_len)) {
+ tzset();
}
+ #endif
+ RETURN_TRUE;
+ } else {
+ efree(pe.putenv_string);
+ efree(pe.key);
+ RETURN_FALSE;
}
-
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter syntax");
- RETURN_FALSE;
}
/* }}} */
#endif