mirror of
https://github.com/php/php-src.git
synced 2026-04-12 02:23:18 +02:00
Merge branch 'refactoring2' of github.com:zendtech/php into refactoring2
This commit is contained in:
@@ -1619,8 +1619,9 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */
|
||||
result = zend_symtable_update(ht, STR_EMPTY_ALLOC(), value);
|
||||
break;
|
||||
case IS_RESOURCE:
|
||||
zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_LVAL_P(key), Z_LVAL_P(key));
|
||||
/* break missing intentionally */
|
||||
zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_RES_HANDLE_P(key), Z_RES_HANDLE_P(key));
|
||||
result = zend_hash_index_update(ht, Z_RES_HANDLE_P(key), value);
|
||||
break;
|
||||
case IS_BOOL:
|
||||
case IS_LONG:
|
||||
result = zend_hash_index_update(ht, Z_LVAL_P(key), value);
|
||||
|
||||
@@ -1936,8 +1936,15 @@ void zend_do_receive_param(zend_uchar op, znode *varname, const znode *initializ
|
||||
zend_resolve_class_name(class_type TSRMLS_CC);
|
||||
}
|
||||
Z_STR(class_type->u.constant) = zend_new_interned_string(Z_STR(class_type->u.constant) TSRMLS_CC);
|
||||
//???: for now we have to copy it :(
|
||||
#if 1
|
||||
cur_arg_info->class_name = estrndup(Z_STRVAL(class_type->u.constant), Z_STRLEN(class_type->u.constant));
|
||||
cur_arg_info->class_name_len = Z_STRLEN(class_type->u.constant);
|
||||
STR_RELEASE(Z_STR(class_type->u.constant));
|
||||
#else
|
||||
cur_arg_info->class_name = Z_STRVAL(class_type->u.constant);
|
||||
cur_arg_info->class_name_len = Z_STRLEN(class_type->u.constant);
|
||||
#endif
|
||||
if (op == ZEND_RECV_INIT) {
|
||||
if (Z_TYPE(initialization->u.constant) == IS_NULL || (Z_TYPE(initialization->u.constant) == IS_CONSTANT && !strcasecmp(Z_STRVAL(initialization->u.constant), "NULL")) || Z_TYPE(initialization->u.constant) == IS_CONSTANT_AST) {
|
||||
cur_arg_info->allow_null = 1;
|
||||
@@ -3284,13 +3291,9 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
|
||||
zend_string *fe_class_name, *proto_class_name;
|
||||
|
||||
if (!strcasecmp(fe_arg_info->class_name, "parent") && proto->common.scope) {
|
||||
fe_class_name = STR_INIT(
|
||||
proto->common.scope->name->val,
|
||||
proto->common.scope->name->len, 0);
|
||||
fe_class_name = STR_COPY(proto->common.scope->name);
|
||||
} else if (!strcasecmp(fe_arg_info->class_name, "self") && fe->common.scope) {
|
||||
fe_class_name = STR_INIT(
|
||||
fe->common.scope->name->val,
|
||||
fe->common.scope->name->len, 0);
|
||||
fe_class_name = STR_COPY(fe->common.scope->name);
|
||||
} else {
|
||||
fe_class_name = STR_INIT(
|
||||
fe_arg_info->class_name,
|
||||
@@ -3298,13 +3301,9 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
|
||||
}
|
||||
|
||||
if (!strcasecmp(proto_arg_info->class_name, "parent") && proto->common.scope && proto->common.scope->parent) {
|
||||
proto_class_name = STR_INIT(
|
||||
proto->common.scope->parent->name->val,
|
||||
proto->common.scope->parent->name->len, 0);
|
||||
proto_class_name = STR_COPY(proto->common.scope->parent->name);
|
||||
} else if (!strcasecmp(proto_arg_info->class_name, "self") && proto->common.scope) {
|
||||
proto_class_name = STR_INIT(
|
||||
proto->common.scope->name->val,
|
||||
proto->common.scope->name->len, 0);
|
||||
proto_class_name = STR_COPY(proto->common.scope->name);
|
||||
} else {
|
||||
proto_class_name = STR_INIT(
|
||||
proto_arg_info->class_name,
|
||||
@@ -3315,6 +3314,8 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
|
||||
const char *colon;
|
||||
|
||||
if (fe->common.type != ZEND_USER_FUNCTION) {
|
||||
STR_RELEASE(proto_class_name);
|
||||
STR_RELEASE(fe_class_name);
|
||||
return 0;
|
||||
} else if (strchr(proto_class_name->val, '\\') != NULL ||
|
||||
(colon = zend_memrchr(fe_class_name->val, '\\', fe_class_name->len)) == NULL ||
|
||||
@@ -3329,10 +3330,14 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
|
||||
fe_ce->type == ZEND_INTERNAL_CLASS ||
|
||||
proto_ce->type == ZEND_INTERNAL_CLASS ||
|
||||
fe_ce != proto_ce) {
|
||||
STR_RELEASE(proto_class_name);
|
||||
STR_RELEASE(fe_class_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
STR_RELEASE(proto_class_name);
|
||||
STR_RELEASE(fe_class_name);
|
||||
}
|
||||
if (fe_arg_info->type_hint != proto_arg_info->type_hint) {
|
||||
/* Incompatible type hint */
|
||||
|
||||
@@ -1088,8 +1088,9 @@ fetch_string_dim:
|
||||
hval = zend_dval_to_lval(Z_DVAL_P(dim));
|
||||
goto num_index;
|
||||
case IS_RESOURCE:
|
||||
zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_LVAL_P(dim), Z_LVAL_P(dim));
|
||||
/* Fall Through */
|
||||
zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim));
|
||||
hval = Z_RES_HANDLE_P(dim);
|
||||
goto num_index;
|
||||
case IS_BOOL:
|
||||
case IS_LONG:
|
||||
hval = Z_LVAL_P(dim);
|
||||
|
||||
@@ -332,7 +332,7 @@ static zend_always_inline struct _zend_property_info *zend_get_property_info_qui
|
||||
if (UNEXPECTED(denied_access != 0)) {
|
||||
/* Information was available, but we were denied access. Error out. */
|
||||
if (!silent) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name, Z_STRVAL_P(member));
|
||||
zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name->val, Z_STRVAL_P(member));
|
||||
}
|
||||
return NULL;
|
||||
} else {
|
||||
@@ -452,7 +452,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, const zend_li
|
||||
}
|
||||
goto exit;
|
||||
}
|
||||
if (UNEXPECTED(!zobj->properties)) {
|
||||
if (UNEXPECTED(zobj->properties != NULL)) {
|
||||
retval = zend_hash_find(zobj->properties, property_info->name);
|
||||
if (retval) goto exit;
|
||||
}
|
||||
@@ -485,7 +485,7 @@ zval *zend_std_read_property(zval *object, zval *member, int type, const zend_li
|
||||
Z_SET_REFCOUNT_P(rv, 0);
|
||||
}
|
||||
if (UNEXPECTED(Z_TYPE_P(rv) != IS_OBJECT)) {
|
||||
zend_error(E_NOTICE, "Indirect modification of overloaded property %s::$%s has no effect", zobj->ce->name, Z_STRVAL_P(member));
|
||||
zend_error(E_NOTICE, "Indirect modification of overloaded property %s::$%s has no effect", zobj->ce->name->val, Z_STRVAL_P(member));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -736,7 +736,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type,
|
||||
{
|
||||
zend_object *zobj;
|
||||
zval tmp_member;
|
||||
zval *retval;
|
||||
zval *retval, tmp;
|
||||
zend_property_info *property_info;
|
||||
long *guard;
|
||||
|
||||
@@ -766,7 +766,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type,
|
||||
}
|
||||
goto exit;
|
||||
}
|
||||
if (UNEXPECTED(!zobj->properties)) {
|
||||
if (UNEXPECTED(zobj->properties != NULL)) {
|
||||
retval = zend_hash_find(zobj->properties, property_info->name);
|
||||
if (retval) goto exit;
|
||||
}
|
||||
@@ -780,12 +780,10 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type,
|
||||
if(UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
|
||||
zend_error(E_NOTICE, "Undefined property: %s::$%s", zobj->ce->name->val, Z_STRVAL_P(member));
|
||||
}
|
||||
ZVAL_NULL(&tmp);
|
||||
if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) &&
|
||||
property_info->offset >= 0) {
|
||||
if (zobj->properties) {
|
||||
zval tmp;
|
||||
|
||||
ZVAL_NULL(&tmp);
|
||||
retval = zend_hash_update(zobj->properties, property_info->name, &tmp);
|
||||
ZVAL_INDIRECT(&zobj->properties_table[property_info->offset], retval);
|
||||
} else {
|
||||
@@ -796,7 +794,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type,
|
||||
if (!zobj->properties) {
|
||||
rebuild_object_properties(zobj);
|
||||
}
|
||||
zend_hash_update(zobj->properties, property_info->name, retval);
|
||||
retval = zend_hash_update(zobj->properties, property_info->name, &tmp);
|
||||
}
|
||||
} else {
|
||||
/* we do have getter - fail and let it try again with usual get/set */
|
||||
@@ -1202,7 +1200,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
|
||||
/* right now this function is used for non static method lookup too */
|
||||
/* Is the function static */
|
||||
if (UNEXPECTED(!(fbc->common.fn_flags & ZEND_ACC_STATIC))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot call non static method %s::%s() without object", ZEND_FN_SCOPE_NAME(fbc), fbc->common.function_name);
|
||||
zend_error_noreturn(E_ERROR, "Cannot call non static method %s::%s() without object", ZEND_FN_SCOPE_NAME(fbc), fbc->common.function_name->val);
|
||||
}
|
||||
#endif
|
||||
if (fbc->op_array.fn_flags & ZEND_ACC_PUBLIC) {
|
||||
@@ -1258,14 +1256,14 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p
|
||||
|
||||
if (UNEXPECTED(!zend_verify_property_access(property_info, ce TSRMLS_CC))) {
|
||||
if (!silent) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name, property_name);
|
||||
zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name->val, property_name->val);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) {
|
||||
if (!silent) {
|
||||
zend_error_noreturn(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name, property_name);
|
||||
zend_error_noreturn(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name->val, property_name->val);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1534,14 +1532,12 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
|
||||
|
||||
switch (type) {
|
||||
case IS_STRING:
|
||||
ZVAL_UNDEF(&retval);
|
||||
ZVAL_UNDEF(&retval);
|
||||
ce = Z_OBJCE_P(readobj);
|
||||
if (ce->__tostring &&
|
||||
(zend_call_method_with_0_params(readobj, ce, &ce->__tostring, "__tostring", &retval) || EG(exception))) {
|
||||
if (UNEXPECTED(EG(exception) != NULL)) {
|
||||
if (Z_TYPE(retval) != IS_UNDEF) {
|
||||
zval_ptr_dtor(&retval);
|
||||
}
|
||||
zval_ptr_dtor(&retval);
|
||||
EG(exception) = NULL;
|
||||
zend_error_noreturn(E_ERROR, "Method %s::__toString() must not throw an exception", ce->name->val);
|
||||
return FAILURE;
|
||||
|
||||
@@ -232,10 +232,14 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */
|
||||
break; \
|
||||
} \
|
||||
case IS_BOOL: \
|
||||
case IS_RESOURCE: \
|
||||
ZVAL_LONG(&(holder), Z_LVAL_P(op)); \
|
||||
(op) = &(holder); \
|
||||
break; \
|
||||
case IS_RESOURCE: \
|
||||
/* ??? delete old resource ??? */ \
|
||||
ZVAL_LONG(&(holder), Z_RES_HANDLE_P(op)); \
|
||||
(op) = &(holder); \
|
||||
break; \
|
||||
case IS_NULL: \
|
||||
ZVAL_LONG(&(holder), 0); \
|
||||
(op) = &(holder); \
|
||||
@@ -275,9 +279,12 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */
|
||||
convert_to_long_base(&(holder), 10); \
|
||||
break; \
|
||||
case IS_BOOL: \
|
||||
case IS_RESOURCE: \
|
||||
Z_LVAL(holder) = Z_LVAL_P(op); \
|
||||
break; \
|
||||
case IS_RESOURCE: \
|
||||
/* ??? delete old resource ??? */ \
|
||||
ZVAL_LONG(&holder, Z_RES_HANDLE_P(op)); \
|
||||
break; \
|
||||
default: \
|
||||
zend_error(E_WARNING, "Cannot convert to ordinal value"); \
|
||||
Z_LVAL(holder) = 0; \
|
||||
@@ -299,6 +306,8 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */
|
||||
Z_LVAL(holder) = 0; \
|
||||
break; \
|
||||
case IS_RESOURCE: \
|
||||
Z_LVAL(holder) = (Z_RES_HANDLE_P(op) ? 1 : 0); \
|
||||
break; \
|
||||
case IS_LONG: \
|
||||
Z_LVAL(holder) = (Z_LVAL_P(op) ? 1 : 0); \
|
||||
break; \
|
||||
@@ -334,6 +343,7 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */
|
||||
#define convert_object_to_type(op, ctype, conv_func) \
|
||||
if (Z_OBJ_HT_P(op)->cast_object) { \
|
||||
zval dst; \
|
||||
ZVAL_UNDEF(&dst); \
|
||||
if (Z_OBJ_HT_P(op)->cast_object(op, &dst, ctype TSRMLS_CC) == FAILURE) { \
|
||||
zend_error(E_RECOVERABLE_ERROR, \
|
||||
"Object of class %s could not be converted to %s", Z_OBJCE_P(op)->name->val,\
|
||||
@@ -1625,6 +1635,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {
|
||||
zend_free_obj_get_result(op_free TSRMLS_CC);
|
||||
return ret;
|
||||
} else if (Z_TYPE_P(op2) != IS_OBJECT && Z_OBJ_HT_P(op1)->cast_object) {
|
||||
ZVAL_UNDEF(&tmp_free);
|
||||
if (Z_OBJ_HT_P(op1)->cast_object(op1, &tmp_free, Z_TYPE_P(op2) TSRMLS_CC) == FAILURE) {
|
||||
ZVAL_LONG(result, 1);
|
||||
zend_free_obj_get_result(&tmp_free TSRMLS_CC);
|
||||
@@ -1642,6 +1653,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {
|
||||
zend_free_obj_get_result(op_free TSRMLS_CC);
|
||||
return ret;
|
||||
} else if (Z_TYPE_P(op1) != IS_OBJECT && Z_OBJ_HT_P(op2)->cast_object) {
|
||||
ZVAL_UNDEF(&tmp_free);
|
||||
if (Z_OBJ_HT_P(op2)->cast_object(op2, &tmp_free, Z_TYPE_P(op1) TSRMLS_CC) == FAILURE) {
|
||||
ZVAL_LONG(result, -1);
|
||||
zend_free_obj_get_result(&tmp_free TSRMLS_CC);
|
||||
@@ -1728,9 +1740,11 @@ ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
|
||||
break;
|
||||
case IS_BOOL:
|
||||
case IS_LONG:
|
||||
case IS_RESOURCE:
|
||||
Z_LVAL_P(result) = (Z_LVAL_P(op1) == Z_LVAL_P(op2));
|
||||
break;
|
||||
case IS_RESOURCE:
|
||||
Z_LVAL_P(result) = (Z_RES_P(op1) == Z_RES_P(op2));
|
||||
break;
|
||||
case IS_DOUBLE:
|
||||
Z_LVAL_P(result) = (Z_DVAL_P(op1) == Z_DVAL_P(op2));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user