Skip to content

Working with custom method attributes and gen_stub.php #2254

Discussion options

You must be logged in to vote

Answering my own question, in case this ever ends up in someone's searches

You can add arbitrary attributes to an extension class' methods like so:

extern zend_class_entry *redis_ce;

static void redis_add_method_attribute(zend_class_entry *ce, const char *fn, size_t fnlen, zend_string *attr) {
    zval *zfn;

    zfn = zend_hash_str_find(&ce->function_table, fn, fnlen);
    ZEND_ASSERT(zfn != NULL);

    zend_add_function_attribute(Z_FUNC_P(zfn), attr, 0);
}

static void register_redis_attributes(void) {
    zend_string *attribute_name_Local = zend_string_init_interned("Local", sizeof("Local") - 1, 1);
    zend_string *attribute_name_RedisCommand = zend_string_init_interned("RedisCommand", 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by michael-grunder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant