@@ -2138,6 +2138,44 @@ ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce,
2138
2138
}
2139
2139
/* }}} */
2140
2140
2141
+ ZEND_API void zend_add_magic_method (zend_class_entry * ce , zend_function * fptr , zend_string * lcname )
2142
+ {
2143
+ if (ZSTR_VAL (lcname )[0 ] != '_' || ZSTR_VAL (lcname )[1 ] != '_' ) {
2144
+ /* pass */
2145
+ } else if (zend_string_equals_literal (lcname , ZEND_CLONE_FUNC_NAME )) {
2146
+ ce -> clone = fptr ;
2147
+ } else if (zend_string_equals_literal (lcname , ZEND_CONSTRUCTOR_FUNC_NAME )) {
2148
+ ce -> constructor = fptr ;
2149
+ ce -> constructor -> common .fn_flags |= ZEND_ACC_CTOR ;
2150
+ } else if (zend_string_equals_literal (lcname , ZEND_DESTRUCTOR_FUNC_NAME )) {
2151
+ ce -> destructor = fptr ;
2152
+ } else if (zend_string_equals_literal (lcname , ZEND_GET_FUNC_NAME )) {
2153
+ ce -> __get = fptr ;
2154
+ ce -> ce_flags |= ZEND_ACC_USE_GUARDS ;
2155
+ } else if (zend_string_equals_literal (lcname , ZEND_SET_FUNC_NAME )) {
2156
+ ce -> __set = fptr ;
2157
+ ce -> ce_flags |= ZEND_ACC_USE_GUARDS ;
2158
+ } else if (zend_string_equals_literal (lcname , ZEND_CALL_FUNC_NAME )) {
2159
+ ce -> __call = fptr ;
2160
+ } else if (zend_string_equals_literal (lcname , ZEND_UNSET_FUNC_NAME )) {
2161
+ ce -> __unset = fptr ;
2162
+ ce -> ce_flags |= ZEND_ACC_USE_GUARDS ;
2163
+ } else if (zend_string_equals_literal (lcname , ZEND_ISSET_FUNC_NAME )) {
2164
+ ce -> __isset = fptr ;
2165
+ ce -> ce_flags |= ZEND_ACC_USE_GUARDS ;
2166
+ } else if (zend_string_equals_literal (lcname , ZEND_CALLSTATIC_FUNC_NAME )) {
2167
+ ce -> __callstatic = fptr ;
2168
+ } else if (zend_string_equals_literal (lcname , ZEND_TOSTRING_FUNC_NAME )) {
2169
+ ce -> __tostring = fptr ;
2170
+ } else if (zend_string_equals_literal (lcname , ZEND_DEBUGINFO_FUNC_NAME )) {
2171
+ ce -> __debugInfo = fptr ;
2172
+ } else if (zend_string_equals_literal (lcname , "__serialize" )) {
2173
+ ce -> __serialize = fptr ;
2174
+ } else if (zend_string_equals_literal (lcname , "__unserialize" )) {
2175
+ ce -> __unserialize = fptr ;
2176
+ }
2177
+ }
2178
+
2141
2179
/* registers all functions in *library_functions in the function hash */
2142
2180
ZEND_API int zend_register_functions (zend_class_entry * scope , const zend_function_entry * functions , HashTable * function_table , int type ) /* {{{ */
2143
2181
{
@@ -2294,47 +2332,9 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
2294
2332
}
2295
2333
2296
2334
if (scope ) {
2297
- /* Look for ctor, dtor, clone */
2298
- if (ZSTR_VAL (lowercase_name )[0 ] != '_' || ZSTR_VAL (lowercase_name )[1 ] != '_' ) {
2299
- reg_function = NULL ;
2300
- } else if (zend_string_equals_literal (lowercase_name , ZEND_CONSTRUCTOR_FUNC_NAME )) {
2301
- scope -> constructor = reg_function ;
2302
- scope -> constructor -> common .fn_flags |= ZEND_ACC_CTOR ;
2303
- } else if (zend_string_equals_literal (lowercase_name , ZEND_DESTRUCTOR_FUNC_NAME )) {
2304
- scope -> destructor = reg_function ;
2305
- } else if (zend_string_equals_literal (lowercase_name , ZEND_CLONE_FUNC_NAME )) {
2306
- scope -> clone = reg_function ;
2307
- } else if (zend_string_equals_literal (lowercase_name , ZEND_CALL_FUNC_NAME )) {
2308
- scope -> __call = reg_function ;
2309
- } else if (zend_string_equals_literal (lowercase_name , ZEND_CALLSTATIC_FUNC_NAME )) {
2310
- scope -> __callstatic = reg_function ;
2311
- } else if (zend_string_equals_literal (lowercase_name , ZEND_TOSTRING_FUNC_NAME )) {
2312
- scope -> __tostring = reg_function ;
2313
- } else if (zend_string_equals_literal (lowercase_name , ZEND_GET_FUNC_NAME )) {
2314
- scope -> __get = reg_function ;
2315
- scope -> ce_flags |= ZEND_ACC_USE_GUARDS ;
2316
- } else if (zend_string_equals_literal (lowercase_name , ZEND_SET_FUNC_NAME )) {
2317
- scope -> __set = reg_function ;
2318
- scope -> ce_flags |= ZEND_ACC_USE_GUARDS ;
2319
- } else if (zend_string_equals_literal (lowercase_name , ZEND_UNSET_FUNC_NAME )) {
2320
- scope -> __unset = reg_function ;
2321
- scope -> ce_flags |= ZEND_ACC_USE_GUARDS ;
2322
- } else if (zend_string_equals_literal (lowercase_name , ZEND_ISSET_FUNC_NAME )) {
2323
- scope -> __isset = reg_function ;
2324
- scope -> ce_flags |= ZEND_ACC_USE_GUARDS ;
2325
- } else if (zend_string_equals_literal (lowercase_name , ZEND_DEBUGINFO_FUNC_NAME )) {
2326
- scope -> __debugInfo = reg_function ;
2327
- } else if (zend_string_equals_literal (lowercase_name , "__serialize" )) {
2328
- scope -> __serialize = reg_function ;
2329
- } else if (zend_string_equals_literal (lowercase_name , "__unserialize" )) {
2330
- scope -> __unserialize = reg_function ;
2331
- } else {
2332
- reg_function = NULL ;
2333
- }
2334
- if (reg_function ) {
2335
- zend_check_magic_method_implementation (
2336
- scope , reg_function , lowercase_name , E_CORE_ERROR );
2337
- }
2335
+ zend_check_magic_method_implementation (
2336
+ scope , reg_function , lowercase_name , E_CORE_ERROR );
2337
+ zend_add_magic_method (scope , reg_function , lowercase_name );
2338
2338
}
2339
2339
ptr ++ ;
2340
2340
count ++ ;
0 commit comments