summaryrefslogtreecommitdiff
path: root/Zend/zend_inheritance.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-06-30 13:59:27 +0300
committerDmitry Stogov <dmitry@zend.com>2015-06-30 13:59:27 +0300
commit7aa7627172c11979ec45c2db85f99182812ee59d (patch)
tree90762a1d26b47213a9edd7016a9c45110156e24e /Zend/zend_inheritance.c
parentd554d64f649a915b4ecb3a1de409cfc8ff0e9133 (diff)
downloadphp-git-7aa7627172c11979ec45c2db85f99182812ee59d.tar.gz
Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes).
Diffstat (limited to 'Zend/zend_inheritance.c')
-rw-r--r--Zend/zend_inheritance.c186
1 files changed, 93 insertions, 93 deletions
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 004aadde34..f1a6d60a2d 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -142,8 +142,8 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
if (ce->constructor) {
if (ce->parent->constructor && UNEXPECTED(ce->parent->constructor->common.fn_flags & ZEND_ACC_FINAL)) {
zend_error_noreturn(E_ERROR, "Cannot override final %s::%s() with %s::%s()",
- ce->parent->name->val, ce->parent->constructor->common.function_name->val,
- ce->name->val, ce->constructor->common.function_name->val);
+ ZSTR_VAL(ce->parent->name), ZSTR_VAL(ce->parent->constructor->common.function_name),
+ ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name));
}
return;
}
@@ -183,7 +183,7 @@ static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_inf
class_name = ((zend_internal_arg_info*)fe_arg_info)->class_name;
} else {
fe_class_name = fe_arg_info->class_name;
- class_name = fe_arg_info->class_name->val;
+ class_name = ZSTR_VAL(fe_arg_info->class_name);
}
if (!strcasecmp(class_name, "parent") && proto->common.scope) {
fe_class_name = zend_string_copy(proto->common.scope->name);
@@ -200,7 +200,7 @@ static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_inf
class_name = ((zend_internal_arg_info*)proto_arg_info)->class_name;
} else {
proto_class_name = proto_arg_info->class_name;
- class_name = proto_arg_info->class_name->val;
+ class_name = ZSTR_VAL(proto_arg_info->class_name);
}
if (!strcasecmp(class_name, "parent") && proto->common.scope && proto->common.scope->parent) {
proto_class_name = zend_string_copy(proto->common.scope->parent->name);
@@ -212,16 +212,16 @@ static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_inf
proto_class_name = zend_string_init(class_name, strlen(class_name), 0);
}
- if (strcasecmp(fe_class_name->val, proto_class_name->val) != 0) {
+ if (strcasecmp(ZSTR_VAL(fe_class_name), ZSTR_VAL(proto_class_name)) != 0) {
const char *colon;
if (fe->common.type != ZEND_USER_FUNCTION) {
zend_string_release(proto_class_name);
zend_string_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 ||
- strcasecmp(colon+1, proto_class_name->val) != 0) {
+ } else if (strchr(ZSTR_VAL(proto_class_name), '\\') != NULL ||
+ (colon = zend_memrchr(ZSTR_VAL(fe_class_name), '\\', ZSTR_LEN(fe_class_name))) == NULL ||
+ strcasecmp(colon+1, ZSTR_VAL(proto_class_name)) != 0) {
zend_class_entry *fe_ce, *proto_ce;
fe_ce = zend_lookup_class(fe_class_name);
@@ -355,16 +355,16 @@ static void zend_append_type_hint(smart_str *str, const zend_function *fptr, zen
class_name = ((zend_internal_arg_info*)arg_info)->class_name;
class_name_len = strlen(class_name);
} else {
- class_name = arg_info->class_name->val;
- class_name_len = arg_info->class_name->len;
+ class_name = ZSTR_VAL(arg_info->class_name);
+ class_name_len = ZSTR_LEN(arg_info->class_name);
}
if (!strcasecmp(class_name, "self") && fptr->common.scope) {
- class_name = fptr->common.scope->name->val;
- class_name_len = fptr->common.scope->name->len;
+ class_name = ZSTR_VAL(fptr->common.scope->name);
+ class_name_len = ZSTR_LEN(fptr->common.scope->name);
} else if (!strcasecmp(class_name, "parent") && fptr->common.scope && fptr->common.scope->parent) {
- class_name = fptr->common.scope->parent->name->val;
- class_name_len = fptr->common.scope->parent->name->len;
+ class_name = ZSTR_VAL(fptr->common.scope->parent->name);
+ class_name_len = ZSTR_LEN(fptr->common.scope->parent->name);
}
smart_str_appendl(str, class_name, class_name_len);
@@ -395,7 +395,7 @@ static zend_string *zend_get_function_declaration(const zend_function *fptr) /*
if (fptr->common.scope) {
/* cut off on NULL byte ... class@anonymous */
- smart_str_appendl(&str, fptr->common.scope->name->val, strlen(fptr->common.scope->name->val));
+ smart_str_appendl(&str, ZSTR_VAL(fptr->common.scope->name), strlen(ZSTR_VAL(fptr->common.scope->name)));
smart_str_appends(&str, "::");
}
@@ -428,7 +428,7 @@ static zend_string *zend_get_function_declaration(const zend_function *fptr) /*
if (fptr->type == ZEND_INTERNAL_FUNCTION) {
smart_str_appends(&str, ((zend_internal_arg_info*)arg_info)->name);
} else {
- smart_str_appendl(&str, arg_info->name->val, arg_info->name->len);
+ smart_str_appendl(&str, ZSTR_VAL(arg_info->name), ZSTR_LEN(arg_info->name));
}
} else {
smart_str_appends(&str, "param");
@@ -516,13 +516,13 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
&& parent->common.scope != (child->common.prototype ? child->common.prototype->common.scope : child->common.scope)
&& child->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_IMPLEMENTED_ABSTRACT)) {
zend_error_noreturn(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)",
- parent->common.scope->name->val,
- child->common.function_name->val,
- child->common.prototype ? child->common.prototype->common.scope->name->val : child->common.scope->name->val);
+ ZSTR_VAL(parent->common.scope->name),
+ ZSTR_VAL(child->common.function_name),
+ child->common.prototype ? ZSTR_VAL(child->common.prototype->common.scope->name) : ZSTR_VAL(child->common.scope->name));
}
if (UNEXPECTED(parent_flags & ZEND_ACC_FINAL)) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot override final method %s::%s()", ZEND_FN_SCOPE_NAME(parent), child->common.function_name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Cannot override final method %s::%s()", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name));
}
child_flags = child->common.fn_flags;
@@ -530,15 +530,15 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
*/
if (UNEXPECTED((child_flags & ZEND_ACC_STATIC) != (parent_flags & ZEND_ACC_STATIC))) {
if (child->common.fn_flags & ZEND_ACC_STATIC) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot make non static method %s::%s() static in class %s", ZEND_FN_SCOPE_NAME(parent), child->common.function_name->val, ZEND_FN_SCOPE_NAME(child));
+ zend_error_noreturn(E_COMPILE_ERROR, "Cannot make non static method %s::%s() static in class %s", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child));
} else {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot make static method %s::%s() non static in class %s", ZEND_FN_SCOPE_NAME(parent), child->common.function_name->val, ZEND_FN_SCOPE_NAME(child));
+ zend_error_noreturn(E_COMPILE_ERROR, "Cannot make static method %s::%s() non static in class %s", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child));
}
}
/* Disallow making an inherited method abstract. */
if (UNEXPECTED((child_flags & ZEND_ACC_ABSTRACT) > (parent_flags & ZEND_ACC_ABSTRACT))) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot make non abstract method %s::%s() abstract in class %s", ZEND_FN_SCOPE_NAME(parent), child->common.function_name->val, ZEND_FN_SCOPE_NAME(child));
+ zend_error_noreturn(E_COMPILE_ERROR, "Cannot make non abstract method %s::%s() abstract in class %s", ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child));
}
if (parent_flags & ZEND_ACC_CHANGED) {
@@ -547,7 +547,7 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
/* Prevent derived classes from restricting access that was available in parent classes
*/
if (UNEXPECTED((child_flags & ZEND_ACC_PPP_MASK) > (parent_flags & ZEND_ACC_PPP_MASK))) {
- zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::%s() must be %s (as in class %s)%s", ZEND_FN_SCOPE_NAME(child), child->common.function_name->val, zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
+ zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::%s() must be %s (as in class %s)%s", ZEND_FN_SCOPE_NAME(child), ZSTR_VAL(child->common.function_name), zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
} else if (((child_flags & ZEND_ACC_PPP_MASK) < (parent_flags & ZEND_ACC_PPP_MASK))
&& ((parent_flags & ZEND_ACC_PPP_MASK) & ZEND_ACC_PRIVATE)) {
child->common.fn_flags |= ZEND_ACC_CHANGED;
@@ -570,12 +570,12 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
if (UNEXPECTED(!zend_do_perform_implementation_check(child, child->common.prototype))) {
zend_string *method_prototype = zend_get_function_declaration(child->common.prototype);
zend_string *child_prototype = zend_get_function_declaration(child);
- zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s", child_prototype->val, method_prototype->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s", ZSTR_VAL(child_prototype), ZSTR_VAL(method_prototype));
}
} else if (UNEXPECTED(!zend_do_perform_implementation_check(child, parent))) {
zend_string *method_prototype = zend_get_function_declaration(parent);
zend_string *child_prototype = zend_get_function_declaration(child);
- zend_error(E_WARNING, "Declaration of %s should be compatible with %s", child_prototype->val, method_prototype->val);
+ zend_error(E_WARNING, "Declaration of %s should be compatible with %s", ZSTR_VAL(child_prototype), ZSTR_VAL(method_prototype));
zend_string_free(child_prototype);
zend_string_free(method_prototype);
}
@@ -611,8 +611,8 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
} else {
if (UNEXPECTED((parent_info->flags & ZEND_ACC_STATIC) != (child_info->flags & ZEND_ACC_STATIC))) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s%s::$%s as %s%s::$%s",
- (parent_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ce->parent->name->val, key->val,
- (child_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ce->name->val, key->val);
+ (parent_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ZSTR_VAL(ce->parent->name), ZSTR_VAL(key),
+ (child_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ZSTR_VAL(ce->name), ZSTR_VAL(key));
}
if (parent_info->flags & ZEND_ACC_CHANGED) {
@@ -620,7 +620,7 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
}
if (UNEXPECTED((child_info->flags & ZEND_ACC_PPP_MASK) > (parent_info->flags & ZEND_ACC_PPP_MASK))) {
- zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ce->name->val, key->val, zend_visibility_string(parent_info->flags), ce->parent->name->val, (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
+ zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ZSTR_VAL(ce->name), ZSTR_VAL(key), zend_visibility_string(parent_info->flags), ZSTR_VAL(ce->parent->name), (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
} else if ((child_info->flags & ZEND_ACC_STATIC) == 0) {
int parent_num = OBJ_PROP_TO_NUM(parent_info->offset);
int child_num = OBJ_PROP_TO_NUM(child_info->offset);
@@ -655,10 +655,10 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry *iface) /* {{{ */
{
if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && iface->interface_gets_implemented && iface->interface_gets_implemented(iface, ce) == FAILURE) {
- zend_error_noreturn(E_CORE_ERROR, "Class %s could not implement interface %s", ce->name->val, iface->name->val);
+ zend_error_noreturn(E_CORE_ERROR, "Class %s could not implement interface %s", ZSTR_VAL(ce->name), ZSTR_VAL(iface->name));
}
if (UNEXPECTED(ce == iface)) {
- zend_error_noreturn(E_ERROR, "Interface %s cannot implement itself", ce->name->val);
+ zend_error_noreturn(E_ERROR, "Interface %s cannot implement itself", ZSTR_VAL(ce->name));
}
}
/* }}} */
@@ -729,19 +729,19 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
if (UNEXPECTED(ce->ce_flags & ZEND_ACC_INTERFACE)) {
/* Interface can only inherit other interfaces */
if (UNEXPECTED(!(parent_ce->ce_flags & ZEND_ACC_INTERFACE))) {
- zend_error_noreturn(E_COMPILE_ERROR, "Interface %s may not inherit from class (%s)", ce->name->val, parent_ce->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Interface %s may not inherit from class (%s)", ZSTR_VAL(ce->name), ZSTR_VAL(parent_ce->name));
}
} else if (UNEXPECTED(parent_ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_FINAL))) {
/* Class declaration must not extend traits or interfaces */
if (parent_ce->ce_flags & ZEND_ACC_INTERFACE) {
- zend_error_noreturn(E_COMPILE_ERROR, "Class %s cannot extend from interface %s", ce->name->val, parent_ce->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Class %s cannot extend from interface %s", ZSTR_VAL(ce->name), ZSTR_VAL(parent_ce->name));
} else if (parent_ce->ce_flags & ZEND_ACC_TRAIT) {
- zend_error_noreturn(E_COMPILE_ERROR, "Class %s cannot extend from trait %s", ce->name->val, parent_ce->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Class %s cannot extend from trait %s", ZSTR_VAL(ce->name), ZSTR_VAL(parent_ce->name));
}
/* Class must not extend a final class */
if (parent_ce->ce_flags & ZEND_ACC_FINAL) {
- zend_error_noreturn(E_COMPILE_ERROR, "Class %s may not inherit from final class (%s)", ce->name->val, parent_ce->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Class %s may not inherit from final class (%s)", ZSTR_VAL(ce->name), ZSTR_VAL(parent_ce->name));
}
}
@@ -896,7 +896,7 @@ static zend_bool do_inherit_constant_check(HashTable *child_constants_table, zva
if (!Z_ISREF_P(old_constant) ||
!Z_ISREF_P(parent_constant) ||
Z_REFVAL_P(old_constant) != Z_REFVAL_P(parent_constant)) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot inherit previously-inherited or override constant %s from interface %s", name->val, iface->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Cannot inherit previously-inherited or override constant %s from interface %s", ZSTR_VAL(name), ZSTR_VAL(iface->name));
}
return 0;
}
@@ -934,7 +934,7 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry
if (EXPECTED(i < parent_iface_num)) {
ignore = 1;
} else {
- zend_error_noreturn(E_COMPILE_ERROR, "Class %s cannot implement previously implemented interface %s", ce->name->val, iface->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Class %s cannot implement previously implemented interface %s", ZSTR_VAL(ce->name), ZSTR_VAL(iface->name));
}
}
}
@@ -1014,41 +1014,41 @@ static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_
static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zend_function* fe) /* {{{ */
{
- if (!strncmp(mname->val, ZEND_CLONE_FUNC_NAME, mname->len)) {
+ if (!strncmp(ZSTR_VAL(mname), ZEND_CLONE_FUNC_NAME, ZSTR_LEN(mname))) {
ce->clone = fe; fe->common.fn_flags |= ZEND_ACC_CLONE;
- } else if (!strncmp(mname->val, ZEND_CONSTRUCTOR_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_CONSTRUCTOR_FUNC_NAME, ZSTR_LEN(mname))) {
if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) {
- zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ce->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name));
}
ce->constructor = fe; fe->common.fn_flags |= ZEND_ACC_CTOR;
- } else if (!strncmp(mname->val, ZEND_DESTRUCTOR_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_DESTRUCTOR_FUNC_NAME, ZSTR_LEN(mname))) {
ce->destructor = fe; fe->common.fn_flags |= ZEND_ACC_DTOR;
- } else if (!strncmp(mname->val, ZEND_GET_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_GET_FUNC_NAME, ZSTR_LEN(mname))) {
ce->__get = fe;
ce->ce_flags |= ZEND_ACC_USE_GUARDS;
- } else if (!strncmp(mname->val, ZEND_SET_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_SET_FUNC_NAME, ZSTR_LEN(mname))) {
ce->__set = fe;
ce->ce_flags |= ZEND_ACC_USE_GUARDS;
- } else if (!strncmp(mname->val, ZEND_CALL_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_CALL_FUNC_NAME, ZSTR_LEN(mname))) {
ce->__call = fe;
- } else if (!strncmp(mname->val, ZEND_UNSET_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_UNSET_FUNC_NAME, ZSTR_LEN(mname))) {
ce->__unset = fe;
ce->ce_flags |= ZEND_ACC_USE_GUARDS;
- } else if (!strncmp(mname->val, ZEND_ISSET_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_ISSET_FUNC_NAME, ZSTR_LEN(mname))) {
ce->__isset = fe;
ce->ce_flags |= ZEND_ACC_USE_GUARDS;
- } else if (!strncmp(mname->val, ZEND_CALLSTATIC_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_CALLSTATIC_FUNC_NAME, ZSTR_LEN(mname))) {
ce->__callstatic = fe;
- } else if (!strncmp(mname->val, ZEND_TOSTRING_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_TOSTRING_FUNC_NAME, ZSTR_LEN(mname))) {
ce->__tostring = fe;
- } else if (!strncmp(mname->val, ZEND_DEBUGINFO_FUNC_NAME, mname->len)) {
+ } else if (!strncmp(ZSTR_VAL(mname), ZEND_DEBUGINFO_FUNC_NAME, ZSTR_LEN(mname))) {
ce->__debugInfo = fe;
- } else if (ce->name->len == mname->len) {
+ } else if (ZSTR_LEN(ce->name) == ZSTR_LEN(mname)) {
zend_string *lowercase_name = zend_string_tolower(ce->name);
lowercase_name = zend_new_interned_string(lowercase_name);
- if (!memcmp(mname->val, lowercase_name->val, mname->len)) {
+ if (!memcmp(ZSTR_VAL(mname), ZSTR_VAL(lowercase_name), ZSTR_LEN(mname))) {
if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) {
- zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ce->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ZSTR_VAL(ce->name));
}
ce->constructor = fe;
fe->common.fn_flags |= ZEND_ACC_CTOR;
@@ -1073,15 +1073,15 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
/* Make sure the trait method is compatible with previosly declared abstract method */
if (UNEXPECTED(!zend_traits_method_compatibility_check(fn, existing_fn))) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
- zend_get_function_declaration(fn)->val,
- zend_get_function_declaration(existing_fn)->val);
+ ZSTR_VAL(zend_get_function_declaration(fn)),
+ ZSTR_VAL(zend_get_function_declaration(existing_fn)));
}
} else if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
/* Make sure the abstract declaration is compatible with previous declaration */
if (UNEXPECTED(!zend_traits_method_compatibility_check(existing_fn, fn))) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
- zend_get_function_declaration(fn)->val,
- zend_get_function_declaration(existing_fn)->val);
+ ZSTR_VAL(zend_get_function_declaration(fn)),
+ ZSTR_VAL(zend_get_function_declaration(existing_fn)));
}
return;
}
@@ -1097,27 +1097,27 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
/* Make sure the trait method is compatible with previosly declared abstract method */
if (UNEXPECTED(!zend_traits_method_compatibility_check(fn, existing_fn))) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
- zend_get_function_declaration(fn)->val,
- zend_get_function_declaration(existing_fn)->val);
+ ZSTR_VAL(zend_get_function_declaration(fn)),
+ ZSTR_VAL(zend_get_function_declaration(existing_fn)));
}
} else if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
/* Make sure the abstract declaration is compatible with previous declaration */
if (UNEXPECTED(!zend_traits_method_compatibility_check(existing_fn, fn))) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
- zend_get_function_declaration(fn)->val,
- zend_get_function_declaration(existing_fn)->val);
+ ZSTR_VAL(zend_get_function_declaration(fn)),
+ ZSTR_VAL(zend_get_function_declaration(existing_fn)));
}
return;
} else if (UNEXPECTED(existing_fn->common.scope->ce_flags & ZEND_ACC_TRAIT)) {
/* two traits can't define the same non-abstract method */
#if 1
zend_error_noreturn(E_COMPILE_ERROR, "Trait method %s has not been applied, because there are collisions with other trait methods on %s",
- name, ce->name->val);
+ name, ZSTR_VAL(ce->name));
#else /* TODO: better error message */
zend_error_noreturn(E_COMPILE_ERROR, "Trait method %s::%s has not been applied as %s::%s, because of collision with %s::%s",
- fn->common.scope->name->val, fn->common.function_name->val,
- ce->name->val, name,
- existing_fn->common.scope->name->val, existing_fn->common.function_name->val);
+ ZSTR_VAL(fn->common.scope->name), ZSTR_VAL(fn->common.function_name),
+ ZSTR_VAL(ce->name), name,
+ ZSTR_VAL(existing_fn->common.scope->name), ZSTR_VAL(existing_fn->common.function_name));
#endif
} else {
/* inherited members are overridden by members inserted by traits */
@@ -1165,8 +1165,8 @@ static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, ze
/* Scope unset or equal to the function we compare to, and the alias applies to fn */
if (alias->alias != NULL
&& (!alias->trait_method->ce || fn->common.scope == alias->trait_method->ce)
- && alias->trait_method->method_name->len == fnname->len
- && (zend_binary_strcasecmp(alias->trait_method->method_name->val, alias->trait_method->method_name->len, fnname->val, fnname->len) == 0)) {
+ && ZSTR_LEN(alias->trait_method->method_name) == ZSTR_LEN(fnname)
+ && (zend_binary_strcasecmp(ZSTR_VAL(alias->trait_method->method_name), ZSTR_LEN(alias->trait_method->method_name), ZSTR_VAL(fnname), ZSTR_LEN(fnname)) == 0)) {
fn_copy = *fn;
/* if it is 0, no modifieres has been changed */
@@ -1175,7 +1175,7 @@ static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, ze
}
lcname = zend_string_tolower(alias->alias);
- zend_add_trait_method(ce, alias->alias->val, lcname, &fn_copy, overriden);
+ zend_add_trait_method(ce, ZSTR_VAL(alias->alias), lcname, &fn_copy, overriden);
zend_string_release(lcname);
/* Record the trait from which this alias was resolved. */
@@ -1200,8 +1200,8 @@ static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, ze
/* Scope unset or equal to the function we compare to, and the alias applies to fn */
if (alias->alias == NULL && alias->modifiers != 0
&& (!alias->trait_method->ce || fn->common.scope == alias->trait_method->ce)
- && (alias->trait_method->method_name->len == fnname->len)
- && (zend_binary_strcasecmp(alias->trait_method->method_name->val, alias->trait_method->method_name->len, fnname->val, fnname->len) == 0)) {
+ && (ZSTR_LEN(alias->trait_method->method_name) == ZSTR_LEN(fnname))
+ && (zend_binary_strcasecmp(ZSTR_VAL(alias->trait_method->method_name), ZSTR_LEN(alias->trait_method->method_name), ZSTR_VAL(fnname), ZSTR_LEN(fnname)) == 0)) {
fn_copy.common.fn_flags = alias->modifiers | (fn->common.fn_flags ^ (fn->common.fn_flags & ZEND_ACC_PPP_MASK));
@@ -1215,7 +1215,7 @@ static int zend_traits_copy_functions(zend_string *fnname, zend_function *fn, ze
}
}
- zend_add_trait_method(ce, fn->common.function_name->val, fnname, &fn_copy, overriden);
+ zend_add_trait_method(ce, ZSTR_VAL(fn->common.function_name), fnname, &fn_copy, overriden);
}
return ZEND_HASH_APPLY_KEEP;
@@ -1227,7 +1227,7 @@ static void zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *trait
uint32_t i;
if (UNEXPECTED((trait->ce_flags & ZEND_ACC_TRAIT) != ZEND_ACC_TRAIT)) {
- zend_error_noreturn(E_COMPILE_ERROR, "Class %s is not a trait, Only traits may be used in 'as' and 'insteadof' statements", trait->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Class %s is not a trait, Only traits may be used in 'as' and 'insteadof' statements", ZSTR_VAL(trait->name));
}
for (i = 0; i < ce->num_traits; i++) {
@@ -1235,7 +1235,7 @@ static void zend_check_trait_usage(zend_class_entry *ce, zend_class_entry *trait
return;
}
}
- zend_error_noreturn(E_COMPILE_ERROR, "Required Trait %s wasn't added to %s", trait->name->val, ce->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Required Trait %s wasn't added to %s", ZSTR_VAL(trait->name), ZSTR_VAL(ce->name));
}
/* }}} */
@@ -1259,7 +1259,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce) /* {{{ */
cur_method_ref = cur_precedence->trait_method;
if (!(cur_precedence->trait_method->ce = zend_fetch_class(cur_method_ref->class_name,
ZEND_FETCH_CLASS_TRAIT|ZEND_FETCH_CLASS_NO_AUTOLOAD))) {
- zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", cur_method_ref->class_name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", ZSTR_VAL(cur_method_ref->class_name));
}
zend_check_trait_usage(ce, cur_precedence->trait_method->ce);
@@ -1271,8 +1271,8 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce) /* {{{ */
if (!method_exists) {
zend_error_noreturn(E_COMPILE_ERROR,
"A precedence rule was defined for %s::%s but this method does not exist",
- cur_method_ref->ce->name->val,
- cur_method_ref->method_name->val);
+ ZSTR_VAL(cur_method_ref->ce->name),
+ ZSTR_VAL(cur_method_ref->method_name));
}
/** With the other traits, we are more permissive.
@@ -1286,7 +1286,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce) /* {{{ */
zend_string* class_name = cur_precedence->exclude_from_classes[j].class_name;
if (!(cur_precedence->exclude_from_classes[j].ce = zend_fetch_class(class_name, ZEND_FETCH_CLASS_TRAIT |ZEND_FETCH_CLASS_NO_AUTOLOAD))) {
- zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", class_name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", ZSTR_VAL(class_name));
}
zend_check_trait_usage(ce, cur_precedence->exclude_from_classes[j].ce);
@@ -1296,9 +1296,9 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce) /* {{{ */
zend_error_noreturn(E_COMPILE_ERROR,
"Inconsistent insteadof definition. "
"The method %s is to be used from %s, but %s is also on the exclude list",
- cur_method_ref->method_name->val,
- cur_precedence->trait_method->ce->name->val,
- cur_precedence->trait_method->ce->name->val);
+ ZSTR_VAL(cur_method_ref->method_name),
+ ZSTR_VAL(cur_precedence->trait_method->ce->name),
+ ZSTR_VAL(cur_precedence->trait_method->ce->name));
}
zend_string_release(class_name);
@@ -1317,7 +1317,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce) /* {{{ */
if (ce->trait_aliases[i]->trait_method->class_name) {
cur_method_ref = ce->trait_aliases[i]->trait_method;
if (!(cur_method_ref->ce = zend_fetch_class(cur_method_ref->class_name, ZEND_FETCH_CLASS_TRAIT|ZEND_FETCH_CLASS_NO_AUTOLOAD))) {
- zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", cur_method_ref->class_name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", ZSTR_VAL(cur_method_ref->class_name));
}
zend_check_trait_usage(ce, cur_method_ref->ce);
@@ -1328,7 +1328,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce) /* {{{ */
zend_string_release(lcname);
if (!method_exists) {
- zend_error_noreturn(E_COMPILE_ERROR, "An alias was defined for %s::%s but this method does not exist", cur_method_ref->ce->name->val, cur_method_ref->method_name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "An alias was defined for %s::%s but this method does not exist", ZSTR_VAL(cur_method_ref->ce->name), ZSTR_VAL(cur_method_ref->method_name));
}
}
i++;
@@ -1353,7 +1353,7 @@ static void zend_traits_compile_exclude_table(HashTable* exclude_table, zend_tra
zend_string_tolower(precedences[i]->trait_method->method_name);
if (zend_hash_add_empty_element(exclude_table, lcname) == NULL) {
zend_string_release(lcname);
- zend_error_noreturn(E_COMPILE_ERROR, "Failed to evaluate a trait precedence (%s). Method of trait %s was defined to be excluded multiple times", precedences[i]->trait_method->method_name->val, trait->name->val);
+ zend_error_noreturn(E_COMPILE_ERROR, "Failed to evaluate a trait precedence (%s). Method of trait %s was defined to be excluded multiple times", ZSTR_VAL(precedences[i]->trait_method->method_name), ZSTR_VAL(trait->name));
}
zend_string_release(lcname);
}
@@ -1504,10 +1504,10 @@ static void zend_do_traits_property_binding(zend_class_entry *ce) /* {{{ */
if (not_compatible) {
zend_error_noreturn(E_COMPILE_ERROR,
"%s and %s define the same property ($%s) in the composition of %s. However, the definition differs and is considered incompatible. Class was composed",
- find_first_definition(ce, i, prop_name, coliding_prop->ce)->name->val,
- property_info->ce->name->val,
- prop_name->val,
- ce->name->val);
+ ZSTR_VAL(find_first_definition(ce, i, prop_name, coliding_prop->ce)->name),
+ ZSTR_VAL(property_info->ce->name),
+ ZSTR_VAL(prop_name),
+ ZSTR_VAL(ce->name));
}
zend_string_release(prop_name);
@@ -1549,8 +1549,8 @@ static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce)
/** Plain old inconsistency/typo/bug */
zend_error_noreturn(E_COMPILE_ERROR,
"An alias (%s) was defined for method %s(), but this method does not exist",
- cur_alias->alias->val,
- cur_alias->trait_method->method_name->val);
+ ZSTR_VAL(cur_alias->alias),
+ ZSTR_VAL(cur_alias->trait_method->method_name));
} else {
/** Here are two possible cases:
1) this is an attempt to modifiy the visibility
@@ -1567,12 +1567,12 @@ static void zend_do_check_for_inconsistent_traits_aliasing(zend_class_entry *ce)
zend_string_release(lc_method_name);
zend_error_noreturn(E_COMPILE_ERROR,
"The modifiers for the trait alias %s() need to be changed in the same statement in which the alias is defined. Error",
- cur_alias->trait_method->method_name->val);
+ ZSTR_VAL(cur_alias->trait_method->method_name));
} else {
zend_string_release(lc_method_name);
zend_error_noreturn(E_COMPILE_ERROR,
"The modifiers of the trait method %s() are changed, but this method does not exist. Error",
- cur_alias->trait_method->method_name->val);
+ ZSTR_VAL(cur_alias->trait_method->method_name));
}
}
@@ -1624,8 +1624,8 @@ static zend_bool zend_has_deprecated_constructor(const zend_class_entry *ce) /*
}
constructor_name = ce->constructor->common.function_name;
return !zend_binary_strcasecmp(
- ce->name->val, ce->name->len,
- constructor_name->val, constructor_name->len
+ ZSTR_VAL(ce->name), ZSTR_LEN(ce->name),
+ ZSTR_VAL(constructor_name), ZSTR_LEN(constructor_name)
);
}
/* }}} */
@@ -1633,7 +1633,7 @@ static zend_bool zend_has_deprecated_constructor(const zend_class_entry *ce) /*
void zend_check_deprecated_constructor(const zend_class_entry *ce) /* {{{ */
{
if (zend_has_deprecated_constructor(ce)) {
- zend_error(E_DEPRECATED, "Methods with the same name as their class will not be constructors in a future version of PHP; %s has a deprecated constructor", ce->name->val);
+ zend_error(E_DEPRECATED, "Methods with the same name as their class will not be constructors in a future version of PHP; %s has a deprecated constructor", ZSTR_VAL(ce->name));
}
}
/* }}} */