Skip to content

Instantly share code, notes, and snippets.

@amad
Created July 14, 2015 02:11
Show Gist options
  • Save amad/1dfd2d9234d21d7874b1 to your computer and use it in GitHub Desktop.
Save amad/1dfd2d9234d21d7874b1 to your computer and use it in GitHub Desktop.
PHP_FUNCTION(publicize)
{
char *classname = NULL;
int classname_len;
ulong i;
char *str;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
&classname, &classname_len) == FAILURE) {
return;
}
zend_class_entry **ce = NULL;
zend_hash_find(EG(class_table), classname, classname_len + 1, (void
**) &ce);
if(!ce) {
spprintf(&str, 0, "Class %s does not exist", classname);
zend_throw_exception(NULL, str, 0 TSRMLS_CC);
return;
}
HashTable *class_methods = &(*ce)->function_table;
if(class_methods && zend_hash_num_elements(class_methods) > 0) {
zend_hash_internal_pointer_reset(class_methods);
zend_function *method;
while(zend_hash_get_current_data(class_methods, (void **)
&method) == SUCCESS) {
method->common.fn_flags = method->common.fn_flags &
ZEND_ACC_PUBLIC;
zend_hash_move_forward(class_methods);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment