3

On writing an extension for php (5.3) i want to access the zend_class_entry pointer on a static method.

On non static methods i can use the getThis() macro and within Z_OBJCE_P macro like this:

zend_class_entry ce* = Z_OBJCE_P(getThis());

Now the problem: on static methods the getThis() macro returns a null pointer, so i can not use the Z_OBJCE_P macro.

Has anyone a solution for me to access the zend_class_entry from a static method??

1 Answer 1

3

it is really interesting: on static methods you can access the scope like this

zend_class_entry* ce = 0L;
if (EG(called_scope)) {
    ce = EG(called_scope);
} else if (!EG(scope))  {
    ce = EG(scope);
}

the EG Macro access a lot of global and context specific variables, also the calling scope, the calling class of the static method.

Sign up to request clarification or add additional context in comments.

1 Comment

Note the called scope is not the same as the (calling) scope, the first is related to LSB, the second is probably what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.