]> granicus.if.org Git - php/commitdiff
MFH
authorMarcus Boerger <helly@php.net>
Sat, 3 Jan 2009 19:08:47 +0000 (19:08 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 3 Jan 2009 19:08:47 +0000 (19:08 +0000)
- 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.

ext/reflection/php_reflection.c

index 7bef9be798b1c3cd8b596eadb339f44bebeb0c32..13cabfad8eb1ea5aa0ded107630ebccd1a2074d6 100644 (file)
@@ -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)
@@ -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}
 };