Skip to content

Commit 12df96e

Browse files
committed
MFH
- 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.
1 parent 4651b7f commit 12df96e

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

ext/reflection/php_reflection.c

+29-11
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,23 @@ ZEND_METHOD(reflection_function, isClosure)
15501550
}
15511551
/* }}} */
15521552

1553+
/* {{{ proto public bool ReflectionFunction::getClosureThis()
1554+
Returns this pointer bound to closure */
1555+
ZEND_METHOD(reflection_function, getClosureThis)
1556+
{
1557+
reflection_object *intern;
1558+
zend_function *fptr;
1559+
zval* closure_this;
1560+
1561+
METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
1562+
GET_REFLECTION_OBJECT_PTR(fptr);
1563+
if (intern->obj) {
1564+
closure_this = zend_get_closure_this_ptr(intern->obj TSRMLS_CC);
1565+
RETURN_ZVAL(closure_this, 1, 0);
1566+
}
1567+
}
1568+
/* }}} */
1569+
15531570
/* {{{ proto public bool ReflectionFunction::isInternal()
15541571
Returns whether this is an internal function */
15551572
ZEND_METHOD(reflection_function, isInternal)
@@ -4927,25 +4944,26 @@ ZEND_END_ARG_INFO()
49274944
static const zend_function_entry reflection_function_abstract_functions[] = {
49284945
ZEND_ME(reflection, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
49294946
PHP_ABSTRACT_ME(reflection_function, __toString, NULL)
4947+
ZEND_ME(reflection_function, inNamespace, NULL, 0)
49304948
ZEND_ME(reflection_function, isClosure, NULL, 0)
4949+
ZEND_ME(reflection_function, isDeprecated, NULL, 0)
49314950
ZEND_ME(reflection_function, isInternal, NULL, 0)
49324951
ZEND_ME(reflection_function, isUserDefined, NULL, 0)
4933-
ZEND_ME(reflection_function, getName, NULL, 0)
4934-
ZEND_ME(reflection_function, getFileName, NULL, 0)
4935-
ZEND_ME(reflection_function, getStartLine, NULL, 0)
4936-
ZEND_ME(reflection_function, getEndLine, NULL, 0)
4952+
ZEND_ME(reflection_function, getClosureThis, NULL, 0)
49374953
ZEND_ME(reflection_function, getDocComment, NULL, 0)
4938-
ZEND_ME(reflection_function, getStaticVariables, NULL, 0)
4939-
ZEND_ME(reflection_function, returnsReference, NULL, 0)
4940-
ZEND_ME(reflection_function, getParameters, NULL, 0)
4941-
ZEND_ME(reflection_function, getNumberOfParameters, NULL, 0)
4942-
ZEND_ME(reflection_function, getNumberOfRequiredParameters, NULL, 0)
4954+
ZEND_ME(reflection_function, getEndLine, NULL, 0)
49434955
ZEND_ME(reflection_function, getExtension, NULL, 0)
49444956
ZEND_ME(reflection_function, getExtensionName, NULL, 0)
4945-
ZEND_ME(reflection_function, isDeprecated, NULL, 0)
4946-
ZEND_ME(reflection_function, inNamespace, NULL, 0)
4957+
ZEND_ME(reflection_function, getFileName, NULL, 0)
4958+
ZEND_ME(reflection_function, getName, NULL, 0)
49474959
ZEND_ME(reflection_function, getNamespaceName, NULL, 0)
4960+
ZEND_ME(reflection_function, getNumberOfParameters, NULL, 0)
4961+
ZEND_ME(reflection_function, getNumberOfRequiredParameters, NULL, 0)
4962+
ZEND_ME(reflection_function, getParameters, NULL, 0)
49484963
ZEND_ME(reflection_function, getShortName, NULL, 0)
4964+
ZEND_ME(reflection_function, getStartLine, NULL, 0)
4965+
ZEND_ME(reflection_function, getStaticVariables, NULL, 0)
4966+
ZEND_ME(reflection_function, returnsReference, NULL, 0)
49494967
{NULL, NULL, NULL}
49504968
};
49514969

0 commit comments

Comments
 (0)