@@ -1960,82 +1960,66 @@ ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *mod
1960
1960
1961
1961
ZEND_API void zend_check_magic_method_implementation (const zend_class_entry * ce , const zend_function * fptr , int error_type ) /* {{{ */
1962
1962
{
1963
- char lcname [16 ];
1964
- size_t name_len ;
1963
+ zend_string * lcname ;
1965
1964
1966
1965
if (ZSTR_VAL (fptr -> common .function_name )[0 ] != '_'
1967
1966
|| ZSTR_VAL (fptr -> common .function_name )[1 ] != '_' ) {
1968
1967
return ;
1969
1968
}
1970
1969
1971
- /* we don't care if the function name is longer, in fact lowercasing only
1972
- * the beginning of the name speeds up the check process */
1973
- name_len = ZSTR_LEN (fptr -> common .function_name );
1974
- zend_str_tolower_copy (lcname , ZSTR_VAL (fptr -> common .function_name ), MIN (name_len , sizeof (lcname )- 1 ));
1975
- lcname [sizeof (lcname )- 1 ] = '\0' ; /* zend_str_tolower_copy won't necessarily set the zero byte */
1970
+ lcname = zend_string_tolower (fptr -> common .function_name );
1976
1971
1977
- if (name_len == sizeof ( ZEND_DESTRUCTOR_FUNC_NAME ) - 1 && ! memcmp ( lcname , ZEND_DESTRUCTOR_FUNC_NAME , sizeof ( ZEND_DESTRUCTOR_FUNC_NAME ) - 1 ) && fptr -> common .num_args != 0 ) {
1972
+ if (zend_string_equals_literal ( lcname , ZEND_DESTRUCTOR_FUNC_NAME ) && fptr -> common .num_args != 0 ) {
1978
1973
zend_error (error_type , "Destructor %s::%s() cannot take arguments" , ZSTR_VAL (ce -> name ), ZEND_DESTRUCTOR_FUNC_NAME );
1979
- } else if (name_len == sizeof ( ZEND_CLONE_FUNC_NAME ) - 1 && ! memcmp ( lcname , ZEND_CLONE_FUNC_NAME , sizeof ( ZEND_CLONE_FUNC_NAME ) - 1 ) && fptr -> common .num_args != 0 ) {
1974
+ } else if (zend_string_equals_literal ( lcname , ZEND_CLONE_FUNC_NAME ) && fptr -> common .num_args != 0 ) {
1980
1975
zend_error (error_type , "Method %s::%s() cannot accept any arguments" , ZSTR_VAL (ce -> name ), ZEND_CLONE_FUNC_NAME );
1981
- } else if (name_len == sizeof ( ZEND_GET_FUNC_NAME ) - 1 && ! memcmp ( lcname , ZEND_GET_FUNC_NAME , sizeof ( ZEND_GET_FUNC_NAME ) - 1 )) {
1976
+ } else if (zend_string_equals_literal ( lcname , ZEND_GET_FUNC_NAME )) {
1982
1977
if (fptr -> common .num_args != 1 ) {
1983
1978
zend_error (error_type , "Method %s::%s() must take exactly 1 argument" , ZSTR_VAL (ce -> name ), ZEND_GET_FUNC_NAME );
1984
1979
} else if (QUICK_ARG_SHOULD_BE_SENT_BY_REF (fptr , 1 )) {
1985
1980
zend_error (error_type , "Method %s::%s() cannot take arguments by reference" , ZSTR_VAL (ce -> name ), ZEND_GET_FUNC_NAME );
1986
1981
}
1987
- } else if (name_len == sizeof ( ZEND_SET_FUNC_NAME ) - 1 && ! memcmp ( lcname , ZEND_SET_FUNC_NAME , sizeof ( ZEND_SET_FUNC_NAME ) - 1 )) {
1982
+ } else if (zend_string_equals_literal ( lcname , ZEND_SET_FUNC_NAME )) {
1988
1983
if (fptr -> common .num_args != 2 ) {
1989
1984
zend_error (error_type , "Method %s::%s() must take exactly 2 arguments" , ZSTR_VAL (ce -> name ), ZEND_SET_FUNC_NAME );
1990
1985
} else if (QUICK_ARG_SHOULD_BE_SENT_BY_REF (fptr , 1 ) || QUICK_ARG_SHOULD_BE_SENT_BY_REF (fptr , 2 )) {
1991
1986
zend_error (error_type , "Method %s::%s() cannot take arguments by reference" , ZSTR_VAL (ce -> name ), ZEND_SET_FUNC_NAME );
1992
1987
}
1993
- } else if (name_len == sizeof ( ZEND_UNSET_FUNC_NAME ) - 1 && ! memcmp ( lcname , ZEND_UNSET_FUNC_NAME , sizeof ( ZEND_UNSET_FUNC_NAME ) - 1 )) {
1988
+ } else if (zend_string_equals_literal ( lcname , ZEND_UNSET_FUNC_NAME )) {
1994
1989
if (fptr -> common .num_args != 1 ) {
1995
1990
zend_error (error_type , "Method %s::%s() must take exactly 1 argument" , ZSTR_VAL (ce -> name ), ZEND_UNSET_FUNC_NAME );
1996
1991
} else if (QUICK_ARG_SHOULD_BE_SENT_BY_REF (fptr , 1 )) {
1997
1992
zend_error (error_type , "Method %s::%s() cannot take arguments by reference" , ZSTR_VAL (ce -> name ), ZEND_UNSET_FUNC_NAME );
1998
1993
}
1999
- } else if (name_len == sizeof ( ZEND_ISSET_FUNC_NAME ) - 1 && ! memcmp ( lcname , ZEND_ISSET_FUNC_NAME , sizeof ( ZEND_ISSET_FUNC_NAME ) - 1 )) {
1994
+ } else if (zend_string_equals_literal ( lcname , ZEND_ISSET_FUNC_NAME )) {
2000
1995
if (fptr -> common .num_args != 1 ) {
2001
1996
zend_error (error_type , "Method %s::%s() must take exactly 1 argument" , ZSTR_VAL (ce -> name ), ZEND_ISSET_FUNC_NAME );
2002
1997
} else if (QUICK_ARG_SHOULD_BE_SENT_BY_REF (fptr , 1 )) {
2003
1998
zend_error (error_type , "Method %s::%s() cannot take arguments by reference" , ZSTR_VAL (ce -> name ), ZEND_ISSET_FUNC_NAME );
2004
1999
}
2005
- } else if (name_len == sizeof ( ZEND_CALL_FUNC_NAME ) - 1 && ! memcmp ( lcname , ZEND_CALL_FUNC_NAME , sizeof ( ZEND_CALL_FUNC_NAME ) - 1 )) {
2000
+ } else if (zend_string_equals_literal ( lcname , ZEND_CALL_FUNC_NAME )) {
2006
2001
if (fptr -> common .num_args != 2 ) {
2007
2002
zend_error (error_type , "Method %s::%s() must take exactly 2 arguments" , ZSTR_VAL (ce -> name ), ZEND_CALL_FUNC_NAME );
2008
2003
} else if (QUICK_ARG_SHOULD_BE_SENT_BY_REF (fptr , 1 ) || QUICK_ARG_SHOULD_BE_SENT_BY_REF (fptr , 2 )) {
2009
2004
zend_error (error_type , "Method %s::%s() cannot take arguments by reference" , ZSTR_VAL (ce -> name ), ZEND_CALL_FUNC_NAME );
2010
2005
}
2011
- } else if (name_len == sizeof (ZEND_CALLSTATIC_FUNC_NAME ) - 1 &&
2012
- !memcmp (lcname , ZEND_CALLSTATIC_FUNC_NAME , sizeof (ZEND_CALLSTATIC_FUNC_NAME )- 1 )
2013
- ) {
2006
+ } else if (zend_string_equals_literal (lcname , ZEND_CALLSTATIC_FUNC_NAME )) {
2014
2007
if (fptr -> common .num_args != 2 ) {
2015
2008
zend_error (error_type , "Method %s::__callStatic() must take exactly 2 arguments" , ZSTR_VAL (ce -> name ));
2016
2009
} else if (QUICK_ARG_SHOULD_BE_SENT_BY_REF (fptr , 1 ) || QUICK_ARG_SHOULD_BE_SENT_BY_REF (fptr , 2 )) {
2017
2010
zend_error (error_type , "Method %s::__callStatic() cannot take arguments by reference" , ZSTR_VAL (ce -> name ));
2018
2011
}
2019
- } else if (name_len == sizeof (ZEND_TOSTRING_FUNC_NAME ) - 1 &&
2020
- !memcmp (lcname , ZEND_TOSTRING_FUNC_NAME , sizeof (ZEND_TOSTRING_FUNC_NAME )- 1 ) && fptr -> common .num_args != 0
2021
- ) {
2012
+ } else if (zend_string_equals_literal (lcname , ZEND_TOSTRING_FUNC_NAME ) && fptr -> common .num_args != 0 ) {
2022
2013
zend_error (error_type , "Method %s::__toString() cannot take arguments" , ZSTR_VAL (ce -> name ));
2023
- } else if (name_len == sizeof (ZEND_DEBUGINFO_FUNC_NAME ) - 1 &&
2024
- !memcmp (lcname , ZEND_DEBUGINFO_FUNC_NAME , sizeof (ZEND_DEBUGINFO_FUNC_NAME )- 1 ) && fptr -> common .num_args != 0 ) {
2014
+ } else if (zend_string_equals_literal (lcname , ZEND_DEBUGINFO_FUNC_NAME ) && fptr -> common .num_args != 0 ) {
2025
2015
zend_error (error_type , "Method %s::__debugInfo() cannot take arguments" , ZSTR_VAL (ce -> name ));
2026
- } else if (
2027
- name_len == sizeof ("__serialize" ) - 1
2028
- && !memcmp (lcname , "__serialize" , sizeof ("__serialize" ) - 1 )
2029
- && fptr -> common .num_args != 0
2030
- ) {
2016
+ } else if (zend_string_equals_literal (lcname , "__serialize" ) && fptr -> common .num_args != 0 ) {
2031
2017
zend_error (error_type , "Method %s::__serialize() cannot take arguments" , ZSTR_VAL (ce -> name ));
2032
- } else if (
2033
- name_len == sizeof ("__unserialize" ) - 1
2034
- && !memcmp (lcname , "__unserialize" , sizeof ("__unserialize" ) - 1 )
2035
- && fptr -> common .num_args != 1
2036
- ) {
2018
+ } else if (zend_string_equals_literal (lcname , "__unserialize" ) && fptr -> common .num_args != 1 ) {
2037
2019
zend_error (error_type , "Method %s::__unserialize() must take exactly 1 argument" , ZSTR_VAL (ce -> name ));
2038
2020
}
2021
+
2022
+ zend_string_release_ex (lcname , 0 );
2039
2023
}
2040
2024
/* }}} */
2041
2025
0 commit comments