Skip to content

Commit

Permalink
MFH
Browse files Browse the repository at this point in the history
- Add ReflectionFunctionAbstract::getClosureThis()
[DOC]
# Returns the this pointer bound to the closure is the relection object
# points to closure. Since not all closures have a bound this, the method
# cannot be used to differentiate between normal functions/methods and
# closures. Instead ReflectionFunctionAbstract::isClosure() has to be used.
  • Loading branch information
helly25 committed Jan 3, 2009
1 parent 4651b7f commit 12df96e
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,23 @@ ZEND_METHOD(reflection_function, isClosure)
}
/* }}} */

/* {{{ proto public bool ReflectionFunction::getClosureThis()
Returns this pointer bound to closure */
ZEND_METHOD(reflection_function, getClosureThis)
{
reflection_object *intern;
zend_function *fptr;
zval* closure_this;

METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
if (intern->obj) {
closure_this = zend_get_closure_this_ptr(intern->obj TSRMLS_CC);
RETURN_ZVAL(closure_this, 1, 0);
}
}
/* }}} */

/* {{{ proto public bool ReflectionFunction::isInternal()
Returns whether this is an internal function */
ZEND_METHOD(reflection_function, isInternal)
Expand Down Expand Up @@ -4927,25 +4944,26 @@ ZEND_END_ARG_INFO()
static const zend_function_entry reflection_function_abstract_functions[] = {
ZEND_ME(reflection, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
PHP_ABSTRACT_ME(reflection_function, __toString, NULL)
ZEND_ME(reflection_function, inNamespace, NULL, 0)
ZEND_ME(reflection_function, isClosure, NULL, 0)
ZEND_ME(reflection_function, isDeprecated, NULL, 0)
ZEND_ME(reflection_function, isInternal, NULL, 0)
ZEND_ME(reflection_function, isUserDefined, NULL, 0)
ZEND_ME(reflection_function, getName, NULL, 0)
ZEND_ME(reflection_function, getFileName, NULL, 0)
ZEND_ME(reflection_function, getStartLine, NULL, 0)
ZEND_ME(reflection_function, getEndLine, NULL, 0)
ZEND_ME(reflection_function, getClosureThis, NULL, 0)
ZEND_ME(reflection_function, getDocComment, NULL, 0)
ZEND_ME(reflection_function, getStaticVariables, NULL, 0)
ZEND_ME(reflection_function, returnsReference, NULL, 0)
ZEND_ME(reflection_function, getParameters, NULL, 0)
ZEND_ME(reflection_function, getNumberOfParameters, NULL, 0)
ZEND_ME(reflection_function, getNumberOfRequiredParameters, NULL, 0)
ZEND_ME(reflection_function, getEndLine, NULL, 0)
ZEND_ME(reflection_function, getExtension, NULL, 0)
ZEND_ME(reflection_function, getExtensionName, NULL, 0)
ZEND_ME(reflection_function, isDeprecated, NULL, 0)
ZEND_ME(reflection_function, inNamespace, NULL, 0)
ZEND_ME(reflection_function, getFileName, NULL, 0)
ZEND_ME(reflection_function, getName, NULL, 0)
ZEND_ME(reflection_function, getNamespaceName, NULL, 0)
ZEND_ME(reflection_function, getNumberOfParameters, NULL, 0)
ZEND_ME(reflection_function, getNumberOfRequiredParameters, NULL, 0)
ZEND_ME(reflection_function, getParameters, NULL, 0)
ZEND_ME(reflection_function, getShortName, NULL, 0)
ZEND_ME(reflection_function, getStartLine, NULL, 0)
ZEND_ME(reflection_function, getStaticVariables, NULL, 0)
ZEND_ME(reflection_function, returnsReference, NULL, 0)
{NULL, NULL, NULL}
};

Expand Down

0 comments on commit 12df96e

Please sign in to comment.