*/
if ((fname_len == class_name_len) && !ctor && !memcmp(lowercase_name->val, lc_class_name, class_name_len+1)) {
ctor = reg_function;
- } else if ((fname_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_CONSTRUCTOR_FUNC_NAME)) {
ctor = reg_function;
- } else if ((fname_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_DESTRUCTOR_FUNC_NAME)) {
dtor = reg_function;
if (internal_function->num_args) {
zend_error(error_type, "Destructor %s::%s() cannot take arguments", scope->name->val, ptr->fname);
}
- } else if ((fname_len == sizeof(ZEND_CLONE_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_CLONE_FUNC_NAME)) {
clone = reg_function;
- } else if ((fname_len == sizeof(ZEND_CALL_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_CALL_FUNC_NAME)) {
__call = reg_function;
- } else if ((fname_len == sizeof(ZEND_CALLSTATIC_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_CALLSTATIC_FUNC_NAME, sizeof(ZEND_CALLSTATIC_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_CALLSTATIC_FUNC_NAME)) {
__callstatic = reg_function;
- } else if ((fname_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_TOSTRING_FUNC_NAME)) {
__tostring = reg_function;
- } else if ((fname_len == sizeof(ZEND_GET_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_GET_FUNC_NAME)) {
__get = reg_function;
- } else if ((fname_len == sizeof(ZEND_SET_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_SET_FUNC_NAME)) {
__set = reg_function;
- } else if ((fname_len == sizeof(ZEND_UNSET_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_UNSET_FUNC_NAME, sizeof(ZEND_UNSET_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_UNSET_FUNC_NAME)) {
__unset = reg_function;
- } else if ((fname_len == sizeof(ZEND_ISSET_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_ISSET_FUNC_NAME)) {
__isset = reg_function;
- } else if ((fname_len == sizeof(ZEND_DEBUGINFO_FUNC_NAME)-1) && !memcmp(lowercase_name->val, ZEND_DEBUGINFO_FUNC_NAME, sizeof(ZEND_DEBUGINFO_FUNC_NAME) - 1)) {
+ } else if (zend_string_equals_literal(lowercase_name, ZEND_DEBUGINFO_FUNC_NAME)) {
__debugInfo = reg_function;
} else {
reg_function = NULL;
zend_str_tolower_copy(lcname->val, name->val, name_len);
*strict_class = 0;
- if (name_len == sizeof("self") - 1 &&
- !memcmp(lcname->val, "self", sizeof("self") - 1)) {
+ if (zend_string_equals_literal(lcname, "self")) {
if (!EG(scope)) {
if (error) *error = estrdup("cannot access self:: when no class scope is active");
} else {
}
ret = 1;
}
- } else if (name_len == sizeof("parent") - 1 &&
- !memcmp(lcname->val, "parent", sizeof("parent") - 1)) {
+ } else if (zend_string_equals_literal(lcname, "parent")) {
if (!EG(scope)) {
if (error) *error = estrdup("cannot access parent:: when no class scope is active");
} else if (!EG(scope)->parent) {
*strict_class = 1;
ret = 1;
}
- } else if (name_len == sizeof("static") - 1 &&
- !memcmp(lcname->val, "static", sizeof("static") - 1)) {
+ } else if (zend_string_equals_literal(lcname, "static")) {
if (!EG(current_execute_data) || !EG(current_execute_data)->called_scope) {
if (error) *error = estrdup("cannot access static:: when no class scope is active");
} else {
zend_str_tolower_copy(lmname->val, mname->val, mlen);
if (strict_class &&
fcc->calling_scope &&
- mlen == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1 &&
- !memcmp(lmname->val, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME) - 1)) {
+ zend_string_equals_literal(lmname, ZEND_CONSTRUCTOR_FUNC_NAME)) {
fcc->function_handler = fcc->calling_scope->constructor;
if (fcc->function_handler) {
retval = 1;
}
/* }}} */
-static inline zend_bool zend_str_equals_str(zend_string *str1, zend_string *str2) {
- return str1->len == str2->len && !memcmp(str1->val, str2->val, str2->len);
-}
-static inline zend_bool zend_str_equals_str_ci(zend_string *str1, zend_string *str2) {
+static inline zend_bool zend_string_equals_str_ci(zend_string *str1, zend_string *str2) {
return str1->len == str2->len
&& !zend_binary_strcasecmp(str1->val, str1->len, str2->val, str2->len);
}
-#define zend_str_equals_literal(str, c) \
- ((str)->len == sizeof(c) - 1 && !memcmp((str)->val, (c), sizeof(c) - 1))
-#define zend_str_equals_literal_ci(str, c) \
+#define zend_string_equals_literal_ci(str, c) \
((str)->len == sizeof(c) - 1 \
&& !zend_binary_strcasecmp((str)->val, (str)->len, (c), sizeof(c) - 1))
result->op_type = IS_CV;
result->u.op.var = lookup_cv(CG(active_op_array), name TSRMLS_CC);
- if (zend_str_equals_literal(name, "this")) {
+ if (zend_string_equals_literal(name, "this")) {
CG(active_op_array)->this_var = result->u.op.var;
}
return SUCCESS;
static zend_bool is_this_fetch(zend_ast *ast) {
if (ast->kind == ZEND_AST_VAR && ast->child[0]->kind == ZEND_AST_ZVAL) {
zval *name = zend_ast_get_zval(ast->child[0]);
- return Z_TYPE_P(name) == IS_STRING && zend_str_equals_literal(Z_STR_P(name), "this");
+ return Z_TYPE_P(name) == IS_STRING && zend_string_equals_literal(Z_STR_P(name), "this");
}
return 0;
{
zend_string *name1 = zval_get_string(zend_ast_get_zval(var_ast->child[0]));
zend_string *name2 = zval_get_string(zend_ast_get_zval(expr_ast->child[0]));
- zend_bool result = zend_str_equals_str(name1, name2);
+ zend_bool result = zend_string_equals(name1, name2);
zend_string_release(name1);
zend_string_release(name2);
return result;
int zend_try_compile_special_func(
znode *result, zend_string *lcname, zend_ast_list *args TSRMLS_DC
) {
- if (zend_str_equals_literal(lcname, "strlen")) {
+ if (zend_string_equals_literal(lcname, "strlen")) {
return zend_compile_func_strlen(result, args TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "is_null")) {
+ } else if (zend_string_equals_literal(lcname, "is_null")) {
return zend_compile_func_typecheck(result, args, IS_NULL TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "is_bool")) {
+ } else if (zend_string_equals_literal(lcname, "is_bool")) {
return zend_compile_func_typecheck(result, args, _IS_BOOL TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "is_long")) {
+ } else if (zend_string_equals_literal(lcname, "is_long")) {
return zend_compile_func_typecheck(result, args, IS_LONG TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "is_float")) {
+ } else if (zend_string_equals_literal(lcname, "is_float")) {
return zend_compile_func_typecheck(result, args, IS_DOUBLE TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "is_string")) {
+ } else if (zend_string_equals_literal(lcname, "is_string")) {
return zend_compile_func_typecheck(result, args, IS_STRING TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "is_array")) {
+ } else if (zend_string_equals_literal(lcname, "is_array")) {
return zend_compile_func_typecheck(result, args, IS_ARRAY TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "is_object")) {
+ } else if (zend_string_equals_literal(lcname, "is_object")) {
return zend_compile_func_typecheck(result, args, IS_OBJECT TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "is_resource")) {
+ } else if (zend_string_equals_literal(lcname, "is_resource")) {
return zend_compile_func_typecheck(result, args, IS_RESOURCE TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "defined")) {
+ } else if (zend_string_equals_literal(lcname, "defined")) {
return zend_compile_func_defined(result, args TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "call_user_func_array")) {
+ } else if (zend_string_equals_literal(lcname, "call_user_func_array")) {
return zend_compile_func_cufa(result, args, lcname TSRMLS_CC);
- } else if (zend_str_equals_literal(lcname, "call_user_func")) {
+ } else if (zend_string_equals_literal(lcname, "call_user_func")) {
return zend_compile_func_cuf(result, args, lcname TSRMLS_CC);
} else {
return FAILURE;
}
zend_bool zend_is_constructor(zend_string *name) {
- return zend_str_equals_literal_ci(name, ZEND_CONSTRUCTOR_FUNC_NAME);
+ return zend_string_equals_literal_ci(name, ZEND_CONSTRUCTOR_FUNC_NAME);
}
void zend_compile_static_call(znode *result, zend_ast *ast, int type TSRMLS_DC) {
zend_ast *value_ast = declare_ast->child[1];
zend_string *name = zend_ast_get_str(name_ast);
- if (zend_str_equals_literal_ci(name, "encoding")) {
+ if (zend_string_equals_literal_ci(name, "encoding")) {
if (value_ast->kind != ZEND_AST_ZVAL) {
zend_error_noreturn(E_COMPILE_ERROR, "Encoding must be a literal");
}
zend_ast *value_ast = declare_ast->child[1];
zend_string *name = zend_ast_get_str(name_ast);
- if (zend_str_equals_literal_ci(name, "ticks")) {
+ if (zend_string_equals_literal_ci(name, "ticks")) {
zval value_zv;
zend_const_expr_to_zval(&value_zv, value_ast TSRMLS_CC);
convert_to_long(&value_zv);
ZVAL_COPY_VALUE(&CG(declarables).ticks, &value_zv);
zval_dtor(&value_zv);
- } else if (zend_str_equals_literal_ci(name, "encoding")) {
+ } else if (zend_string_equals_literal_ci(name, "encoding")) {
/* Encoding declaration was already handled during parsing. Here we
* only check that it is the first statement in the file. */
uint32_t num = CG(active_op_array)->last;
if (EX_VAR_TO_NUM(var_node.u.op.var) != i) {
zend_error_noreturn(E_COMPILE_ERROR, "Redefinition of parameter $%s",
name->val);
- } else if (zend_str_equals_literal(name, "this")) {
+ } 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");
}
zend_bool by_ref = var_ast->attr;
zval zv;
- if (zend_str_equals_literal(name, "this")) {
+ if (zend_string_equals_literal(name, "this")) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use $this as lexical variable");
}
}
if (in_interface) {
- if (zend_str_equals_literal(lcname, ZEND_CALL_FUNC_NAME)) {
+ if (zend_string_equals_literal(lcname, ZEND_CALL_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __call() must have "
"public visibility and cannot be static");
}
- } else if (zend_str_equals_literal(lcname, ZEND_CALLSTATIC_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_CALLSTATIC_FUNC_NAME)) {
if (!is_public || !is_static) {
zend_error(E_WARNING, "The magic method __callStatic() must have "
"public visibility and be static");
}
- } else if (zend_str_equals_literal(lcname, ZEND_GET_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_GET_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __get() must have "
"public visibility and cannot be static");
}
- } else if (zend_str_equals_literal(lcname, ZEND_SET_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_SET_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __set() must have "
"public visibility and cannot be static");
}
- } else if (zend_str_equals_literal(lcname, ZEND_UNSET_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_UNSET_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __unset() must have "
"public visibility and cannot be static");
}
- } else if (zend_str_equals_literal(lcname, ZEND_ISSET_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_ISSET_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __isset() must have "
"public visibility and cannot be static");
}
- } else if (zend_str_equals_literal(lcname, ZEND_TOSTRING_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_TOSTRING_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __toString() must have "
"public visibility and cannot be static");
}
- } else if (zend_str_equals_literal(lcname, ZEND_INVOKE_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_INVOKE_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __invoke() must have "
"public visibility and cannot be static");
}
- } else if (zend_str_equals_literal(lcname, ZEND_DEBUGINFO_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_DEBUGINFO_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __debugInfo() must have "
"public visibility and cannot be static");
}
}
} else {
- if (!in_trait && zend_str_equals_str_ci(lcname, ce->name)) {
+ if (!in_trait && zend_string_equals_str_ci(lcname, ce->name)) {
if (!ce->constructor) {
ce->constructor = (zend_function *) op_array;
}
- } else if (zend_str_equals_literal(lcname, ZEND_CONSTRUCTOR_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_CONSTRUCTOR_FUNC_NAME)) {
if (CG(active_class_entry)->constructor) {
zend_error(E_STRICT, "Redefining already defined constructor for class %s",
ce->name->val);
}
ce->constructor = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_DESTRUCTOR_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_DESTRUCTOR_FUNC_NAME)) {
ce->destructor = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_CLONE_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_CLONE_FUNC_NAME)) {
ce->clone = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_CALL_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_CALL_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __call() must have "
"public visibility and cannot be static");
}
ce->__call = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_CALLSTATIC_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_CALLSTATIC_FUNC_NAME)) {
if (!is_public || !is_static) {
zend_error(E_WARNING, "The magic method __callStatic() must have "
"public visibility and be static");
}
ce->__callstatic = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_GET_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_GET_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __get() must have "
"public visibility and cannot be static");
}
ce->__get = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_SET_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_SET_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __set() must have "
"public visibility and cannot be static");
}
ce->__set = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_UNSET_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_UNSET_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __unset() must have "
"public visibility and cannot be static");
}
ce->__unset = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_ISSET_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_ISSET_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __isset() must have "
"public visibility and cannot be static");
}
ce->__isset = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_TOSTRING_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_TOSTRING_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __toString() must have "
"public visibility and cannot be static");
}
ce->__tostring = (zend_function *) op_array;
- } else if (zend_str_equals_literal(lcname, ZEND_INVOKE_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_INVOKE_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __invoke() must have "
"public visibility and cannot be static");
}
- } else if (zend_str_equals_literal(lcname, ZEND_DEBUGINFO_FUNC_NAME)) {
+ } else if (zend_string_equals_literal(lcname, ZEND_DEBUGINFO_FUNC_NAME)) {
if (!is_public || is_static) {
zend_error(E_WARNING, "The magic method __debugInfo() must have "
"public visibility and cannot be static");
if (CG(current_import_function)) {
zend_string *import_name = zend_hash_find_ptr(CG(current_import_function), lcname);
- if (import_name && !zend_str_equals_str_ci(lcname, import_name)) {
+ if (import_name && !zend_string_equals_str_ci(lcname, import_name)) {
zend_error(E_COMPILE_ERROR, "Cannot declare function %s "
"because the name is already in use", name->val);
}
}
- if (zend_str_equals_literal(lcname, ZEND_AUTOLOAD_FUNC_NAME)
+ if (zend_string_equals_literal(lcname, ZEND_AUTOLOAD_FUNC_NAME)
&& zend_ast_get_list(params_ast)->children != 1
) {
zend_error_noreturn(E_COMPILE_ERROR, "%s() must take exactly 1 argument",
zend_string_addref(name);
}
- if (import_name && !zend_str_equals_str_ci(lcname, import_name)) {
+ if (import_name && !zend_string_equals_str_ci(lcname, import_name)) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare class %s "
"because the name is already in use", name->val);
}
static void zend_check_already_in_use(
uint32_t type, zend_string *old_name, zend_string *new_name, zend_string *check_name
) {
- if (zend_str_equals_str_ci(old_name, check_name)) {
+ if (zend_string_equals_str_ci(old_name, check_name)) {
return;
}
new_name = zend_string_copy(old_name);
if (!current_ns) {
- if (type == T_CLASS && zend_str_equals_literal(new_name, "strict")) {
+ if (type == T_CLASS && zend_string_equals_literal(new_name, "strict")) {
zend_error_noreturn(E_COMPILE_ERROR,
"You seem to be trying to use a different language...");
}
zend_str_tolower_copy(lookup_name->val, new_name->val, new_name->len);
}
- if (type == T_CLASS && (zend_str_equals_literal(lookup_name, "self")
- || zend_str_equals_literal(lookup_name, "parent"))
+ if (type == T_CLASS && (zend_string_equals_literal(lookup_name, "self")
+ || zend_string_equals_literal(lookup_name, "parent"))
) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use %s as %s because '%s' "
"is a special class name", old_name->val, new_name->val, new_name->val);
if (CG(current_import_const)
&& (import_name = zend_hash_find_ptr(CG(current_import_const), name))
) {
- if (!zend_str_equals_str(import_name, name)) {
+ if (!zend_string_equals(import_name, name)) {
zend_error(E_COMPILE_ERROR, "Cannot declare const %s because "
"the name is already in use", name->val);
}