@@ -1016,23 +1016,23 @@ static v8::MaybeLocal<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_cl
1016
1016
}
1017
1017
1018
1018
if (has_json_serializable) {
1019
- void *ptr;
1020
- zend_string *key ;
1021
- ZEND_HASH_FOREACH_STR_KEY_PTR (&ce-> function_table , key, ptr) {
1022
- zend_function *method_ptr = reinterpret_cast <zend_function *>(ptr );
1023
- if (strcmp ( ZSTR_VAL (method_ptr-> common . function_name ), " jsonSerialize " ) == 0 ) {
1024
- v8::Local<v8::String> method_name = V8JS_SYM ( " toJSON " );
1025
- v8::Local<v8::FunctionTemplate> ft ;
1026
-
1027
- ft = v8::FunctionTemplate::New (isolate, v8js_php_callback,
1028
- v8::External ::New (( isolate), method_ptr));
1029
-
1030
- v8js_function_tmpl_t *persistent_ft = &ctx-> method_tmpls [ std::make_pair (ce, method_ptr)];
1031
- persistent_ft-> Reset (isolate, ft) ;
1032
-
1033
- newobj. ToLocalChecked ()-> CreateDataProperty (v8_context, method_name, ft-> GetFunction (v8_context). ToLocalChecked ());
1034
- }
1035
- } ZEND_HASH_FOREACH_END ();
1019
+ zend_string *jsonserialize_str = zend_string_init
1020
+ ( " jsonSerialize " , sizeof ( " jsonSerialize " ) - 1 , 0 ) ;
1021
+ zend_function *jsonserialize_method_ptr = reinterpret_cast <zend_function *>
1022
+ ( zend_hash_find_ptr_lc (&ce-> function_table , jsonserialize_str) );
1023
+ if (jsonserialize_method_ptr &&
1024
+ jsonserialize_method_ptr-> common . fn_flags & ZEND_ACC_PUBLIC) {
1025
+ v8::Local<v8::String> method_name = V8JS_SYM ( " toJSON " ) ;
1026
+ v8::Local<v8::FunctionTemplate> ft;
1027
+
1028
+ ft = v8::FunctionTemplate ::New (isolate, v8js_php_callback,
1029
+ v8::External::New ((isolate), jsonserialize_method_ptr));
1030
+
1031
+ v8js_function_tmpl_t *persistent_ft = &ctx-> method_tmpls [ std::make_pair (ce, jsonserialize_method_ptr)] ;
1032
+ persistent_ft-> Reset (isolate, ft);
1033
+
1034
+ newobj. ToLocalChecked ()-> CreateDataProperty (v8_context, method_name, ft-> GetFunction (v8_context). ToLocalChecked ());
1035
+ }
1036
1036
}
1037
1037
1038
1038
if (ce == zend_ce_closure && !newobj.IsEmpty ()) {
0 commit comments