PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/reflection - php_reflection.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 0 2605 0.0 %
Date: 2014-04-16 Functions: 0 208 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 5                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2014 The PHP Group                                |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 3.01 of the PHP license,      |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.php.net/license/3_01.txt                                  |
      11             :    | If you did not receive a copy of the PHP license and are unable to   |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@php.net so we can mail you a copy immediately.               |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Timm Friebe <thekid@thekid.de>                              |
      16             :    |          George Schlossnagle <george@omniti.com>                     |
      17             :    |          Andrei Zmievski <andrei@gravitonic.com>                     |
      18             :    |          Marcus Boerger <helly@php.net>                              |
      19             :    |          Johannes Schlueter <johannes@php.net>                       |
      20             :    +----------------------------------------------------------------------+
      21             : */
      22             : 
      23             : /* $Id: 703e14113f05c361a7257390f119030d32900b40 $ */
      24             : 
      25             : #ifdef HAVE_CONFIG_H
      26             : #include "config.h"
      27             : #endif
      28             : 
      29             : #include "php.h"
      30             : #include "php_ini.h"
      31             : #include "php_reflection.h"
      32             : #include "ext/standard/info.h"
      33             : 
      34             : #include "zend.h"
      35             : #include "zend_API.h"
      36             : #include "zend_exceptions.h"
      37             : #include "zend_operators.h"
      38             : #include "zend_constants.h"
      39             : #include "zend_ini.h"
      40             : #include "zend_interfaces.h"
      41             : #include "zend_closures.h"
      42             : #include "zend_extensions.h"
      43             : 
      44             : #define reflection_update_property(object, name, value) do { \
      45             :                 zval *member; \
      46             :                 MAKE_STD_ZVAL(member); \
      47             :                 ZVAL_STRINGL(member, name, sizeof(name)-1, 1); \
      48             :                 zend_std_write_property(object, member, value, NULL TSRMLS_CC); \
      49             :                 Z_DELREF_P(value); \
      50             :                 zval_ptr_dtor(&member); \
      51             :         } while (0)
      52             : 
      53             : /* Class entry pointers */
      54             : PHPAPI zend_class_entry *reflector_ptr;
      55             : PHPAPI zend_class_entry *reflection_exception_ptr;
      56             : PHPAPI zend_class_entry *reflection_ptr;
      57             : PHPAPI zend_class_entry *reflection_function_abstract_ptr;
      58             : PHPAPI zend_class_entry *reflection_function_ptr;
      59             : PHPAPI zend_class_entry *reflection_parameter_ptr;
      60             : PHPAPI zend_class_entry *reflection_class_ptr;
      61             : PHPAPI zend_class_entry *reflection_object_ptr;
      62             : PHPAPI zend_class_entry *reflection_method_ptr;
      63             : PHPAPI zend_class_entry *reflection_property_ptr;
      64             : PHPAPI zend_class_entry *reflection_extension_ptr;
      65             : PHPAPI zend_class_entry *reflection_zend_extension_ptr;
      66             : 
      67             : #if MBO_0
      68             : ZEND_BEGIN_MODULE_GLOBALS(reflection)
      69             :         int dummy;
      70             : ZEND_END_MODULE_GLOBALS(reflection)
      71             : 
      72             : #ifdef ZTS
      73             : # define REFLECTION_G(v) \
      74             :         TSRMG(reflection_globals_id, zend_reflection_globals*, v)
      75             : extern int reflection_globals_id;
      76             : #else
      77             : # define REFLECTION_G(v) (reflection_globals.v)
      78             : extern zend_reflection_globals reflectionglobals;
      79             : #endif
      80             : 
      81             : ZEND_DECLARE_MODULE_GLOBALS(reflection)
      82             : #endif /* MBO_0 */
      83             : 
      84             : /* Method macros */
      85             : 
      86             : #define METHOD_NOTSTATIC(ce)                                                                                \
      87             :         if (!this_ptr || !instanceof_function(Z_OBJCE_P(this_ptr), ce TSRMLS_CC)) {                             \
      88             :                 php_error_docref(NULL TSRMLS_CC, E_ERROR, "%s() cannot be called statically", get_active_function_name(TSRMLS_C));        \
      89             :                 return;                                                                                             \
      90             :         }                                                                                                       \
      91             : 
      92             : /* Exception throwing macro */
      93             : #define _DO_THROW(msg)                                                                                      \
      94             :         zend_throw_exception(reflection_exception_ptr, msg, 0 TSRMLS_CC);                                       \
      95             :         return;                                                                                                 \
      96             : 
      97             : #define RETURN_ON_EXCEPTION                                                                                 \
      98             :         if (EG(exception) && Z_OBJCE_P(EG(exception)) == reflection_exception_ptr) {                            \
      99             :                 return;                                                                                             \
     100             :         }
     101             : 
     102             : #define GET_REFLECTION_OBJECT_PTR(target)                                                                   \
     103             :         intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC);                       \
     104             :         if (intern == NULL || intern->ptr == NULL) {                                                            \
     105             :                 RETURN_ON_EXCEPTION                                                                                 \
     106             :                 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Failed to retrieve the reflection object");                    \
     107             :         }                                                                                                       \
     108             :         target = intern->ptr;                                                                                   \
     109             : 
     110             : /* Class constants */
     111             : #define REGISTER_REFLECTION_CLASS_CONST_LONG(class_name, const_name, value)                                        \
     112             :         zend_declare_class_constant_long(reflection_ ## class_name ## _ptr, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
     113             : 
     114             : /* {{{ Smart string functions */
     115             : typedef struct _string {
     116             :         char *string;
     117             :         int len;
     118             :         int alloced;
     119             : } string;
     120             : 
     121           0 : static void string_init(string *str)
     122             : {
     123           0 :         str->string = (char *) emalloc(1024);
     124           0 :         str->len = 1;
     125           0 :         str->alloced = 1024;
     126           0 :         *str->string = '\0';
     127           0 : }
     128             : 
     129           0 : static string *string_printf(string *str, const char *format, ...)
     130             : {
     131             :         int len;
     132             :         va_list arg;
     133             :         char *s_tmp;
     134             : 
     135           0 :         va_start(arg, format);
     136           0 :         len = zend_vspprintf(&s_tmp, 0, format, arg);
     137           0 :         if (len) {
     138           0 :                 register int nlen = (str->len + len + (1024 - 1)) & ~(1024 - 1);
     139           0 :                 if (str->alloced < nlen) {
     140           0 :                         str->alloced = nlen;
     141           0 :                         str->string = erealloc(str->string, str->alloced);
     142             :                 }
     143           0 :                 memcpy(str->string + str->len - 1, s_tmp, len + 1);
     144           0 :                 str->len += len;
     145             :         }
     146           0 :         efree(s_tmp);
     147           0 :         va_end(arg);
     148           0 :         return str;
     149             : }
     150             : 
     151           0 : static string *string_write(string *str, char *buf, int len)
     152             : {
     153           0 :         register int nlen = (str->len + len + (1024 - 1)) & ~(1024 - 1);
     154           0 :         if (str->alloced < nlen) {
     155           0 :                 str->alloced = nlen;
     156           0 :                 str->string = erealloc(str->string, str->alloced);
     157             :         }
     158           0 :         memcpy(str->string + str->len - 1, buf, len);
     159           0 :         str->len += len;
     160           0 :         str->string[str->len - 1] = '\0';
     161           0 :         return str;
     162             : }
     163             : 
     164           0 : static string *string_append(string *str, string *append)
     165             : {
     166           0 :         if (append->len > 1) {
     167           0 :                 string_write(str, append->string, append->len - 1);
     168             :         }
     169           0 :         return str;
     170             : }
     171             : 
     172           0 : static void string_free(string *str)
     173             : {
     174           0 :         efree(str->string);
     175           0 :         str->len = 0;
     176           0 :         str->alloced = 0;
     177           0 :         str->string = NULL;
     178           0 : }
     179             : /* }}} */
     180             : 
     181             : /* {{{ Object structure */
     182             : 
     183             : /* Struct for properties */
     184             : typedef struct _property_reference {
     185             :         zend_class_entry *ce;
     186             :         zend_property_info prop;
     187             : } property_reference;
     188             : 
     189             : /* Struct for parameters */
     190             : typedef struct _parameter_reference {
     191             :         zend_uint offset;
     192             :         zend_uint required;
     193             :         struct _zend_arg_info *arg_info;
     194             :         zend_function *fptr;
     195             : } parameter_reference;
     196             : 
     197             : typedef enum {
     198             :         REF_TYPE_OTHER,      /* Must be 0 */
     199             :         REF_TYPE_FUNCTION,
     200             :         REF_TYPE_PARAMETER,
     201             :         REF_TYPE_PROPERTY,
     202             :         REF_TYPE_DYNAMIC_PROPERTY
     203             : } reflection_type_t;
     204             : 
     205             : /* Struct for reflection objects */
     206             : typedef struct {
     207             :         zend_object zo;
     208             :         void *ptr;
     209             :         reflection_type_t ref_type;
     210             :         zval *obj;
     211             :         zend_class_entry *ce;
     212             :         unsigned int ignore_visibility:1;
     213             : } reflection_object;
     214             : 
     215             : /* }}} */
     216             : 
     217             : static zend_object_handlers reflection_object_handlers;
     218             : 
     219           0 : static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) /* {{{ */
     220             : {
     221             :         zval **value;
     222             : 
     223           0 :         if (zend_hash_find(Z_OBJPROP_P(object), name, name_len, (void **) &value) == FAILURE) {
     224           0 :                 RETURN_FALSE;
     225             :         }
     226             : 
     227           0 :         MAKE_COPY_ZVAL(value, return_value);
     228             : }
     229             : /* }}} */
     230             : 
     231             : #ifdef ilia_0
     232             : static void _default_lookup_entry(zval *object, char *name, int name_len, zval **return_value TSRMLS_DC) /* {{{ */
     233             : {
     234             :         zval **value;
     235             : 
     236             :         if (zend_hash_find(Z_OBJPROP_P(object), name, name_len, (void **) &value) == FAILURE) {
     237             :                 *return_value = NULL;
     238             :         } else {
     239             :                 *return_value = *value;
     240             :         }
     241             : }
     242             : /* }}} */
     243             : #endif
     244             : 
     245           0 : static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) /* {{{ */
     246             : {
     247           0 :         zend_uint num_interfaces = ++class_entry->num_interfaces;
     248             : 
     249           0 :         class_entry->interfaces = (zend_class_entry **) realloc(class_entry->interfaces, sizeof(zend_class_entry *) * num_interfaces);
     250           0 :         class_entry->interfaces[num_interfaces - 1] = interface_entry;
     251           0 : }
     252             : /* }}} */
     253             : 
     254           0 : static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */
     255             : {
     256           0 :         if (fptr
     257             :                 && fptr->type == ZEND_INTERNAL_FUNCTION
     258           0 :                 && (fptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0)
     259             :         {
     260             :                 zend_function *copy_fptr;
     261           0 :                 copy_fptr = emalloc(sizeof(zend_function));
     262           0 :                 memcpy(copy_fptr, fptr, sizeof(zend_function));
     263           0 :                 copy_fptr->internal_function.function_name = estrdup(fptr->internal_function.function_name);
     264           0 :                 return copy_fptr;
     265             :         } else {
     266             :                 /* no copy needed */
     267           0 :                 return fptr;
     268             :         }
     269             : }
     270             : /* }}} */
     271             : 
     272           0 : static void _free_function(zend_function *fptr TSRMLS_DC) /* {{{ */
     273             : {
     274           0 :         if (fptr
     275             :                 && fptr->type == ZEND_INTERNAL_FUNCTION
     276           0 :                 && (fptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0)
     277             :         {
     278           0 :                 efree((char*)fptr->internal_function.function_name);
     279           0 :                 efree(fptr);
     280             :         }
     281           0 : }
     282             : /* }}} */
     283             : 
     284           0 : static void reflection_free_objects_storage(void *object TSRMLS_DC) /* {{{ */
     285             : {
     286           0 :         reflection_object *intern = (reflection_object *) object;
     287             :         parameter_reference *reference;
     288             :         property_reference *prop_reference;
     289             : 
     290           0 :         if (intern->ptr) {
     291           0 :                 switch (intern->ref_type) {
     292             :                 case REF_TYPE_PARAMETER:
     293           0 :                         reference = (parameter_reference*)intern->ptr;
     294           0 :                         _free_function(reference->fptr TSRMLS_CC);
     295           0 :                         efree(intern->ptr);
     296           0 :                         break;
     297             :                 case REF_TYPE_FUNCTION:
     298           0 :                         _free_function(intern->ptr TSRMLS_CC);
     299           0 :                         break;
     300             :                 case REF_TYPE_PROPERTY:
     301           0 :                         efree(intern->ptr);
     302           0 :                         break;
     303             :                 case REF_TYPE_DYNAMIC_PROPERTY:
     304           0 :                         prop_reference = (property_reference*)intern->ptr;
     305           0 :                         efree((char*)prop_reference->prop.name);
     306           0 :                         efree(intern->ptr);
     307             :                         break;
     308             :                 case REF_TYPE_OTHER:
     309             :                         break;
     310             :                 }
     311             :         }
     312           0 :         intern->ptr = NULL;
     313           0 :         if (intern->obj) {
     314           0 :                 zval_ptr_dtor(&intern->obj);
     315             :         }
     316           0 :         zend_objects_free_object_storage(object TSRMLS_CC);
     317           0 : }
     318             : /* }}} */
     319             : 
     320           0 : static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
     321             : {
     322             :         zend_object_value retval;
     323             :         reflection_object *intern;
     324             : 
     325           0 :         intern = ecalloc(1, sizeof(reflection_object));
     326           0 :         intern->zo.ce = class_type;
     327             : 
     328           0 :         zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
     329           0 :         object_properties_init(&intern->zo, class_type);
     330           0 :         retval.handle = zend_objects_store_put(intern, NULL, reflection_free_objects_storage, NULL TSRMLS_CC);
     331           0 :         retval.handlers = &reflection_object_handlers;
     332           0 :         return retval;
     333             : }
     334             : /* }}} */
     335             : 
     336           0 : static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) /* {{{ */
     337             : {
     338           0 :         if (!object) {
     339           0 :                 ALLOC_ZVAL(object);
     340             :         }
     341           0 :         Z_TYPE_P(object) = IS_OBJECT;
     342           0 :         object_init_ex(object, pce);
     343             :         Z_SET_REFCOUNT_P(object, 1);
     344             :         Z_SET_ISREF_P(object);
     345           0 :         return object;
     346             : }
     347             : /* }}} */
     348             : 
     349             : static void _const_string(string *str, char *name, zval *value, char *indent TSRMLS_DC);
     350             : static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char* indent TSRMLS_DC);
     351             : static void _property_string(string *str, zend_property_info *prop, char *prop_name, char* indent TSRMLS_DC);
     352             : static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *indent TSRMLS_DC);
     353             : static void _extension_string(string *str, zend_module_entry *module, char *indent TSRMLS_DC);
     354             : static void _zend_extension_string(string *str, zend_extension *extension, char *indent TSRMLS_DC);
     355             : 
     356             : /* {{{ _class_string */
     357           0 : static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *indent TSRMLS_DC)
     358             : {
     359           0 :         int count, count_static_props = 0, count_static_funcs = 0, count_shadow_props = 0;
     360             :         string sub_indent;
     361             : 
     362           0 :         string_init(&sub_indent);
     363           0 :         string_printf(&sub_indent, "%s    ", indent);
     364             : 
     365             :         /* TBD: Repair indenting of doc comment (or is this to be done in the parser?) */
     366           0 :         if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) {
     367           0 :                 string_printf(str, "%s%s", indent, ce->info.user.doc_comment);
     368           0 :                 string_write(str, "\n", 1);
     369             :         }
     370             : 
     371           0 :         if (obj) {
     372           0 :                 string_printf(str, "%sObject of class [ ", indent);
     373             :         } else {
     374           0 :                 char *kind = "Class";
     375           0 :                 if (ce->ce_flags & ZEND_ACC_INTERFACE) {
     376           0 :                         kind = "Interface";
     377           0 :                 } else if ((ce->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
     378           0 :                         kind = "Trait";
     379             :                 }
     380           0 :                 string_printf(str, "%s%s [ ", indent, kind);
     381             :         }
     382           0 :         string_printf(str, (ce->type == ZEND_USER_CLASS) ? "<user" : "<internal");
     383           0 :         if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module) {
     384           0 :                 string_printf(str, ":%s", ce->info.internal.module->name);
     385             :         }
     386           0 :         string_printf(str, "> ");
     387           0 :         if (ce->get_iterator != NULL) {
     388           0 :                 string_printf(str, "<iterateable> ");
     389             :         }
     390           0 :         if (ce->ce_flags & ZEND_ACC_INTERFACE) {
     391           0 :                 string_printf(str, "interface ");
     392           0 :         } else if ((ce->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
     393           0 :                 string_printf(str, "trait ");
     394             :         } else {
     395           0 :                 if (ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
     396           0 :                         string_printf(str, "abstract ");
     397             :                 }
     398           0 :                 if (ce->ce_flags & ZEND_ACC_FINAL_CLASS) {
     399           0 :                         string_printf(str, "final ");
     400             :                 }
     401           0 :                 string_printf(str, "class ");
     402             :         }
     403           0 :         string_printf(str, "%s", ce->name);
     404           0 :         if (ce->parent) {
     405           0 :                 string_printf(str, " extends %s", ce->parent->name);
     406             :         }
     407             : 
     408           0 :         if (ce->num_interfaces) {
     409             :                 zend_uint i;
     410             : 
     411           0 :                 if (ce->ce_flags & ZEND_ACC_INTERFACE) {
     412           0 :                         string_printf(str, " extends %s", ce->interfaces[0]->name);
     413             :                 } else {
     414           0 :                         string_printf(str, " implements %s", ce->interfaces[0]->name);
     415             :                 }
     416           0 :                 for (i = 1; i < ce->num_interfaces; ++i) {
     417           0 :                         string_printf(str, ", %s", ce->interfaces[i]->name);
     418             :                 }
     419             :         }
     420           0 :         string_printf(str, " ] {\n");
     421             : 
     422             :         /* The information where a class is declared is only available for user classes */
     423           0 :         if (ce->type == ZEND_USER_CLASS) {
     424           0 :                 string_printf(str, "%s  @@ %s %d-%d\n", indent, ce->info.user.filename,
     425             :                                                 ce->info.user.line_start, ce->info.user.line_end);
     426             :         }
     427             : 
     428             :         /* Constants */
     429           0 :         if (&ce->constants_table) {
     430           0 :                 zend_hash_apply_with_argument(&ce->constants_table, (apply_func_arg_t) zval_update_constant, (void*)1 TSRMLS_CC);
     431           0 :                 string_printf(str, "\n");
     432           0 :                 count = zend_hash_num_elements(&ce->constants_table);
     433           0 :                 string_printf(str, "%s  - Constants [%d] {\n", indent, count);
     434           0 :                 if (count > 0) {
     435             :                         HashPosition pos;
     436             :                         zval **value;
     437             :                         char *key;
     438             :                         uint key_len;
     439             :                         ulong num_index;
     440             : 
     441           0 :                         zend_hash_internal_pointer_reset_ex(&ce->constants_table, &pos);
     442             : 
     443           0 :                         while (zend_hash_get_current_data_ex(&ce->constants_table, (void **) &value, &pos) == SUCCESS) {
     444           0 :                                 zend_hash_get_current_key_ex(&ce->constants_table, &key, &key_len, &num_index, 0, &pos);
     445             : 
     446           0 :                                 _const_string(str, key, *value, indent TSRMLS_CC);
     447           0 :                                 zend_hash_move_forward_ex(&ce->constants_table, &pos);
     448             :                         }
     449             :                 }
     450           0 :                 string_printf(str, "%s  }\n", indent);
     451             :         }
     452             : 
     453             :         /* Static properties */
     454           0 :         if (&ce->properties_info) {
     455             :                 /* counting static properties */
     456           0 :                 count = zend_hash_num_elements(&ce->properties_info);
     457           0 :                 if (count > 0) {
     458             :                         HashPosition pos;
     459             :                         zend_property_info *prop;
     460             : 
     461           0 :                         zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos);
     462             : 
     463           0 :                         while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop, &pos) == SUCCESS) {
     464           0 :                                 if(prop->flags & ZEND_ACC_SHADOW) {
     465           0 :                                         count_shadow_props++;
     466           0 :                                 } else if (prop->flags & ZEND_ACC_STATIC) {
     467           0 :                                         count_static_props++;
     468             :                                 }
     469           0 :                                 zend_hash_move_forward_ex(&ce->properties_info, &pos);
     470             :                         }
     471             :                 }
     472             : 
     473             :                 /* static properties */
     474           0 :                 string_printf(str, "\n%s  - Static properties [%d] {\n", indent, count_static_props);
     475           0 :                 if (count_static_props > 0) {
     476             :                         HashPosition pos;
     477             :                         zend_property_info *prop;
     478             : 
     479           0 :                         zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos);
     480             : 
     481           0 :                         while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop, &pos) == SUCCESS) {
     482           0 :                                 if ((prop->flags & ZEND_ACC_STATIC) && !(prop->flags & ZEND_ACC_SHADOW)) {
     483           0 :                                         _property_string(str, prop, NULL, sub_indent.string TSRMLS_CC);
     484             :                                 }
     485             : 
     486           0 :                                 zend_hash_move_forward_ex(&ce->properties_info, &pos);
     487             :                         }
     488             :                 }
     489           0 :                 string_printf(str, "%s  }\n", indent);
     490             :         }
     491             : 
     492             :         /* Static methods */
     493           0 :         if (&ce->function_table) {
     494             :                 /* counting static methods */
     495           0 :                 count = zend_hash_num_elements(&ce->function_table);
     496           0 :                 if (count > 0) {
     497             :                         HashPosition pos;
     498             :                         zend_function *mptr;
     499             : 
     500           0 :                         zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);
     501             : 
     502           0 :                         while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
     503           0 :                                 if (mptr->common.fn_flags & ZEND_ACC_STATIC
     504           0 :                                         && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
     505             :                                 {
     506           0 :                                         count_static_funcs++;
     507             :                                 }
     508           0 :                                 zend_hash_move_forward_ex(&ce->function_table, &pos);
     509             :                         }
     510             :                 }
     511             : 
     512             :                 /* static methods */
     513           0 :                 string_printf(str, "\n%s  - Static methods [%d] {", indent, count_static_funcs);
     514           0 :                 if (count_static_funcs > 0) {
     515             :                         HashPosition pos;
     516             :                         zend_function *mptr;
     517             : 
     518           0 :                         zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);
     519             : 
     520           0 :                         while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
     521           0 :                                 if (mptr->common.fn_flags & ZEND_ACC_STATIC
     522           0 :                                         && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
     523             :                                 {
     524           0 :                                         string_printf(str, "\n");
     525           0 :                                         _function_string(str, mptr, ce, sub_indent.string TSRMLS_CC);
     526             :                                 }
     527           0 :                                 zend_hash_move_forward_ex(&ce->function_table, &pos);
     528             :                         }
     529             :                 } else {
     530           0 :                         string_printf(str, "\n");
     531             :                 }
     532           0 :                 string_printf(str, "%s  }\n", indent);
     533             :         }
     534             : 
     535             :         /* Default/Implicit properties */
     536           0 :         if (&ce->properties_info) {
     537           0 :                 count = zend_hash_num_elements(&ce->properties_info) - count_static_props - count_shadow_props;
     538           0 :                 string_printf(str, "\n%s  - Properties [%d] {\n", indent, count);
     539           0 :                 if (count > 0) {
     540             :                         HashPosition pos;
     541             :                         zend_property_info *prop;
     542             : 
     543           0 :                         zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos);
     544             : 
     545           0 :                         while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop, &pos) == SUCCESS) {
     546           0 :                                 if (!(prop->flags & (ZEND_ACC_STATIC|ZEND_ACC_SHADOW))) {
     547           0 :                                         _property_string(str, prop, NULL, sub_indent.string TSRMLS_CC);
     548             :                                 }
     549           0 :                                 zend_hash_move_forward_ex(&ce->properties_info, &pos);
     550             :                         }
     551             :                 }
     552           0 :                 string_printf(str, "%s  }\n", indent);
     553             :         }
     554             : 
     555           0 :         if (obj && Z_OBJ_HT_P(obj)->get_properties) {
     556             :                 string       dyn;
     557           0 :                 HashTable    *properties = Z_OBJ_HT_P(obj)->get_properties(obj TSRMLS_CC);
     558             :                 HashPosition pos;
     559             :                 zval         **prop;
     560             : 
     561           0 :                 string_init(&dyn);
     562           0 :                 count = 0;
     563             : 
     564           0 :                 if (properties && zend_hash_num_elements(properties)) {
     565           0 :                         zend_hash_internal_pointer_reset_ex(properties, &pos);
     566             : 
     567           0 :                         while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) {
     568             :                                 char  *prop_name;
     569             :                                 uint  prop_name_size;
     570             :                                 ulong index;
     571             : 
     572           0 :                                 if (zend_hash_get_current_key_ex(properties, &prop_name, &prop_name_size, &index, 1, &pos) == HASH_KEY_IS_STRING) {
     573           0 :                                         if (prop_name_size && prop_name[0]) { /* skip all private and protected properties */
     574           0 :                                                 if (!zend_hash_quick_exists(&ce->properties_info, prop_name, prop_name_size, zend_get_hash_value(prop_name, prop_name_size))) {
     575           0 :                                                         count++;
     576           0 :                                                         _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC);
     577             :                                                 }
     578             :                                         }
     579           0 :                                         efree(prop_name);
     580             :                                 }
     581           0 :                                 zend_hash_move_forward_ex(properties, &pos);
     582             :                         }
     583             :                 }
     584             : 
     585           0 :                 string_printf(str, "\n%s  - Dynamic properties [%d] {\n", indent, count);
     586           0 :                 string_append(str, &dyn);
     587           0 :                 string_printf(str, "%s  }\n", indent);
     588           0 :                 string_free(&dyn);
     589             :         }
     590             : 
     591             :         /* Non static methods */
     592           0 :         if (&ce->function_table) {
     593           0 :                 count = zend_hash_num_elements(&ce->function_table) - count_static_funcs;
     594           0 :                 if (count > 0) {
     595             :                         HashPosition pos;
     596             :                         zend_function *mptr;
     597             :                         string dyn;
     598             : 
     599           0 :                         count = 0;
     600           0 :                         string_init(&dyn);
     601           0 :                         zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);
     602             : 
     603           0 :                         while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
     604           0 :                                 if ((mptr->common.fn_flags & ZEND_ACC_STATIC) == 0
     605           0 :                                         && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
     606             :                                 {
     607             :                                         char *key;
     608             :                                         uint key_len;
     609             :                                         ulong num_index;
     610           0 :                                         uint len = strlen(mptr->common.function_name);
     611             : 
     612             :                                         /* Do not display old-style inherited constructors */
     613           0 :                                         if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0
     614           0 :                                                 || mptr->common.scope == ce
     615           0 :                                                 || zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING
     616           0 :                                                 || zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0)
     617             :                                         {
     618             :                                                 zend_function *closure;
     619             :                                                 /* see if this is a closure */
     620           0 :                                                 if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
     621           0 :                                                         && memcmp(mptr->common.function_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
     622           0 :                                                         && (closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL)
     623             :                                                 {
     624           0 :                                                         mptr = closure;
     625             :                                                 } else {
     626           0 :                                                         closure = NULL;
     627             :                                                 }
     628           0 :                                                 string_printf(&dyn, "\n");
     629           0 :                                                 _function_string(&dyn, mptr, ce, sub_indent.string TSRMLS_CC);
     630           0 :                                                 count++;
     631           0 :                                                 _free_function(closure TSRMLS_CC);
     632             :                                         }
     633             :                                 }
     634           0 :                                 zend_hash_move_forward_ex(&ce->function_table, &pos);
     635             :                         }
     636           0 :                         string_printf(str, "\n%s  - Methods [%d] {", indent, count);
     637           0 :                         if (!count) {
     638           0 :                                 string_printf(str, "\n");
     639             :                         }
     640           0 :                         string_append(str, &dyn);
     641           0 :                         string_free(&dyn);
     642             :                 } else {
     643           0 :                         string_printf(str, "\n%s  - Methods [0] {\n", indent);
     644             :                 }
     645           0 :                 string_printf(str, "%s  }\n", indent);
     646             :         }
     647             : 
     648           0 :         string_printf(str, "%s}\n", indent);
     649           0 :         string_free(&sub_indent);
     650           0 : }
     651             : /* }}} */
     652             : 
     653             : /* {{{ _const_string */
     654           0 : static void _const_string(string *str, char *name, zval *value, char *indent TSRMLS_DC)
     655             : {
     656             :         char *type;
     657             :         zval value_copy;
     658             :         int use_copy;
     659             : 
     660           0 :         type = zend_zval_type_name(value);
     661             : 
     662           0 :         zend_make_printable_zval(value, &value_copy, &use_copy);
     663           0 :         if (use_copy) {
     664           0 :                 value = &value_copy;
     665             :         }
     666             : 
     667           0 :         string_printf(str, "%s    Constant [ %s %s ] { %s }\n",
     668             :                                         indent, type, name, Z_STRVAL_P(value));
     669             : 
     670           0 :         if (use_copy) {
     671             :                 zval_dtor(value);
     672             :         }
     673           0 : }
     674             : /* }}} */
     675             : 
     676             : /* {{{ _get_recv_opcode */
     677           0 : static zend_op* _get_recv_op(zend_op_array *op_array, zend_uint offset)
     678             : {
     679           0 :         zend_op *op = op_array->opcodes;
     680           0 :         zend_op *end = op + op_array->last;
     681             : 
     682           0 :         ++offset;
     683           0 :         while (op < end) {
     684           0 :                 if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT 
     685           0 :                     || op->opcode == ZEND_RECV_VARIADIC) && op->op1.num == (long)offset)
     686             :                 {
     687           0 :                         return op;
     688             :                 }
     689           0 :                 ++op;
     690             :         }
     691           0 :         return NULL;
     692             : }
     693             : /* }}} */
     694             : 
     695             : /* {{{ _parameter_string */
     696           0 : static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg_info *arg_info, zend_uint offset, zend_uint required, char* indent TSRMLS_DC)
     697             : {
     698           0 :         string_printf(str, "Parameter #%d [ ", offset);
     699           0 :         if (offset >= required) {
     700           0 :                 string_printf(str, "<optional> ");
     701             :         } else {
     702           0 :                 string_printf(str, "<required> ");
     703             :         }
     704           0 :         if (arg_info->class_name) {
     705           0 :                 string_printf(str, "%s ", arg_info->class_name);
     706           0 :                 if (arg_info->allow_null) {
     707           0 :                         string_printf(str, "or NULL ");
     708             :                 }
     709           0 :         } else if (arg_info->type_hint) {
     710           0 :                 string_printf(str, "%s ", zend_get_type_by_const(arg_info->type_hint));
     711           0 :                 if (arg_info->allow_null) {
     712           0 :                         string_printf(str, "or NULL ");
     713             :                 }
     714             :         }
     715           0 :         if (arg_info->pass_by_reference) {
     716           0 :                 string_write(str, "&", sizeof("&")-1);
     717             :         }
     718           0 :         if (arg_info->is_variadic) {
     719           0 :                 string_write(str, "...", sizeof("...")-1);
     720             :         }
     721           0 :         if (arg_info->name) {
     722           0 :                 string_printf(str, "$%s", arg_info->name);
     723             :         } else {
     724           0 :                 string_printf(str, "$param%d", offset);
     725             :         }
     726           0 :         if (fptr->type == ZEND_USER_FUNCTION && offset >= required) {
     727           0 :                 zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset);
     728           0 :                 if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {
     729             :                         zval *zv, zv_copy;
     730             :                         int use_copy;
     731           0 :                         string_write(str, " = ", sizeof(" = ")-1);
     732           0 :                         ALLOC_ZVAL(zv);
     733           0 :                         *zv = *precv->op2.zv;
     734           0 :                         zval_copy_ctor(zv);
     735           0 :                         INIT_PZVAL(zv);
     736           0 :                         zval_update_constant_ex(&zv, 1, fptr->common.scope TSRMLS_CC);
     737           0 :                         if (Z_TYPE_P(zv) == IS_BOOL) {
     738           0 :                                 if (Z_LVAL_P(zv)) {
     739           0 :                                         string_write(str, "true", sizeof("true")-1);
     740             :                                 } else {
     741           0 :                                         string_write(str, "false", sizeof("false")-1);
     742             :                                 }
     743           0 :                         } else if (Z_TYPE_P(zv) == IS_NULL) {
     744           0 :                                 string_write(str, "NULL", sizeof("NULL")-1);
     745           0 :                         } else if (Z_TYPE_P(zv) == IS_STRING) {
     746           0 :                                 string_write(str, "'", sizeof("'")-1);
     747           0 :                                 string_write(str, Z_STRVAL_P(zv), MIN(Z_STRLEN_P(zv), 15));
     748           0 :                                 if (Z_STRLEN_P(zv) > 15) {
     749           0 :                                         string_write(str, "...", sizeof("...")-1);
     750             :                                 }
     751           0 :                                 string_write(str, "'", sizeof("'")-1);
     752           0 :                         } else if (Z_TYPE_P(zv) == IS_ARRAY) {
     753           0 :                                 string_write(str, "Array", sizeof("Array")-1);
     754             :                         } else {
     755           0 :                                 zend_make_printable_zval(zv, &zv_copy, &use_copy);
     756           0 :                                 string_write(str, Z_STRVAL(zv_copy), Z_STRLEN(zv_copy));
     757           0 :                                 if (use_copy) {
     758             :                                         zval_dtor(&zv_copy);
     759             :                                 }
     760             :                         }
     761           0 :                         zval_ptr_dtor(&zv);
     762             :                 }
     763             :         }
     764           0 :         string_write(str, " ]", sizeof(" ]")-1);
     765           0 : }
     766             : /* }}} */
     767             : 
     768             : /* {{{ _function_parameter_string */
     769           0 : static void _function_parameter_string(string *str, zend_function *fptr, char* indent TSRMLS_DC)
     770             : {
     771           0 :         struct _zend_arg_info *arg_info = fptr->common.arg_info;
     772           0 :         zend_uint i, required = fptr->common.required_num_args;
     773             : 
     774           0 :         if (!arg_info) {
     775           0 :                 return;
     776             :         }
     777             : 
     778           0 :         string_printf(str, "\n");
     779           0 :         string_printf(str, "%s- Parameters [%d] {\n", indent, fptr->common.num_args);
     780           0 :         for (i = 0; i < fptr->common.num_args; i++) {
     781           0 :                 string_printf(str, "%s  ", indent);
     782           0 :                 _parameter_string(str, fptr, arg_info, i, required, indent TSRMLS_CC);
     783           0 :                 string_write(str, "\n", sizeof("\n")-1);
     784           0 :                 arg_info++;
     785             :         }
     786           0 :         string_printf(str, "%s}\n", indent);
     787             : }
     788             : /* }}} */
     789             : 
     790             : /* {{{ _function_closure_string */
     791           0 : static void _function_closure_string(string *str, zend_function *fptr, char* indent TSRMLS_DC)
     792             : {
     793             :         zend_uint i, count;
     794             :         ulong num_index;
     795             :         char *key;
     796             :         uint key_len;
     797             :         HashTable *static_variables;
     798             :         HashPosition pos;
     799             : 
     800           0 :         if (fptr->type != ZEND_USER_FUNCTION || !fptr->op_array.static_variables) {
     801           0 :                 return;
     802             :         }
     803             : 
     804           0 :         static_variables = fptr->op_array.static_variables;
     805           0 :         count = zend_hash_num_elements(static_variables);
     806             : 
     807           0 :         if (!count) {
     808           0 :                 return;
     809             :         }
     810             : 
     811           0 :         string_printf(str, "\n");
     812           0 :         string_printf(str, "%s- Bound Variables [%d] {\n", indent, zend_hash_num_elements(static_variables));
     813           0 :         zend_hash_internal_pointer_reset_ex(static_variables, &pos);
     814           0 :         i = 0;
     815           0 :         while (i < count) {
     816           0 :                 zend_hash_get_current_key_ex(static_variables, &key, &key_len, &num_index, 0, &pos);
     817           0 :                 string_printf(str, "%s    Variable #%d [ $%s ]\n", indent, i++, key);
     818           0 :                 zend_hash_move_forward_ex(static_variables, &pos);
     819             :         }
     820           0 :         string_printf(str, "%s}\n", indent);
     821             : }
     822             : /* }}} */
     823             : 
     824             : /* {{{ _function_string */
     825           0 : static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char* indent TSRMLS_DC)
     826             : {
     827             :         string param_indent;
     828             :         zend_function *overwrites;
     829             :         char *lc_name;
     830             :         unsigned int lc_name_len;
     831             : 
     832             :         /* TBD: Repair indenting of doc comment (or is this to be done in the parser?)
     833             :          * What's "wrong" is that any whitespace before the doc comment start is
     834             :          * swallowed, leading to an unaligned comment.
     835             :          */
     836           0 :         if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) {
     837           0 :                 string_printf(str, "%s%s\n", indent, fptr->op_array.doc_comment);
     838             :         }
     839             : 
     840           0 :         string_write(str, indent, strlen(indent));
     841           0 :         string_printf(str, fptr->common.fn_flags & ZEND_ACC_CLOSURE ? "Closure [ " : (fptr->common.scope ? "Method [ " : "Function [ "));
     842           0 :         string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user" : "<internal");
     843           0 :         if (fptr->common.fn_flags & ZEND_ACC_DEPRECATED) {
     844           0 :                 string_printf(str, ", deprecated");
     845             :         }
     846           0 :         if (fptr->type == ZEND_INTERNAL_FUNCTION && ((zend_internal_function*)fptr)->module) {
     847           0 :                 string_printf(str, ":%s", ((zend_internal_function*)fptr)->module->name);
     848             :         }
     849             : 
     850           0 :         if (scope && fptr->common.scope) {
     851           0 :                 if (fptr->common.scope != scope) {
     852           0 :                         string_printf(str, ", inherits %s", fptr->common.scope->name);
     853           0 :                 } else if (fptr->common.scope->parent) {
     854           0 :                         lc_name_len = strlen(fptr->common.function_name);
     855           0 :                         lc_name = zend_str_tolower_dup(fptr->common.function_name, lc_name_len);
     856           0 :                         if (zend_hash_find(&fptr->common.scope->parent->function_table, lc_name, lc_name_len + 1, (void**) &overwrites) == SUCCESS) {
     857           0 :                                 if (fptr->common.scope != overwrites->common.scope) {
     858           0 :                                         string_printf(str, ", overwrites %s", overwrites->common.scope->name);
     859             :                                 }
     860             :                         }
     861           0 :                         efree(lc_name);
     862             :                 }
     863             :         }
     864           0 :         if (fptr->common.prototype && fptr->common.prototype->common.scope) {
     865           0 :                 string_printf(str, ", prototype %s", fptr->common.prototype->common.scope->name);
     866             :         }
     867           0 :         if (fptr->common.fn_flags & ZEND_ACC_CTOR) {
     868           0 :                 string_printf(str, ", ctor");
     869             :         }
     870           0 :         if (fptr->common.fn_flags & ZEND_ACC_DTOR) {
     871           0 :                 string_printf(str, ", dtor");
     872             :         }
     873           0 :         string_printf(str, "> ");
     874             : 
     875           0 :         if (fptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
     876           0 :                 string_printf(str, "abstract ");
     877             :         }
     878           0 :         if (fptr->common.fn_flags & ZEND_ACC_FINAL) {
     879           0 :                 string_printf(str, "final ");
     880             :         }
     881           0 :         if (fptr->common.fn_flags & ZEND_ACC_STATIC) {
     882           0 :                 string_printf(str, "static ");
     883             :         }
     884             : 
     885           0 :         if (fptr->common.scope) {
     886             :                 /* These are mutually exclusive */
     887           0 :                 switch (fptr->common.fn_flags & ZEND_ACC_PPP_MASK) {
     888             :                         case ZEND_ACC_PUBLIC:
     889           0 :                                 string_printf(str, "public ");
     890           0 :                                 break;
     891             :                         case ZEND_ACC_PRIVATE:
     892           0 :                                 string_printf(str, "private ");
     893           0 :                                 break;
     894             :                         case ZEND_ACC_PROTECTED:
     895           0 :                                 string_printf(str, "protected ");
     896           0 :                                 break;
     897             :                         default:
     898           0 :                                 string_printf(str, "<visibility error> ");
     899             :                                 break;
     900             :                 }
     901           0 :                 string_printf(str, "method ");
     902             :         } else {
     903           0 :                 string_printf(str, "function ");
     904             :         }
     905             : 
     906           0 :         if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
     907           0 :                 string_printf(str, "&");
     908             :         }
     909           0 :         string_printf(str, "%s ] {\n", fptr->common.function_name);
     910             :         /* The information where a function is declared is only available for user classes */
     911           0 :         if (fptr->type == ZEND_USER_FUNCTION) {
     912           0 :                 string_printf(str, "%s  @@ %s %d - %d\n", indent,
     913             :                                                 fptr->op_array.filename,
     914             :                                                 fptr->op_array.line_start,
     915             :                                                 fptr->op_array.line_end);
     916             :         }
     917           0 :         string_init(&param_indent);
     918           0 :         string_printf(&param_indent, "%s  ", indent);
     919           0 :         if (fptr->common.fn_flags & ZEND_ACC_CLOSURE) {
     920           0 :                 _function_closure_string(str, fptr, param_indent.string TSRMLS_CC);
     921             :         }
     922           0 :         _function_parameter_string(str, fptr, param_indent.string TSRMLS_CC);
     923           0 :         string_free(&param_indent);
     924           0 :         string_printf(str, "%s}\n", indent);
     925           0 : }
     926             : /* }}} */
     927             : 
     928             : /* {{{ _property_string */
     929           0 : static void _property_string(string *str, zend_property_info *prop, char *prop_name, char* indent TSRMLS_DC)
     930             : {
     931             :         const char *class_name;
     932             : 
     933           0 :         string_printf(str, "%sProperty [ ", indent);
     934           0 :         if (!prop) {
     935           0 :                 string_printf(str, "<dynamic> public $%s", prop_name);
     936             :         } else {
     937           0 :                 if (!(prop->flags & ZEND_ACC_STATIC)) {
     938           0 :                         if (prop->flags & ZEND_ACC_IMPLICIT_PUBLIC) {
     939           0 :                                 string_write(str, "<implicit> ", sizeof("<implicit> ") - 1);
     940             :                         } else {
     941           0 :                                 string_write(str, "<default> ", sizeof("<default> ") - 1);
     942             :                         }
     943             :                 }
     944             : 
     945             :                 /* These are mutually exclusive */
     946           0 :                 switch (prop->flags & ZEND_ACC_PPP_MASK) {
     947             :                         case ZEND_ACC_PUBLIC:
     948           0 :                                 string_printf(str, "public ");
     949           0 :                                 break;
     950             :                         case ZEND_ACC_PRIVATE:
     951           0 :                                 string_printf(str, "private ");
     952           0 :                                 break;
     953             :                         case ZEND_ACC_PROTECTED:
     954           0 :                                 string_printf(str, "protected ");
     955             :                                 break;
     956             :                 }
     957           0 :                 if(prop->flags & ZEND_ACC_STATIC) {
     958           0 :                         string_printf(str, "static ");
     959             :                 }
     960             : 
     961           0 :                 zend_unmangle_property_name(prop->name, prop->name_length, &class_name, (const char**)&prop_name);
     962           0 :                 string_printf(str, "$%s", prop_name);
     963             :         }
     964             : 
     965           0 :         string_printf(str, " ]\n");
     966           0 : }
     967             : /* }}} */
     968             : 
     969           0 : static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
     970             : {
     971           0 :         string *str = va_arg(args, string *);
     972           0 :         char *indent = va_arg(args, char *);
     973           0 :         int number = va_arg(args, int);
     974           0 :         char *comma = "";
     975             : 
     976           0 :         if (number == ini_entry->module_number) {
     977           0 :                 string_printf(str, "    %sEntry [ %s <", indent, ini_entry->name);
     978           0 :                 if (ini_entry->modifiable == ZEND_INI_ALL) {
     979           0 :                         string_printf(str, "ALL");
     980             :                 } else {
     981           0 :                         if (ini_entry->modifiable & ZEND_INI_USER) {
     982           0 :                                 string_printf(str, "USER");
     983           0 :                                 comma = ",";
     984             :                         }
     985           0 :                         if (ini_entry->modifiable & ZEND_INI_PERDIR) {
     986           0 :                                 string_printf(str, "%sPERDIR", comma);
     987           0 :                                 comma = ",";
     988             :                         }
     989           0 :                         if (ini_entry->modifiable & ZEND_INI_SYSTEM) {
     990           0 :                                 string_printf(str, "%sSYSTEM", comma);
     991             :                         }
     992             :                 }
     993             : 
     994           0 :                 string_printf(str, "> ]\n");
     995           0 :                 string_printf(str, "    %s  Current = '%s'\n", indent, ini_entry->value ? ini_entry->value : "");
     996           0 :                 if (ini_entry->modified) {
     997           0 :                         string_printf(str, "    %s  Default = '%s'\n", indent, ini_entry->orig_value ? ini_entry->orig_value : "");
     998             :                 }
     999           0 :                 string_printf(str, "    %s}\n", indent);
    1000             :         }
    1001           0 :         return ZEND_HASH_APPLY_KEEP;
    1002             : }
    1003             : /* }}} */
    1004             : 
    1005           0 : static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
    1006             : {
    1007           0 :         string *str = va_arg(args, string *);
    1008           0 :         char *indent = va_arg(args, char *);
    1009           0 :         struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*);
    1010           0 :         int *num_classes = va_arg(args, int*);
    1011             : 
    1012           0 :         if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) {
    1013           0 :                 string_printf(str, "\n");
    1014           0 :                 _class_string(str, *pce, NULL, indent TSRMLS_CC);
    1015           0 :                 (*num_classes)++;
    1016             :         }
    1017           0 :         return ZEND_HASH_APPLY_KEEP;
    1018             : }
    1019             : /* }}} */
    1020             : 
    1021           0 : static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
    1022             : {
    1023           0 :         string *str = va_arg(args, string *);
    1024           0 :         char *indent = va_arg(args, char *);
    1025           0 :         struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*);
    1026           0 :         int *num_classes = va_arg(args, int*);
    1027             : 
    1028           0 :         if (constant->module_number  == module->module_number) {
    1029           0 :                 _const_string(str, constant->name, &constant->value, indent TSRMLS_CC);
    1030           0 :                 (*num_classes)++;
    1031             :         }
    1032           0 :         return ZEND_HASH_APPLY_KEEP;
    1033             : }
    1034             : /* }}} */
    1035             : 
    1036             : /* {{{ _extension_string */
    1037           0 : static void _extension_string(string *str, zend_module_entry *module, char *indent TSRMLS_DC)
    1038             : {
    1039           0 :         string_printf(str, "%sExtension [ ", indent);
    1040           0 :         if (module->type == MODULE_PERSISTENT) {
    1041           0 :                 string_printf(str, "<persistent>");
    1042             :         }
    1043           0 :         if (module->type == MODULE_TEMPORARY) {
    1044           0 :                 string_printf(str, "<temporary>" );
    1045             :         }
    1046           0 :         string_printf(str, " extension #%d %s version %s ] {\n",
    1047             :                                         module->module_number, module->name,
    1048             :                                         (module->version == NO_VERSION_YET) ? "<no_version>" : module->version);
    1049             : 
    1050           0 :         if (module->deps) {
    1051           0 :                 const zend_module_dep* dep = module->deps;
    1052             : 
    1053           0 :                 string_printf(str, "\n  - Dependencies {\n");
    1054             : 
    1055           0 :                 while(dep->name) {
    1056           0 :                         string_printf(str, "%s    Dependency [ %s (", indent, dep->name);
    1057             : 
    1058           0 :                         switch(dep->type) {
    1059             :                         case MODULE_DEP_REQUIRED:
    1060           0 :                                 string_write(str, "Required", sizeof("Required") - 1);
    1061           0 :                                 break;
    1062             :                         case MODULE_DEP_CONFLICTS:
    1063           0 :                                 string_write(str, "Conflicts", sizeof("Conflicts") - 1);
    1064           0 :                                 break;
    1065             :                         case MODULE_DEP_OPTIONAL:
    1066           0 :                                 string_write(str, "Optional", sizeof("Optional") - 1);
    1067           0 :                                 break;
    1068             :                         default:
    1069           0 :                                 string_write(str, "Error", sizeof("Error") - 1); /* shouldn't happen */
    1070             :                                 break;
    1071             :                         }
    1072             : 
    1073           0 :                         if (dep->rel) {
    1074           0 :                                 string_printf(str, " %s", dep->rel);
    1075             :                         }
    1076           0 :                         if (dep->version) {
    1077           0 :                                 string_printf(str, " %s", dep->version);
    1078             :                         }
    1079           0 :                         string_write(str, ") ]\n", sizeof(") ]\n") - 1);
    1080           0 :                         dep++;
    1081             :                 }
    1082           0 :                 string_printf(str, "%s  }\n", indent);
    1083             :         }
    1084             : 
    1085             :         {
    1086             :                 string str_ini;
    1087           0 :                 string_init(&str_ini);
    1088           0 :                 zend_hash_apply_with_arguments(EG(ini_directives) TSRMLS_CC, (apply_func_args_t) _extension_ini_string, 3, &str_ini, indent, module->module_number);
    1089           0 :                 if (str_ini.len > 1) {
    1090           0 :                         string_printf(str, "\n  - INI {\n");
    1091           0 :                         string_append(str, &str_ini);
    1092           0 :                         string_printf(str, "%s  }\n", indent);
    1093             :                 }
    1094           0 :                 string_free(&str_ini);
    1095             :         }
    1096             : 
    1097             :         {
    1098             :                 string str_constants;
    1099           0 :                 int num_constants = 0;
    1100             : 
    1101           0 :                 string_init(&str_constants);
    1102           0 :                 zend_hash_apply_with_arguments(EG(zend_constants) TSRMLS_CC, (apply_func_args_t) _extension_const_string, 4, &str_constants, indent, module, &num_constants);
    1103           0 :                 if (num_constants) {
    1104           0 :                         string_printf(str, "\n  - Constants [%d] {\n", num_constants);
    1105           0 :                         string_append(str, &str_constants);
    1106           0 :                         string_printf(str, "%s  }\n", indent);
    1107             :                 }
    1108           0 :                 string_free(&str_constants);
    1109             :         }
    1110             : 
    1111             :         {
    1112             :                 HashPosition iterator;
    1113             :                 zend_function *fptr;
    1114           0 :                 int first = 1;
    1115             : 
    1116           0 :                 zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator);
    1117           0 :                 while (zend_hash_get_current_data_ex(CG(function_table), (void **) &fptr, &iterator) == SUCCESS) {
    1118           0 :                         if (fptr->common.type==ZEND_INTERNAL_FUNCTION
    1119           0 :                                 && fptr->internal_function.module == module) {
    1120           0 :                                 if (first) {
    1121           0 :                                         string_printf(str, "\n  - Functions {\n");
    1122           0 :                                         first = 0;
    1123             :                                 }
    1124           0 :                                 _function_string(str, fptr, NULL, "    " TSRMLS_CC);
    1125             :                         }
    1126           0 :                         zend_hash_move_forward_ex(CG(function_table), &iterator);
    1127             :                 }
    1128           0 :                 if (!first) {
    1129           0 :                         string_printf(str, "%s  }\n", indent);
    1130             :                 }
    1131             :         }
    1132             : 
    1133             :         {
    1134             :                 string str_classes;
    1135             :                 string sub_indent;
    1136           0 :                 int num_classes = 0;
    1137             : 
    1138           0 :                 string_init(&sub_indent);
    1139           0 :                 string_printf(&sub_indent, "%s    ", indent);
    1140           0 :                 string_init(&str_classes);
    1141           0 :                 zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) _extension_class_string, 4, &str_classes, sub_indent.string, module, &num_classes);
    1142           0 :                 if (num_classes) {
    1143           0 :                         string_printf(str, "\n  - Classes [%d] {", num_classes);
    1144           0 :                         string_append(str, &str_classes);
    1145           0 :                         string_printf(str, "%s  }\n", indent);
    1146             :                 }
    1147           0 :                 string_free(&str_classes);
    1148           0 :                 string_free(&sub_indent);
    1149             :         }
    1150             : 
    1151           0 :         string_printf(str, "%s}\n", indent);
    1152           0 : }
    1153             : /* }}} */
    1154             : 
    1155           0 : static void _zend_extension_string(string *str, zend_extension *extension, char *indent TSRMLS_DC) /* {{{ */
    1156             : {
    1157           0 :         string_printf(str, "%sZend Extension [ %s ", indent, extension->name);
    1158             : 
    1159           0 :         if (extension->version) {
    1160           0 :                 string_printf(str, "%s ", extension->version);
    1161             :         }
    1162           0 :         if (extension->copyright) {
    1163           0 :                 string_printf(str, "%s ", extension->copyright);
    1164             :         }
    1165           0 :         if (extension->author) {
    1166           0 :                 string_printf(str, "by %s ", extension->author);
    1167             :         }
    1168           0 :         if (extension->URL) {
    1169           0 :                 string_printf(str, "<%s> ", extension->URL);
    1170             :         }
    1171             : 
    1172           0 :         string_printf(str, "]\n");
    1173           0 : }
    1174             : /* }}} */
    1175             : 
    1176             : /* {{{ _function_check_flag */
    1177           0 : static void _function_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask)
    1178             : {
    1179             :         reflection_object *intern;
    1180             :         zend_function *mptr;
    1181             : 
    1182           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1183           0 :                 return;
    1184             :         }
    1185           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    1186           0 :         RETURN_BOOL(mptr->common.fn_flags & mask);
    1187             : }
    1188             : /* }}} */
    1189             : 
    1190             : /* {{{ zend_reflection_class_factory */
    1191           0 : PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSRMLS_DC)
    1192             : {
    1193             :         reflection_object *intern;
    1194             :         zval *name;
    1195             : 
    1196           0 :         MAKE_STD_ZVAL(name);
    1197           0 :         ZVAL_STRINGL(name, ce->name, ce->name_length, 1);
    1198           0 :         reflection_instantiate(reflection_class_ptr, object TSRMLS_CC);
    1199           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    1200           0 :         intern->ptr = ce;
    1201           0 :         intern->ref_type = REF_TYPE_OTHER;
    1202           0 :         intern->ce = ce;
    1203           0 :         reflection_update_property(object, "name", name);
    1204           0 : }
    1205             : /* }}} */
    1206             : 
    1207             : /* {{{ reflection_extension_factory */
    1208           0 : static void reflection_extension_factory(zval *object, const char *name_str TSRMLS_DC)
    1209             : {
    1210             :         reflection_object *intern;
    1211             :         zval *name;
    1212           0 :         int name_len = strlen(name_str);
    1213             :         char *lcname;
    1214             :         struct _zend_module_entry *module;
    1215             :         ALLOCA_FLAG(use_heap)
    1216             : 
    1217           0 :         lcname = do_alloca(name_len + 1, use_heap);
    1218           0 :         zend_str_tolower_copy(lcname, name_str, name_len);
    1219           0 :         if (zend_hash_find(&module_registry, lcname, name_len + 1, (void **)&module) == FAILURE) {
    1220           0 :                 free_alloca(lcname, use_heap);
    1221           0 :                 return;
    1222             :         }
    1223           0 :         free_alloca(lcname, use_heap);
    1224             : 
    1225           0 :         reflection_instantiate(reflection_extension_ptr, object TSRMLS_CC);
    1226           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    1227           0 :         MAKE_STD_ZVAL(name);
    1228           0 :         ZVAL_STRINGL(name, module->name, name_len, 1);
    1229           0 :         intern->ptr = module;
    1230           0 :         intern->ref_type = REF_TYPE_OTHER;
    1231           0 :         intern->ce = NULL;
    1232           0 :         reflection_update_property(object, "name", name);
    1233             : }
    1234             : /* }}} */
    1235             : 
    1236             : /* {{{ reflection_parameter_factory */
    1237           0 : static void reflection_parameter_factory(zend_function *fptr, zval *closure_object, struct _zend_arg_info *arg_info, zend_uint offset, zend_uint required, zval *object TSRMLS_DC)
    1238             : {
    1239             :         reflection_object *intern;
    1240             :         parameter_reference *reference;
    1241             :         zval *name;
    1242             : 
    1243           0 :         if (closure_object) {
    1244             :                 Z_ADDREF_P(closure_object);
    1245             :         }
    1246           0 :         MAKE_STD_ZVAL(name);
    1247           0 :         if (arg_info->name) {
    1248           0 :                 ZVAL_STRINGL(name, arg_info->name, arg_info->name_len, 1);
    1249             :         } else {
    1250           0 :                 ZVAL_NULL(name);
    1251             :         }
    1252           0 :         reflection_instantiate(reflection_parameter_ptr, object TSRMLS_CC);
    1253           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    1254           0 :         reference = (parameter_reference*) emalloc(sizeof(parameter_reference));
    1255           0 :         reference->arg_info = arg_info;
    1256           0 :         reference->offset = offset;
    1257           0 :         reference->required = required;
    1258           0 :         reference->fptr = fptr;
    1259           0 :         intern->ptr = reference;
    1260           0 :         intern->ref_type = REF_TYPE_PARAMETER;
    1261           0 :         intern->ce = fptr->common.scope;
    1262           0 :         intern->obj = closure_object;
    1263           0 :         reflection_update_property(object, "name", name);
    1264           0 : }
    1265             : /* }}} */
    1266             : 
    1267             : /* {{{ reflection_function_factory */
    1268           0 : static void reflection_function_factory(zend_function *function, zval *closure_object, zval *object TSRMLS_DC)
    1269             : {
    1270             :         reflection_object *intern;
    1271             :         zval *name;
    1272             : 
    1273           0 :         if (closure_object) {
    1274             :                 Z_ADDREF_P(closure_object);
    1275             :         }
    1276           0 :         MAKE_STD_ZVAL(name);
    1277           0 :         ZVAL_STRING(name, function->common.function_name, 1);
    1278             : 
    1279           0 :         reflection_instantiate(reflection_function_ptr, object TSRMLS_CC);
    1280           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    1281           0 :         intern->ptr = function;
    1282           0 :         intern->ref_type = REF_TYPE_FUNCTION;
    1283           0 :         intern->ce = NULL;
    1284           0 :         intern->obj = closure_object;
    1285           0 :         reflection_update_property(object, "name", name);
    1286           0 : }
    1287             : /* }}} */
    1288             : 
    1289             : /* {{{ reflection_method_factory */
    1290           0 : static void reflection_method_factory(zend_class_entry *ce, zend_function *method, zval *closure_object, zval *object TSRMLS_DC)
    1291             : {
    1292             :         reflection_object *intern;
    1293             :         zval *name;
    1294             :         zval *classname;
    1295             : 
    1296           0 :         if (closure_object) {
    1297             :                 Z_ADDREF_P(closure_object);
    1298             :         }
    1299           0 :         MAKE_STD_ZVAL(name);
    1300           0 :         MAKE_STD_ZVAL(classname);
    1301           0 :         ZVAL_STRING(name, (method->common.scope && method->common.scope->trait_aliases)?
    1302             :                         zend_resolve_method_name(ce, method) : method->common.function_name, 1);
    1303           0 :         ZVAL_STRINGL(classname, method->common.scope->name, method->common.scope->name_length, 1);
    1304           0 :         reflection_instantiate(reflection_method_ptr, object TSRMLS_CC);
    1305           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    1306           0 :         intern->ptr = method;
    1307           0 :         intern->ref_type = REF_TYPE_FUNCTION;
    1308           0 :         intern->ce = ce;
    1309           0 :         intern->obj = closure_object;
    1310           0 :         reflection_update_property(object, "name", name);
    1311           0 :         reflection_update_property(object, "class", classname);
    1312           0 : }
    1313             : /* }}} */
    1314             : 
    1315             : /* {{{ reflection_property_factory */
    1316           0 : static void reflection_property_factory(zend_class_entry *ce, zend_property_info *prop, zval *object TSRMLS_DC)
    1317             : {
    1318             :         reflection_object *intern;
    1319             :         zval *name;
    1320             :         zval *classname;
    1321             :         property_reference *reference;
    1322             :         const char *class_name, *prop_name;
    1323             : 
    1324           0 :         zend_unmangle_property_name(prop->name, prop->name_length, &class_name, &prop_name);
    1325             : 
    1326           0 :         if (!(prop->flags & ZEND_ACC_PRIVATE)) {
    1327             :                 /* we have to search the class hierarchy for this (implicit) public or protected property */
    1328           0 :                 zend_class_entry *tmp_ce = ce, *store_ce = ce;
    1329           0 :                 zend_property_info *tmp_info = NULL;
    1330             : 
    1331           0 :                 while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) != SUCCESS) {
    1332           0 :                         ce = tmp_ce;
    1333           0 :                         tmp_ce = tmp_ce->parent;
    1334             :                 }
    1335             : 
    1336           0 :                 if (tmp_info && !(tmp_info->flags & ZEND_ACC_SHADOW)) { /* found something and it's not a parent's private */
    1337           0 :                         prop = tmp_info;
    1338             :                 } else { /* not found, use initial value */
    1339           0 :                         ce = store_ce;
    1340             :                 }
    1341             :         }
    1342             : 
    1343           0 :         MAKE_STD_ZVAL(name);
    1344           0 :         MAKE_STD_ZVAL(classname);
    1345           0 :         ZVAL_STRING(name, prop_name, 1);
    1346           0 :         ZVAL_STRINGL(classname, prop->ce->name, prop->ce->name_length, 1);
    1347             : 
    1348           0 :         reflection_instantiate(reflection_property_ptr, object TSRMLS_CC);
    1349           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    1350           0 :         reference = (property_reference*) emalloc(sizeof(property_reference));
    1351           0 :         reference->ce = ce;
    1352           0 :         reference->prop = *prop;
    1353           0 :         intern->ptr = reference;
    1354           0 :         intern->ref_type = REF_TYPE_PROPERTY;
    1355           0 :         intern->ce = ce;
    1356           0 :         intern->ignore_visibility = 0;
    1357           0 :         reflection_update_property(object, "name", name);
    1358           0 :         reflection_update_property(object, "class", classname);
    1359           0 : }
    1360             : /* }}} */
    1361             : 
    1362             : /* {{{ _reflection_export */
    1363           0 : static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *ce_ptr, int ctor_argc)
    1364             : {
    1365             :         zval *reflector_ptr;
    1366           0 :         zval output, *output_ptr = &output;
    1367             :         zval *argument_ptr, *argument2_ptr;
    1368             :         zval *retval_ptr, **params[2];
    1369             :         int result;
    1370           0 :         int return_output = 0;
    1371             :         zend_fcall_info fci;
    1372             :         zend_fcall_info_cache fcc;
    1373             :         zval fname;
    1374             : 
    1375           0 :         if (ctor_argc == 1) {
    1376           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &argument_ptr, &return_output) == FAILURE) {
    1377           0 :                         return;
    1378             :                 }
    1379             :         } else {
    1380           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|b", &argument_ptr, &argument2_ptr, &return_output) == FAILURE) {
    1381           0 :                         return;
    1382             :                 }
    1383             :         }
    1384             : 
    1385           0 :         INIT_PZVAL(&output);
    1386             : 
    1387             :         /* Create object */
    1388           0 :         MAKE_STD_ZVAL(reflector_ptr);
    1389           0 :         if (object_and_properties_init(reflector_ptr, ce_ptr, NULL) == FAILURE) {
    1390           0 :                 _DO_THROW("Could not create reflector");
    1391             :         }
    1392             : 
    1393             :         /* Call __construct() */
    1394           0 :         params[0] = &argument_ptr;
    1395           0 :         params[1] = &argument2_ptr;
    1396             : 
    1397           0 :         fci.size = sizeof(fci);
    1398           0 :         fci.function_table = NULL;
    1399           0 :         fci.function_name = NULL;
    1400           0 :         fci.symbol_table = NULL;
    1401           0 :         fci.object_ptr = reflector_ptr;
    1402           0 :         fci.retval_ptr_ptr = &retval_ptr;
    1403           0 :         fci.param_count = ctor_argc;
    1404           0 :         fci.params = params;
    1405           0 :         fci.no_separation = 1;
    1406             : 
    1407           0 :         fcc.initialized = 1;
    1408           0 :         fcc.function_handler = ce_ptr->constructor;
    1409           0 :         fcc.calling_scope = ce_ptr;
    1410           0 :         fcc.called_scope = Z_OBJCE_P(reflector_ptr);
    1411           0 :         fcc.object_ptr = reflector_ptr;
    1412             : 
    1413           0 :         result = zend_call_function(&fci, &fcc TSRMLS_CC);
    1414             : 
    1415           0 :         if (retval_ptr) {
    1416           0 :                 zval_ptr_dtor(&retval_ptr);
    1417             :         }
    1418             : 
    1419           0 :         if (EG(exception)) {
    1420           0 :                 zval_ptr_dtor(&reflector_ptr);
    1421           0 :                 return;
    1422             :         }
    1423           0 :         if (result == FAILURE) {
    1424           0 :                 zval_ptr_dtor(&reflector_ptr);
    1425           0 :                 _DO_THROW("Could not create reflector");
    1426             :         }
    1427             : 
    1428             :         /* Call static reflection::export */
    1429           0 :         ZVAL_BOOL(&output, return_output);
    1430           0 :         params[0] = &reflector_ptr;
    1431           0 :         params[1] = &output_ptr;
    1432             : 
    1433           0 :         ZVAL_STRINGL(&fname, "reflection::export", sizeof("reflection::export") - 1, 0);
    1434           0 :         fci.function_table = &reflection_ptr->function_table;
    1435           0 :         fci.function_name = &fname;
    1436           0 :         fci.object_ptr = NULL;
    1437           0 :         fci.retval_ptr_ptr = &retval_ptr;
    1438           0 :         fci.param_count = 2;
    1439           0 :         fci.params = params;
    1440           0 :         fci.no_separation = 1;
    1441             : 
    1442           0 :         result = zend_call_function(&fci, NULL TSRMLS_CC);
    1443             : 
    1444           0 :         if (result == FAILURE && EG(exception) == NULL) {
    1445           0 :                 zval_ptr_dtor(&reflector_ptr);
    1446           0 :                 zval_ptr_dtor(&retval_ptr);
    1447           0 :                 _DO_THROW("Could not execute reflection::export()");
    1448             :         }
    1449             : 
    1450           0 :         if (return_output) {
    1451           0 :                 COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
    1452             :         } else {
    1453           0 :                 zval_ptr_dtor(&retval_ptr);
    1454             :         }
    1455             : 
    1456             :         /* Destruct reflector which is no longer needed */
    1457           0 :         zval_ptr_dtor(&reflector_ptr);
    1458             : }
    1459             : /* }}} */
    1460             : 
    1461             : /* {{{ _reflection_param_get_default_param */
    1462           0 : static parameter_reference *_reflection_param_get_default_param(INTERNAL_FUNCTION_PARAMETERS)
    1463             : {
    1464             :         reflection_object *intern;
    1465             :         parameter_reference *param;
    1466             : 
    1467           0 :         intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
    1468           0 :         if (intern == NULL || intern->ptr == NULL) {
    1469           0 :                 if (EG(exception) && Z_OBJCE_P(EG(exception)) == reflection_exception_ptr) {
    1470           0 :                         return NULL;
    1471             :                 }
    1472           0 :                 php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Failed to retrieve the reflection object");
    1473             :         }
    1474             : 
    1475           0 :         param = intern->ptr;
    1476           0 :         if (param->fptr->type != ZEND_USER_FUNCTION) {
    1477           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot determine default value for internal functions");
    1478           0 :                 return NULL;
    1479             :         }
    1480             : 
    1481           0 :         return param;
    1482             : }
    1483             : /* }}} */
    1484             : 
    1485             : /* {{{ _reflection_param_get_default_precv */
    1486           0 : static zend_op *_reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAMETERS, parameter_reference *param)
    1487             : {
    1488             :         zend_op *precv;
    1489             : 
    1490           0 :         if (param == NULL) {
    1491           0 :                 return NULL;
    1492             :         }
    1493             : 
    1494           0 :         precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
    1495           0 :         if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) {
    1496           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error: Failed to retrieve the default value");
    1497           0 :                 return NULL;
    1498             :         }
    1499             : 
    1500           0 :         return precv;
    1501             : }
    1502             : /* }}} */
    1503             : 
    1504             : /* {{{ Preventing __clone from being called */
    1505           0 : ZEND_METHOD(reflection, __clone)
    1506             : {
    1507             :         /* Should never be executable */
    1508           0 :         _DO_THROW("Cannot clone object using __clone()");
    1509             : }
    1510             : /* }}} */
    1511             : 
    1512             : /* {{{ proto public static mixed Reflection::export(Reflector r [, bool return])
    1513             :    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
    1514           0 : ZEND_METHOD(reflection, export)
    1515             : {
    1516             :         zval *object, fname, *retval_ptr;
    1517             :         int result;
    1518           0 :         zend_bool return_output = 0;
    1519             : 
    1520           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &object, reflector_ptr, &return_output) == FAILURE) {
    1521           0 :                 return;
    1522             :         }
    1523             : 
    1524             :         /* Invoke the __toString() method */
    1525           0 :         ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring") - 1, 1);
    1526           0 :         result= call_user_function_ex(NULL, &object, &fname, &retval_ptr, 0, NULL, 0, NULL TSRMLS_CC);
    1527             :         zval_dtor(&fname);
    1528             : 
    1529           0 :         if (result == FAILURE) {
    1530           0 :                 _DO_THROW("Invocation of method __toString() failed");
    1531             :                 /* Returns from this function */
    1532             :         }
    1533             : 
    1534           0 :         if (!retval_ptr) {
    1535           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::__toString() did not return anything", Z_OBJCE_P(object)->name);
    1536           0 :                 RETURN_FALSE;
    1537             :         }
    1538             : 
    1539           0 :         if (return_output) {
    1540           0 :                 COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
    1541             :         } else {
    1542             :                 /* No need for _r variant, return of __toString should always be a string */
    1543           0 :                 zend_print_zval(retval_ptr, 0);
    1544           0 :                 zend_printf("\n");
    1545           0 :                 zval_ptr_dtor(&retval_ptr);
    1546             :         }
    1547             : }
    1548             : /* }}} */
    1549             : 
    1550             : /* {{{ proto public static array Reflection::getModifierNames(int modifiers)
    1551             :    Returns an array of modifier names */
    1552           0 : ZEND_METHOD(reflection, getModifierNames)
    1553             : {
    1554             :         long modifiers;
    1555             : 
    1556           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &modifiers) == FAILURE) {
    1557           0 :                 return;
    1558             :         }
    1559             : 
    1560           0 :         array_init(return_value);
    1561             : 
    1562           0 :         if (modifiers & (ZEND_ACC_ABSTRACT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
    1563           0 :                 add_next_index_stringl(return_value, "abstract", sizeof("abstract")-1, 1);
    1564             :         }
    1565           0 :         if (modifiers & (ZEND_ACC_FINAL | ZEND_ACC_FINAL_CLASS)) {
    1566           0 :                 add_next_index_stringl(return_value, "final", sizeof("final")-1, 1);
    1567             :         }
    1568           0 :         if (modifiers & ZEND_ACC_IMPLICIT_PUBLIC) {
    1569           0 :                 add_next_index_stringl(return_value, "public", sizeof("public")-1, 1);
    1570             :         }
    1571             : 
    1572             :         /* These are mutually exclusive */
    1573           0 :         switch (modifiers & ZEND_ACC_PPP_MASK) {
    1574             :                 case ZEND_ACC_PUBLIC:
    1575           0 :                         add_next_index_stringl(return_value, "public", sizeof("public")-1, 1);
    1576           0 :                         break;
    1577             :                 case ZEND_ACC_PRIVATE:
    1578           0 :                         add_next_index_stringl(return_value, "private", sizeof("private")-1, 1);
    1579           0 :                         break;
    1580             :                 case ZEND_ACC_PROTECTED:
    1581           0 :                         add_next_index_stringl(return_value, "protected", sizeof("protected")-1, 1);
    1582             :                         break;
    1583             :         }
    1584             : 
    1585           0 :         if (modifiers & ZEND_ACC_STATIC) {
    1586           0 :                 add_next_index_stringl(return_value, "static", sizeof("static")-1, 1);
    1587             :         }
    1588             : }
    1589             : /* }}} */
    1590             : 
    1591             : /* {{{ proto public static mixed ReflectionFunction::export(string name [, bool return])
    1592             :    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
    1593           0 : ZEND_METHOD(reflection_function, export)
    1594             : {
    1595           0 :         _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_function_ptr, 1);
    1596           0 : }
    1597             : /* }}} */
    1598             : 
    1599             : /* {{{ proto public void ReflectionFunction::__construct(string name)
    1600             :    Constructor. Throws an Exception in case the given function does not exist */
    1601           0 : ZEND_METHOD(reflection_function, __construct)
    1602             : {
    1603             :         zval *name;
    1604             :         zval *object;
    1605           0 :         zval *closure = NULL;
    1606             :         char *lcname;
    1607             :         reflection_object *intern;
    1608             :         zend_function *fptr;
    1609             :         char *name_str;
    1610             :         int name_len;
    1611             : 
    1612           0 :         object = getThis();
    1613           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    1614           0 :         if (intern == NULL) {
    1615           0 :                 return;
    1616             :         }
    1617             : 
    1618           0 :         if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "O", &closure, zend_ce_closure) == SUCCESS) {
    1619           0 :                 fptr = (zend_function*)zend_get_closure_method_def(closure TSRMLS_CC);
    1620           0 :                 Z_ADDREF_P(closure);
    1621           0 :         } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len) == SUCCESS) {
    1622             :                 char *nsname;
    1623             : 
    1624           0 :                 lcname = zend_str_tolower_dup(name_str, name_len);
    1625             : 
    1626             :                 /* Ignore leading "\" */
    1627           0 :                 nsname = lcname;
    1628           0 :                 if (lcname[0] == '\\') {
    1629           0 :                         nsname = &lcname[1];
    1630           0 :                         name_len--;
    1631             :                 }
    1632             : 
    1633           0 :                 if (zend_hash_find(EG(function_table), nsname, name_len + 1, (void **)&fptr) == FAILURE) {
    1634           0 :                         efree(lcname);
    1635           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    1636             :                                 "Function %s() does not exist", name_str);
    1637           0 :                         return;
    1638             :                 }
    1639           0 :                 efree(lcname);
    1640             :         } else {
    1641           0 :                 return;
    1642             :         }
    1643             : 
    1644           0 :         MAKE_STD_ZVAL(name);
    1645           0 :         ZVAL_STRING(name, fptr->common.function_name, 1);
    1646           0 :         reflection_update_property(object, "name", name);
    1647           0 :         intern->ptr = fptr;
    1648           0 :         intern->ref_type = REF_TYPE_FUNCTION;
    1649           0 :         intern->obj = closure;
    1650           0 :         intern->ce = NULL;
    1651             : }
    1652             : /* }}} */
    1653             : 
    1654             : /* {{{ proto public string ReflectionFunction::__toString()
    1655             :    Returns a string representation */
    1656           0 : ZEND_METHOD(reflection_function, __toString)
    1657             : {
    1658             :         reflection_object *intern;
    1659             :         zend_function *fptr;
    1660             :         string str;
    1661             : 
    1662           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1663           0 :                 return;
    1664             :         }
    1665           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1666           0 :         string_init(&str);
    1667           0 :         _function_string(&str, fptr, intern->ce, "" TSRMLS_CC);
    1668           0 :         RETURN_STRINGL(str.string, str.len - 1, 0);
    1669             : }
    1670             : /* }}} */
    1671             : 
    1672             : /* {{{ proto public string ReflectionFunction::getName()
    1673             :    Returns this function's name */
    1674           0 : ZEND_METHOD(reflection_function, getName)
    1675             : {
    1676           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1677           0 :                 return;
    1678             :         }
    1679           0 :         _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
    1680             : }
    1681             : /* }}} */
    1682             : 
    1683             : /* {{{ proto public bool ReflectionFunction::isClosure()
    1684             :    Returns whether this is a closure */
    1685           0 : ZEND_METHOD(reflection_function, isClosure)
    1686             : {
    1687             :         reflection_object *intern;
    1688             :         zend_function *fptr;
    1689             : 
    1690           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1691           0 :                 return;
    1692             :         }
    1693           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1694           0 :         RETURN_BOOL(fptr->common.fn_flags & ZEND_ACC_CLOSURE);
    1695             : }
    1696             : /* }}} */
    1697             : 
    1698             : /* {{{ proto public bool ReflectionFunction::getClosureThis()
    1699             :    Returns this pointer bound to closure */
    1700           0 : ZEND_METHOD(reflection_function, getClosureThis)
    1701             : {
    1702             :         reflection_object *intern;
    1703             :         zend_function *fptr;
    1704             :         zval* closure_this;
    1705             : 
    1706           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1707           0 :                 return;
    1708             :         }
    1709           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1710           0 :         if (intern->obj) {
    1711           0 :                 closure_this = zend_get_closure_this_ptr(intern->obj TSRMLS_CC);
    1712           0 :                 if (closure_this) {
    1713           0 :                         RETURN_ZVAL(closure_this, 1, 0);
    1714             :                 }
    1715             :         }
    1716             : }
    1717             : /* }}} */
    1718             : 
    1719             : /* {{{ proto public ReflectionClass ReflectionFunction::getClosureScopeClass()
    1720             :    Returns the scope associated to the closure */
    1721           0 : ZEND_METHOD(reflection_function, getClosureScopeClass)
    1722             : {
    1723             :         reflection_object *intern;
    1724             :         zend_function *fptr;
    1725             :         const zend_function *closure_func;
    1726             : 
    1727           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1728           0 :                 return;
    1729             :         }
    1730           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1731           0 :         if (intern->obj) {
    1732           0 :                 closure_func = zend_get_closure_method_def(intern->obj TSRMLS_CC);
    1733           0 :                 if (closure_func && closure_func->common.scope) {
    1734           0 :                         zend_reflection_class_factory(closure_func->common.scope, return_value TSRMLS_CC);
    1735             :                 }
    1736             :         }
    1737             : }
    1738             : /* }}} */
    1739             : 
    1740             : /* {{{ proto public mixed ReflectionFunction::getClosure()
    1741             :    Returns a dynamically created closure for the function */
    1742           0 : ZEND_METHOD(reflection_function, getClosure)
    1743             : {
    1744             :         reflection_object *intern;
    1745             :         zend_function *fptr;
    1746             : 
    1747           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1748           0 :                 return;
    1749             :         }
    1750           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1751             : 
    1752           0 :         zend_create_closure(return_value, fptr, NULL, NULL TSRMLS_CC);
    1753             : }
    1754             : /* }}} */
    1755             : 
    1756             : 
    1757             : /* {{{ proto public bool ReflectionFunction::isInternal()
    1758             :    Returns whether this is an internal function */
    1759           0 : ZEND_METHOD(reflection_function, isInternal)
    1760             : {
    1761             :         reflection_object *intern;
    1762             :         zend_function *fptr;
    1763             : 
    1764           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1765           0 :                 return;
    1766             :         }
    1767           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1768           0 :         RETURN_BOOL(fptr->type == ZEND_INTERNAL_FUNCTION);
    1769             : }
    1770             : /* }}} */
    1771             : 
    1772             : /* {{{ proto public bool ReflectionFunction::isUserDefined()
    1773             :    Returns whether this is an user-defined function */
    1774           0 : ZEND_METHOD(reflection_function, isUserDefined)
    1775             : {
    1776             :         reflection_object *intern;
    1777             :         zend_function *fptr;
    1778             : 
    1779           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1780           0 :                 return;
    1781             :         }
    1782           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1783           0 :         RETURN_BOOL(fptr->type == ZEND_USER_FUNCTION);
    1784             : }
    1785             : /* }}} */
    1786             : 
    1787             : /* {{{ proto public bool ReflectionFunction::isDisabled()
    1788             :    Returns whether this function has been disabled or not */
    1789           0 : ZEND_METHOD(reflection_function, isDisabled)
    1790             : {
    1791             :         reflection_object *intern;
    1792             :         zend_function *fptr;
    1793             : 
    1794           0 :         METHOD_NOTSTATIC(reflection_function_ptr);
    1795           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1796           0 :         RETURN_BOOL(fptr->type == ZEND_INTERNAL_FUNCTION && fptr->internal_function.handler == zif_display_disabled_function);
    1797             : }
    1798             : /* }}} */
    1799             : 
    1800             : /* {{{ proto public string ReflectionFunction::getFileName()
    1801             :    Returns the filename of the file this function was declared in */
    1802           0 : ZEND_METHOD(reflection_function, getFileName)
    1803             : {
    1804             :         reflection_object *intern;
    1805             :         zend_function *fptr;
    1806             : 
    1807           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1808           0 :                 return;
    1809             :         }
    1810           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1811           0 :         if (fptr->type == ZEND_USER_FUNCTION) {
    1812           0 :                 RETURN_STRING(fptr->op_array.filename, 1);
    1813             :         }
    1814           0 :         RETURN_FALSE;
    1815             : }
    1816             : /* }}} */
    1817             : 
    1818             : /* {{{ proto public int ReflectionFunction::getStartLine()
    1819             :    Returns the line this function's declaration starts at */
    1820           0 : ZEND_METHOD(reflection_function, getStartLine)
    1821             : {
    1822             :         reflection_object *intern;
    1823             :         zend_function *fptr;
    1824             : 
    1825           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1826           0 :                 return;
    1827             :         }
    1828           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1829           0 :         if (fptr->type == ZEND_USER_FUNCTION) {
    1830           0 :                 RETURN_LONG(fptr->op_array.line_start);
    1831             :         }
    1832           0 :         RETURN_FALSE;
    1833             : }
    1834             : /* }}} */
    1835             : 
    1836             : /* {{{ proto public int ReflectionFunction::getEndLine()
    1837             :    Returns the line this function's declaration ends at */
    1838           0 : ZEND_METHOD(reflection_function, getEndLine)
    1839             : {
    1840             :         reflection_object *intern;
    1841             :         zend_function *fptr;
    1842             : 
    1843           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1844           0 :                 return;
    1845             :         }
    1846           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1847           0 :         if (fptr->type == ZEND_USER_FUNCTION) {
    1848           0 :                 RETURN_LONG(fptr->op_array.line_end);
    1849             :         }
    1850           0 :         RETURN_FALSE;
    1851             : }
    1852             : /* }}} */
    1853             : 
    1854             : /* {{{ proto public string ReflectionFunction::getDocComment()
    1855             :    Returns the doc comment for this function */
    1856           0 : ZEND_METHOD(reflection_function, getDocComment)
    1857             : {
    1858             :         reflection_object *intern;
    1859             :         zend_function *fptr;
    1860             : 
    1861           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1862           0 :                 return;
    1863             :         }
    1864           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1865           0 :         if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) {
    1866           0 :                 RETURN_STRINGL(fptr->op_array.doc_comment, fptr->op_array.doc_comment_len, 1);
    1867             :         }
    1868           0 :         RETURN_FALSE;
    1869             : }
    1870             : /* }}} */
    1871             : 
    1872             : /* {{{ proto public array ReflectionFunction::getStaticVariables()
    1873             :    Returns an associative array containing this function's static variables and their values */
    1874           0 : ZEND_METHOD(reflection_function, getStaticVariables)
    1875             : {
    1876             :         zval *tmp_copy;
    1877             :         reflection_object *intern;
    1878             :         zend_function *fptr;
    1879             : 
    1880           0 :         if (zend_parse_parameters_none() == FAILURE) {
    1881           0 :                 return;
    1882             :         }
    1883           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1884             : 
    1885             :         /* Return an empty array in case no static variables exist */
    1886           0 :         array_init(return_value);
    1887           0 :         if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.static_variables != NULL) {
    1888           0 :                 zend_hash_apply_with_argument(fptr->op_array.static_variables, (apply_func_arg_t) zval_update_constant_inline_change, fptr->common.scope TSRMLS_CC);
    1889           0 :                 zend_hash_copy(Z_ARRVAL_P(return_value), fptr->op_array.static_variables, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *));
    1890             :         }
    1891             : }
    1892             : /* }}} */
    1893             : 
    1894             : /* {{{ proto public mixed ReflectionFunction::invoke([mixed* args])
    1895             :    Invokes the function */
    1896           0 : ZEND_METHOD(reflection_function, invoke)
    1897             : {
    1898             :         zval *retval_ptr;
    1899           0 :         zval ***params = NULL;
    1900           0 :         int result, num_args = 0;
    1901             :         zend_fcall_info fci;
    1902             :         zend_fcall_info_cache fcc;
    1903             :         reflection_object *intern;
    1904             :         zend_function *fptr;
    1905             : 
    1906           0 :         METHOD_NOTSTATIC(reflection_function_ptr);
    1907           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1908             : 
    1909           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "*", &params, &num_args) == FAILURE) {
    1910           0 :                 return;
    1911             :         }
    1912             : 
    1913           0 :         fci.size = sizeof(fci);
    1914           0 :         fci.function_table = NULL;
    1915           0 :         fci.function_name = NULL;
    1916           0 :         fci.symbol_table = NULL;
    1917           0 :         fci.object_ptr = NULL;
    1918           0 :         fci.retval_ptr_ptr = &retval_ptr;
    1919           0 :         fci.param_count = num_args;
    1920           0 :         fci.params = params;
    1921           0 :         fci.no_separation = 1;
    1922             : 
    1923           0 :         fcc.initialized = 1;
    1924           0 :         fcc.function_handler = fptr;
    1925           0 :         fcc.calling_scope = EG(scope);
    1926           0 :         fcc.called_scope = NULL;
    1927           0 :         fcc.object_ptr = NULL;
    1928             : 
    1929           0 :         result = zend_call_function(&fci, &fcc TSRMLS_CC);
    1930             : 
    1931           0 :         if (num_args) {
    1932           0 :                 efree(params);
    1933             :         }
    1934             : 
    1935           0 :         if (result == FAILURE) {
    1936           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    1937             :                         "Invocation of function %s() failed", fptr->common.function_name);
    1938           0 :                 return;
    1939             :         }
    1940             : 
    1941           0 :         if (retval_ptr) {
    1942           0 :                 COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
    1943             :         }
    1944             : }
    1945             : /* }}} */
    1946             : 
    1947           0 : static int _zval_array_to_c_array(zval **arg, zval ****params TSRMLS_DC) /* {{{ */
    1948             : {
    1949           0 :         *(*params)++ = arg;
    1950           0 :         return ZEND_HASH_APPLY_KEEP;
    1951             : } /* }}} */
    1952             : 
    1953             : /* {{{ proto public mixed ReflectionFunction::invokeArgs(array args)
    1954             :    Invokes the function and pass its arguments as array. */
    1955           0 : ZEND_METHOD(reflection_function, invokeArgs)
    1956             : {
    1957             :         zval *retval_ptr;
    1958             :         zval ***params;
    1959             :         int result;
    1960             :         int argc;
    1961             :         zend_fcall_info fci;
    1962             :         zend_fcall_info_cache fcc;
    1963             :         reflection_object *intern;
    1964             :         zend_function *fptr;
    1965             :         zval *param_array;
    1966             : 
    1967           0 :         METHOD_NOTSTATIC(reflection_function_ptr);
    1968           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    1969             : 
    1970           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &param_array) == FAILURE) {
    1971           0 :                 return;
    1972             :         }
    1973             : 
    1974           0 :         argc = zend_hash_num_elements(Z_ARRVAL_P(param_array));
    1975             : 
    1976           0 :         params = safe_emalloc(sizeof(zval **), argc, 0);
    1977           0 :         zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, &params TSRMLS_CC);
    1978           0 :         params -= argc;
    1979             : 
    1980           0 :         fci.size = sizeof(fci);
    1981           0 :         fci.function_table = NULL;
    1982           0 :         fci.function_name = NULL;
    1983           0 :         fci.symbol_table = NULL;
    1984           0 :         fci.object_ptr = NULL;
    1985           0 :         fci.retval_ptr_ptr = &retval_ptr;
    1986           0 :         fci.param_count = argc;
    1987           0 :         fci.params = params;
    1988           0 :         fci.no_separation = 1;
    1989             : 
    1990           0 :         fcc.initialized = 1;
    1991           0 :         fcc.function_handler = fptr;
    1992           0 :         fcc.calling_scope = EG(scope);
    1993           0 :         fcc.called_scope = NULL;
    1994           0 :         fcc.object_ptr = NULL;
    1995             : 
    1996           0 :         result = zend_call_function(&fci, &fcc TSRMLS_CC);
    1997             : 
    1998           0 :         efree(params);
    1999             : 
    2000           0 :         if (result == FAILURE) {
    2001           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2002             :                         "Invocation of function %s() failed", fptr->common.function_name);
    2003           0 :                 return;
    2004             :         }
    2005             : 
    2006           0 :         if (retval_ptr) {
    2007           0 :                 COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
    2008             :         }
    2009             : }
    2010             : /* }}} */
    2011             : 
    2012             : /* {{{ proto public bool ReflectionFunction::returnsReference()
    2013             :    Gets whether this function returns a reference */
    2014           0 : ZEND_METHOD(reflection_function, returnsReference)
    2015             : {
    2016             :         reflection_object *intern;
    2017             :         zend_function *fptr;
    2018             : 
    2019           0 :         METHOD_NOTSTATIC(reflection_function_abstract_ptr);
    2020           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    2021             : 
    2022           0 :         RETURN_BOOL((fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0);
    2023             : }
    2024             : /* }}} */
    2025             : 
    2026             : /* {{{ proto public bool ReflectionFunction::getNumberOfParameters()
    2027             :    Gets the number of required parameters */
    2028           0 : ZEND_METHOD(reflection_function, getNumberOfParameters)
    2029             : {
    2030             :         reflection_object *intern;
    2031             :         zend_function *fptr;
    2032             : 
    2033           0 :         METHOD_NOTSTATIC(reflection_function_abstract_ptr);
    2034           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    2035             : 
    2036           0 :         RETURN_LONG(fptr->common.num_args);
    2037             : }
    2038             : /* }}} */
    2039             : 
    2040             : /* {{{ proto public bool ReflectionFunction::getNumberOfRequiredParameters()
    2041             :    Gets the number of required parameters */
    2042           0 : ZEND_METHOD(reflection_function, getNumberOfRequiredParameters)
    2043             : {
    2044             :         reflection_object *intern;
    2045             :         zend_function *fptr;
    2046             : 
    2047           0 :         METHOD_NOTSTATIC(reflection_function_abstract_ptr);
    2048           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    2049             : 
    2050           0 :         RETURN_LONG(fptr->common.required_num_args);
    2051             : }
    2052             : /* }}} */
    2053             : 
    2054             : /* {{{ proto public ReflectionParameter[] ReflectionFunction::getParameters()
    2055             :    Returns an array of parameter objects for this function */
    2056           0 : ZEND_METHOD(reflection_function, getParameters)
    2057             : {
    2058             :         reflection_object *intern;
    2059             :         zend_function *fptr;
    2060             :         zend_uint i;
    2061             :         struct _zend_arg_info *arg_info;
    2062             : 
    2063           0 :         METHOD_NOTSTATIC(reflection_function_abstract_ptr);
    2064           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    2065             : 
    2066           0 :         arg_info= fptr->common.arg_info;
    2067             : 
    2068           0 :         array_init(return_value);
    2069           0 :         for (i = 0; i < fptr->common.num_args; i++) {
    2070             :                 zval *parameter;
    2071             : 
    2072           0 :                 ALLOC_ZVAL(parameter);
    2073           0 :                 reflection_parameter_factory(_copy_function(fptr TSRMLS_CC), intern->obj, arg_info, i, fptr->common.required_num_args, parameter TSRMLS_CC);
    2074           0 :                 add_next_index_zval(return_value, parameter);
    2075             : 
    2076           0 :                 arg_info++;
    2077             :         }
    2078             : }
    2079             : /* }}} */
    2080             : 
    2081             : /* {{{ proto public ReflectionExtension|NULL ReflectionFunction::getExtension()
    2082             :    Returns NULL or the extension the function belongs to */
    2083           0 : ZEND_METHOD(reflection_function, getExtension)
    2084             : {
    2085             :         reflection_object *intern;
    2086             :         zend_function *fptr;
    2087             :         zend_internal_function *internal;
    2088             : 
    2089           0 :         METHOD_NOTSTATIC(reflection_function_abstract_ptr);
    2090           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    2091             : 
    2092           0 :         if (fptr->type != ZEND_INTERNAL_FUNCTION) {
    2093           0 :                 RETURN_NULL();
    2094             :         }
    2095             : 
    2096           0 :         internal = (zend_internal_function *)fptr;
    2097           0 :         if (internal->module) {
    2098           0 :                 reflection_extension_factory(return_value, internal->module->name TSRMLS_CC);
    2099             :         } else {
    2100           0 :                 RETURN_NULL();
    2101             :         }
    2102             : }
    2103             : /* }}} */
    2104             : 
    2105             : /* {{{ proto public string|false ReflectionFunction::getExtensionName()
    2106             :    Returns false or the name of the extension the function belongs to */
    2107           0 : ZEND_METHOD(reflection_function, getExtensionName)
    2108             : {
    2109             :         reflection_object *intern;
    2110             :         zend_function *fptr;
    2111             :         zend_internal_function *internal;
    2112             : 
    2113           0 :         METHOD_NOTSTATIC(reflection_function_abstract_ptr);
    2114           0 :         GET_REFLECTION_OBJECT_PTR(fptr);
    2115             : 
    2116           0 :         if (fptr->type != ZEND_INTERNAL_FUNCTION) {
    2117           0 :                 RETURN_FALSE;
    2118             :         }
    2119             : 
    2120           0 :         internal = (zend_internal_function *)fptr;
    2121           0 :         if (internal->module) {
    2122           0 :                 RETURN_STRING(internal->module->name, 1);
    2123             :         } else {
    2124           0 :                 RETURN_FALSE;
    2125             :         }
    2126             : }
    2127             : /* }}} */
    2128             : 
    2129             : /* {{{ proto public static mixed ReflectionParameter::export(mixed function, mixed parameter [, bool return]) throws ReflectionException
    2130             :    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
    2131           0 : ZEND_METHOD(reflection_parameter, export)
    2132             : {
    2133           0 :         _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_parameter_ptr, 2);
    2134           0 : }
    2135             : /* }}} */
    2136             : 
    2137             : /* {{{ proto public void ReflectionParameter::__construct(mixed function, mixed parameter)
    2138             :    Constructor. Throws an Exception in case the given method does not exist */
    2139           0 : ZEND_METHOD(reflection_parameter, __construct)
    2140             : {
    2141             :         parameter_reference *ref;
    2142             :         zval *reference, **parameter;
    2143             :         zval *object;
    2144             :         zval *name;
    2145             :         reflection_object *intern;
    2146             :         zend_function *fptr;
    2147             :         struct _zend_arg_info *arg_info;
    2148             :         int position;
    2149           0 :         zend_class_entry *ce = NULL;
    2150           0 :         zend_bool is_closure = 0;
    2151             : 
    2152           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zZ", &reference, &parameter) == FAILURE) {
    2153           0 :                 return;
    2154             :         }
    2155             : 
    2156           0 :         object = getThis();
    2157           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    2158           0 :         if (intern == NULL) {
    2159           0 :                 return;
    2160             :         }
    2161             : 
    2162             :         /* First, find the function */
    2163           0 :         switch (Z_TYPE_P(reference)) {
    2164             :                 case IS_STRING: {
    2165             :                                 unsigned int lcname_len;
    2166             :                                 char *lcname;
    2167             : 
    2168           0 :                                 lcname_len = Z_STRLEN_P(reference);
    2169           0 :                                 lcname = zend_str_tolower_dup(Z_STRVAL_P(reference), lcname_len);
    2170           0 :                                 if (zend_hash_find(EG(function_table), lcname, lcname_len + 1, (void**) &fptr) == FAILURE) {
    2171           0 :                                         efree(lcname);
    2172           0 :                                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2173           0 :                                                 "Function %s() does not exist", Z_STRVAL_P(reference));
    2174           0 :                                         return;
    2175             :                                 }
    2176           0 :                                 efree(lcname);
    2177             :                         }
    2178           0 :                         ce = fptr->common.scope;
    2179           0 :                         break;
    2180             : 
    2181             :                 case IS_ARRAY: {
    2182             :                                 zval **classref;
    2183             :                                 zval **method;
    2184             :                                 zend_class_entry **pce;
    2185             :                                 unsigned int lcname_len;
    2186             :                                 char *lcname;
    2187             : 
    2188           0 :                                 if ((zend_hash_index_find(Z_ARRVAL_P(reference), 0, (void **) &classref) == FAILURE)
    2189           0 :                                         || (zend_hash_index_find(Z_ARRVAL_P(reference), 1, (void **) &method) == FAILURE))
    2190             :                                 {
    2191           0 :                                         _DO_THROW("Expected array($object, $method) or array($classname, $method)");
    2192             :                                         /* returns out of this function */
    2193             :                                 }
    2194             : 
    2195           0 :                                 if (Z_TYPE_PP(classref) == IS_OBJECT) {
    2196           0 :                                         ce = Z_OBJCE_PP(classref);
    2197             :                                 } else {
    2198           0 :                                         convert_to_string_ex(classref);
    2199           0 :                                         if (zend_lookup_class(Z_STRVAL_PP(classref), Z_STRLEN_PP(classref), &pce TSRMLS_CC) == FAILURE) {
    2200           0 :                                                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2201           0 :                                                                 "Class %s does not exist", Z_STRVAL_PP(classref));
    2202           0 :                                                 return;
    2203             :                                         }
    2204           0 :                                         ce = *pce;
    2205             :                                 }
    2206             : 
    2207           0 :                                 convert_to_string_ex(method);
    2208           0 :                                 lcname_len = Z_STRLEN_PP(method);
    2209           0 :                                 lcname = zend_str_tolower_dup(Z_STRVAL_PP(method), lcname_len);
    2210           0 :                                 if (ce == zend_ce_closure && Z_TYPE_PP(classref) == IS_OBJECT
    2211           0 :                                         && (lcname_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
    2212             :                                         && memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
    2213           0 :                                         && (fptr = zend_get_closure_invoke_method(*classref TSRMLS_CC)) != NULL)
    2214             :                                 {
    2215             :                                         /* nothing to do. don't set is_closure since is the invoke handler,
    2216             : -                                          not the closure itself */
    2217           0 :                                 } else if (zend_hash_find(&ce->function_table, lcname, lcname_len + 1, (void **) &fptr) == FAILURE) {
    2218           0 :                                         efree(lcname);
    2219           0 :                                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2220           0 :                                                 "Method %s::%s() does not exist", ce->name, Z_STRVAL_PP(method));
    2221           0 :                                         return;
    2222             :                                 }
    2223           0 :                                 efree(lcname);
    2224             :                         }
    2225           0 :                         break;
    2226             : 
    2227             :                 case IS_OBJECT: {
    2228           0 :                                 ce = Z_OBJCE_P(reference);
    2229             : 
    2230           0 :                                 if (instanceof_function(ce, zend_ce_closure TSRMLS_CC)) {
    2231           0 :                                         fptr = (zend_function *)zend_get_closure_method_def(reference TSRMLS_CC);
    2232           0 :                                         Z_ADDREF_P(reference);
    2233           0 :                                         is_closure = 1;
    2234           0 :                                 } else if (zend_hash_find(&ce->function_table, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME), (void **)&fptr) == FAILURE) {
    2235           0 :                                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2236             :                                                 "Method %s::%s() does not exist", ce->name, ZEND_INVOKE_FUNC_NAME);
    2237           0 :                                         return;
    2238             :                                 }
    2239             :                         }
    2240           0 :                         break;
    2241             : 
    2242             :                 default:
    2243           0 :                         _DO_THROW("The parameter class is expected to be either a string, an array(class, method) or a callable object");
    2244             :                         /* returns out of this function */
    2245             :         }
    2246             : 
    2247             :         /* Now, search for the parameter */
    2248           0 :         arg_info = fptr->common.arg_info;
    2249           0 :         if (Z_TYPE_PP(parameter) == IS_LONG) {
    2250           0 :                 position= Z_LVAL_PP(parameter);
    2251           0 :                 if (position < 0 || (zend_uint)position >= fptr->common.num_args) {
    2252           0 :                         if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
    2253           0 :                                 if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
    2254           0 :                                         efree((char*)fptr->common.function_name);
    2255             :                                 }
    2256           0 :                                 efree(fptr);
    2257             :                         }
    2258           0 :                         if (is_closure) {
    2259           0 :                                 zval_ptr_dtor(&reference);
    2260             :                         }
    2261           0 :                         _DO_THROW("The parameter specified by its offset could not be found");
    2262             :                         /* returns out of this function */
    2263             :                 }
    2264             :         } else {
    2265             :                 zend_uint i;
    2266             : 
    2267           0 :                 position= -1;
    2268           0 :                 convert_to_string_ex(parameter);
    2269           0 :                 for (i = 0; i < fptr->common.num_args; i++) {
    2270           0 :                         if (arg_info[i].name && strcmp(arg_info[i].name, Z_STRVAL_PP(parameter)) == 0) {
    2271           0 :                                 position= i;
    2272           0 :                                 break;
    2273             :                         }
    2274             :                 }
    2275           0 :                 if (position == -1) {
    2276           0 :                         if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
    2277           0 :                                 if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
    2278           0 :                                         efree((char*)fptr->common.function_name);
    2279             :                                 }
    2280           0 :                                 efree(fptr);
    2281             :                         }
    2282           0 :                         if (is_closure) {
    2283           0 :                                 zval_ptr_dtor(&reference);
    2284             :                         }
    2285           0 :                         _DO_THROW("The parameter specified by its name could not be found");
    2286             :                         /* returns out of this function */
    2287             :                 }
    2288             :         }
    2289             : 
    2290           0 :         MAKE_STD_ZVAL(name);
    2291           0 :         if (arg_info[position].name) {
    2292           0 :                 ZVAL_STRINGL(name, arg_info[position].name, arg_info[position].name_len, 1);
    2293             :         } else {
    2294           0 :                 ZVAL_NULL(name);
    2295             :         }
    2296           0 :         reflection_update_property(object, "name", name);
    2297             : 
    2298           0 :         ref = (parameter_reference*) emalloc(sizeof(parameter_reference));
    2299           0 :         ref->arg_info = &arg_info[position];
    2300           0 :         ref->offset = (zend_uint)position;
    2301           0 :         ref->required = fptr->common.required_num_args;
    2302           0 :         ref->fptr = fptr;
    2303             :         /* TODO: copy fptr */
    2304           0 :         intern->ptr = ref;
    2305           0 :         intern->ref_type = REF_TYPE_PARAMETER;
    2306           0 :         intern->ce = ce;
    2307           0 :         if (reference && is_closure) {
    2308           0 :                 intern->obj = reference;
    2309             :         }
    2310             : }
    2311             : /* }}} */
    2312             : 
    2313             : /* {{{ proto public string ReflectionParameter::__toString()
    2314             :    Returns a string representation */
    2315           0 : ZEND_METHOD(reflection_parameter, __toString)
    2316             : {
    2317             :         reflection_object *intern;
    2318             :         parameter_reference *param;
    2319             :         string str;
    2320             : 
    2321           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2322           0 :                 return;
    2323             :         }
    2324           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2325           0 :         string_init(&str);
    2326           0 :         _parameter_string(&str, param->fptr, param->arg_info, param->offset, param->required, "" TSRMLS_CC);
    2327           0 :         RETURN_STRINGL(str.string, str.len - 1, 0);
    2328             : }
    2329             : /* }}} */
    2330             : 
    2331             : /* {{{ proto public string ReflectionParameter::getName()
    2332             :    Returns this parameters's name */
    2333           0 : ZEND_METHOD(reflection_parameter, getName)
    2334             : {
    2335           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2336           0 :                 return;
    2337             :         }
    2338           0 :         _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
    2339             : }
    2340             : /* }}} */
    2341             : 
    2342             : /* {{{ proto public ReflectionFunction ReflectionParameter::getDeclaringFunction()
    2343             :    Returns the ReflectionFunction for the function of this parameter */
    2344           0 : ZEND_METHOD(reflection_parameter, getDeclaringFunction)
    2345             : {
    2346             :         reflection_object *intern;
    2347             :         parameter_reference *param;
    2348             : 
    2349           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2350           0 :                 return;
    2351             :         }
    2352           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2353             : 
    2354           0 :         if (!param->fptr->common.scope) {
    2355           0 :                 reflection_function_factory(_copy_function(param->fptr TSRMLS_CC), intern->obj, return_value TSRMLS_CC);
    2356             :         } else {
    2357           0 :                 reflection_method_factory(param->fptr->common.scope, _copy_function(param->fptr TSRMLS_CC), intern->obj, return_value TSRMLS_CC);
    2358             :         }
    2359             : }
    2360             : /* }}} */
    2361             : 
    2362             : /* {{{ proto public ReflectionClass|NULL ReflectionParameter::getDeclaringClass()
    2363             :    Returns in which class this parameter is defined (not the typehint of the parameter) */
    2364           0 : ZEND_METHOD(reflection_parameter, getDeclaringClass)
    2365             : {
    2366             :         reflection_object *intern;
    2367             :         parameter_reference *param;
    2368             : 
    2369           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2370           0 :                 return;
    2371             :         }
    2372           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2373             : 
    2374           0 :         if (param->fptr->common.scope) {
    2375           0 :                 zend_reflection_class_factory(param->fptr->common.scope, return_value TSRMLS_CC);
    2376             :         }
    2377             : }
    2378             : /* }}} */
    2379             : 
    2380             : /* {{{ proto public ReflectionClass|NULL ReflectionParameter::getClass()
    2381             :    Returns this parameters's class hint or NULL if there is none */
    2382           0 : ZEND_METHOD(reflection_parameter, getClass)
    2383             : {
    2384             :         reflection_object *intern;
    2385             :         parameter_reference *param;
    2386             :         zend_class_entry **pce, *ce;
    2387             : 
    2388           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2389           0 :                 return;
    2390             :         }
    2391           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2392             : 
    2393           0 :         if (param->arg_info->class_name) {
    2394             :                 /* Class name is stored as a string, we might also get "self" or "parent"
    2395             :                  * - For "self", simply use the function scope. If scope is NULL then
    2396             :                  *   the function is global and thus self does not make any sense
    2397             :                  *
    2398             :                  * - For "parent", use the function scope's parent. If scope is NULL then
    2399             :                  *   the function is global and thus parent does not make any sense.
    2400             :                  *   If the parent is NULL then the class does not extend anything and
    2401             :                  *   thus parent does not make any sense, either.
    2402             :                  *
    2403             :                  * TODO: Think about moving these checks to the compiler or some sort of
    2404             :                  * lint-mode.
    2405             :                  */
    2406           0 :                 if (0 == zend_binary_strcasecmp(param->arg_info->class_name, param->arg_info->class_name_len, "self", sizeof("self")- 1)) {
    2407           0 :                         ce = param->fptr->common.scope;
    2408           0 :                         if (!ce) {
    2409           0 :                                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2410             :                                         "Parameter uses 'self' as type hint but function is not a class member!");
    2411           0 :                                 return;
    2412             :                         }
    2413           0 :                         pce= &ce;
    2414           0 :                 } else if (0 == zend_binary_strcasecmp(param->arg_info->class_name, param->arg_info->class_name_len, "parent", sizeof("parent")- 1)) {
    2415           0 :                         ce = param->fptr->common.scope;
    2416           0 :                         if (!ce) {
    2417           0 :                                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2418             :                                         "Parameter uses 'parent' as type hint but function is not a class member!");
    2419           0 :                                 return;
    2420             :                         }
    2421           0 :                         if (!ce->parent) {
    2422           0 :                                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2423             :                                         "Parameter uses 'parent' as type hint although class does not have a parent!");
    2424           0 :                                 return;
    2425             :                         }
    2426           0 :                         pce= &ce->parent;
    2427           0 :                 } else if (zend_lookup_class(param->arg_info->class_name, param->arg_info->class_name_len, &pce TSRMLS_CC) == FAILURE) {
    2428           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2429           0 :                                 "Class %s does not exist", param->arg_info->class_name);
    2430           0 :                         return;
    2431             :                 }
    2432           0 :                 zend_reflection_class_factory(*pce, return_value TSRMLS_CC);
    2433             :         }
    2434             : }
    2435             : /* }}} */
    2436             : 
    2437             : /* {{{ proto public bool ReflectionParameter::isArray()
    2438             :    Returns whether parameter MUST be an array */
    2439           0 : ZEND_METHOD(reflection_parameter, isArray)
    2440             : {
    2441             :         reflection_object *intern;
    2442             :         parameter_reference *param;
    2443             : 
    2444           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2445           0 :                 return;
    2446             :         }
    2447           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2448             : 
    2449           0 :         RETVAL_BOOL(param->arg_info->type_hint == IS_ARRAY);
    2450             : }
    2451             : /* }}} */
    2452             : 
    2453             : /* {{{ proto public bool ReflectionParameter::isCallable()
    2454             :    Returns whether parameter MUST be callable */
    2455           0 : ZEND_METHOD(reflection_parameter, isCallable)
    2456             : {
    2457             :         reflection_object *intern;
    2458             :         parameter_reference *param;
    2459             : 
    2460           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2461           0 :                 return;
    2462             :         }
    2463           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2464             : 
    2465           0 :         RETVAL_BOOL(param->arg_info->type_hint == IS_CALLABLE);
    2466             : }
    2467             : /* }}} */
    2468             : 
    2469             : /* {{{ proto public bool ReflectionParameter::allowsNull()
    2470             :    Returns whether NULL is allowed as this parameters's value */
    2471           0 : ZEND_METHOD(reflection_parameter, allowsNull)
    2472             : {
    2473             :         reflection_object *intern;
    2474             :         parameter_reference *param;
    2475             : 
    2476           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2477           0 :                 return;
    2478             :         }
    2479           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2480             : 
    2481           0 :         RETVAL_BOOL(param->arg_info->allow_null);
    2482             : }
    2483             : /* }}} */
    2484             : 
    2485             : /* {{{ proto public bool ReflectionParameter::isPassedByReference()
    2486             :    Returns whether this parameters is passed to by reference */
    2487           0 : ZEND_METHOD(reflection_parameter, isPassedByReference)
    2488             : {
    2489             :         reflection_object *intern;
    2490             :         parameter_reference *param;
    2491             : 
    2492           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2493           0 :                 return;
    2494             :         }
    2495           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2496             : 
    2497           0 :         RETVAL_BOOL(param->arg_info->pass_by_reference);
    2498             : }
    2499             : /* }}} */
    2500             : 
    2501             : /* {{{ proto public bool ReflectionParameter::canBePassedByValue()
    2502             :    Returns whether this parameter can be passed by value */
    2503           0 : ZEND_METHOD(reflection_parameter, canBePassedByValue)
    2504             : {
    2505             :         reflection_object *intern;
    2506             :         parameter_reference *param;
    2507             : 
    2508           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2509           0 :                 return;
    2510             :         }
    2511           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2512             : 
    2513             :         /* true if it's ZEND_SEND_BY_VAL or ZEND_SEND_PREFER_REF */
    2514           0 :         RETVAL_BOOL(param->arg_info->pass_by_reference != ZEND_SEND_BY_REF);
    2515             : }
    2516             : /* }}} */
    2517             : 
    2518             : /* {{{ proto public bool ReflectionParameter::getPosition()
    2519             :    Returns whether this parameter is an optional parameter */
    2520           0 : ZEND_METHOD(reflection_parameter, getPosition)
    2521             : {
    2522             :         reflection_object *intern;
    2523             :         parameter_reference *param;
    2524             : 
    2525           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2526           0 :                 return;
    2527             :         }
    2528           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2529             : 
    2530           0 :         RETVAL_LONG(param->offset);
    2531             : }
    2532             : /* }}} */
    2533             : 
    2534             : /* {{{ proto public bool ReflectionParameter::isOptional()
    2535             :    Returns whether this parameter is an optional parameter */
    2536           0 : ZEND_METHOD(reflection_parameter, isOptional)
    2537             : {
    2538             :         reflection_object *intern;
    2539             :         parameter_reference *param;
    2540             : 
    2541           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2542           0 :                 return;
    2543             :         }
    2544           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2545             : 
    2546           0 :         RETVAL_BOOL(param->offset >= param->required);
    2547             : }
    2548             : /* }}} */
    2549             : 
    2550             : /* {{{ proto public bool ReflectionParameter::isDefaultValueAvailable()
    2551             :    Returns whether the default value of this parameter is available */
    2552           0 : ZEND_METHOD(reflection_parameter, isDefaultValueAvailable)
    2553             : {
    2554             :         reflection_object *intern;
    2555             :         parameter_reference *param;
    2556             :         zend_op *precv;
    2557             : 
    2558           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2559           0 :                 return;
    2560             :         }
    2561           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2562             : 
    2563           0 :         if (param->fptr->type != ZEND_USER_FUNCTION)
    2564             :         {
    2565           0 :                 RETURN_FALSE;
    2566             :         }
    2567             : 
    2568           0 :         precv = _get_recv_op((zend_op_array*)param->fptr, param->offset);
    2569           0 :         if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) {
    2570           0 :                 RETURN_FALSE;
    2571             :         }
    2572           0 :         RETURN_TRUE;
    2573             : }
    2574             : /* }}} */
    2575             : 
    2576             : /* {{{ proto public bool ReflectionParameter::getDefaultValue()
    2577             :    Returns the default value of this parameter or throws an exception */
    2578           0 : ZEND_METHOD(reflection_parameter, getDefaultValue)
    2579             : {
    2580             :         parameter_reference *param;
    2581             :         zend_op *precv;
    2582             : 
    2583           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2584           0 :                 return;
    2585             :         }
    2586             : 
    2587           0 :         param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU);
    2588           0 :         if (!param) {
    2589           0 :                 return;
    2590             :         }
    2591             : 
    2592           0 :         precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
    2593           0 :         if (!precv) {
    2594           0 :                 return;
    2595             :         }
    2596             : 
    2597           0 :         *return_value = *precv->op2.zv;
    2598           0 :         INIT_PZVAL(return_value);
    2599           0 :         if (!IS_CONSTANT_TYPE(Z_TYPE_P(return_value))) {
    2600           0 :                 zval_copy_ctor(return_value);
    2601             :         }
    2602           0 :         zval_update_constant_ex(&return_value, 0, param->fptr->common.scope TSRMLS_CC);
    2603             : }
    2604             : /* }}} */
    2605             : 
    2606             : /* {{{ proto public bool ReflectionParameter::isDefaultValueConstant()
    2607             :    Returns whether the default value of this parameter is constant */
    2608           0 : ZEND_METHOD(reflection_parameter, isDefaultValueConstant)
    2609             : {
    2610             :         zend_op *precv;
    2611             :         parameter_reference *param;
    2612             : 
    2613           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2614           0 :                 return;
    2615             :         }
    2616             : 
    2617           0 :         param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU);
    2618           0 :         if (!param) {
    2619           0 :                 RETURN_FALSE;
    2620             :         }
    2621             : 
    2622           0 :         precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
    2623           0 :         if (precv && (Z_TYPE_P(precv->op2.zv) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) {
    2624           0 :                 RETURN_TRUE;
    2625             :         }
    2626             : 
    2627           0 :         RETURN_FALSE;
    2628             : }
    2629             : /* }}} */
    2630             : 
    2631             : /* {{{ proto public mixed ReflectionParameter::getDefaultValueConstantName()
    2632             :    Returns the default value's constant name if default value is constant or null */
    2633           0 : ZEND_METHOD(reflection_parameter, getDefaultValueConstantName)
    2634             : {
    2635             :         zend_op *precv;
    2636             :         parameter_reference *param;
    2637             : 
    2638           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2639           0 :                 return;
    2640             :         }
    2641             : 
    2642           0 :         param = _reflection_param_get_default_param(INTERNAL_FUNCTION_PARAM_PASSTHRU);
    2643           0 :         if (!param) {
    2644           0 :                 return;
    2645             :         }
    2646             : 
    2647           0 :         precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
    2648           0 :         if (precv && (Z_TYPE_P(precv->op2.zv) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) {
    2649           0 :                 RETURN_STRINGL(Z_STRVAL_P(precv->op2.zv), Z_STRLEN_P(precv->op2.zv), 1);
    2650             :         }
    2651             : }
    2652             : /* }}} */
    2653             : 
    2654             : /* {{{ proto public bool ReflectionParameter::isVariadic()
    2655             :    Returns whether this parameter is a variadic parameter */
    2656           0 : ZEND_METHOD(reflection_parameter, isVariadic)
    2657             : {
    2658             :         reflection_object *intern;
    2659             :         parameter_reference *param;
    2660             : 
    2661           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2662           0 :                 return;
    2663             :         }
    2664           0 :         GET_REFLECTION_OBJECT_PTR(param);
    2665             : 
    2666           0 :         RETVAL_BOOL(param->arg_info->is_variadic);
    2667             : }
    2668             : /* }}} */
    2669             : 
    2670             : /* {{{ proto public static mixed ReflectionMethod::export(mixed class, string name [, bool return]) throws ReflectionException
    2671             :    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
    2672           0 : ZEND_METHOD(reflection_method, export)
    2673             : {
    2674           0 :         _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_method_ptr, 2);
    2675           0 : }
    2676             : /* }}} */
    2677             : 
    2678             : /* {{{ proto public void ReflectionMethod::__construct(mixed class_or_method [, string name])
    2679             :    Constructor. Throws an Exception in case the given method does not exist */
    2680           0 : ZEND_METHOD(reflection_method, __construct)
    2681             : {
    2682             :         zval *name, *classname;
    2683             :         zval *object, *orig_obj;
    2684             :         reflection_object *intern;
    2685             :         char *lcname;
    2686             :         zend_class_entry **pce;
    2687             :         zend_class_entry *ce;
    2688             :         zend_function *mptr;
    2689             :         char *name_str, *tmp;
    2690             :         int name_len, tmp_len;
    2691             :         zval ztmp;
    2692             : 
    2693           0 :         if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "zs", &classname, &name_str, &name_len) == FAILURE) {
    2694           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len) == FAILURE) {
    2695           0 :                         return;
    2696             :                 }
    2697           0 :                 if ((tmp = strstr(name_str, "::")) == NULL) {
    2698           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invalid method name %s", name_str);
    2699           0 :                         return;
    2700             :                 }
    2701           0 :                 classname = &ztmp;
    2702           0 :                 tmp_len = tmp - name_str;
    2703           0 :                 ZVAL_STRINGL(classname, name_str, tmp_len, 1);
    2704           0 :                 name_len = name_len - (tmp_len + 2);
    2705           0 :                 name_str = tmp + 2;
    2706           0 :                 orig_obj = NULL;
    2707           0 :         } else if (Z_TYPE_P(classname) == IS_OBJECT) {
    2708           0 :                 orig_obj = classname;
    2709             :         } else {
    2710           0 :                 orig_obj = NULL;
    2711             :         }
    2712             : 
    2713           0 :         object = getThis();
    2714           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    2715           0 :         if (intern == NULL) {
    2716           0 :                 return;
    2717             :         }
    2718             : 
    2719             :         /* Find the class entry */
    2720           0 :         switch (Z_TYPE_P(classname)) {
    2721             :                 case IS_STRING:
    2722           0 :                         if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) {
    2723           0 :                                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2724           0 :                                                 "Class %s does not exist", Z_STRVAL_P(classname));
    2725           0 :                                 if (classname == &ztmp) {
    2726             :                                         zval_dtor(&ztmp);
    2727             :                                 }
    2728           0 :                                 return;
    2729             :                         }
    2730           0 :                         ce = *pce;
    2731           0 :                         break;
    2732             : 
    2733             :                 case IS_OBJECT:
    2734           0 :                         ce = Z_OBJCE_P(classname);
    2735           0 :                         break;
    2736             : 
    2737             :                 default:
    2738           0 :                         if (classname == &ztmp) {
    2739             :                                 zval_dtor(&ztmp);
    2740             :                         }
    2741           0 :                         _DO_THROW("The parameter class is expected to be either a string or an object");
    2742             :                         /* returns out of this function */
    2743             :         }
    2744             : 
    2745           0 :         if (classname == &ztmp) {
    2746             :                 zval_dtor(&ztmp);
    2747             :         }
    2748             : 
    2749           0 :         lcname = zend_str_tolower_dup(name_str, name_len);
    2750             : 
    2751           0 :         if (ce == zend_ce_closure && orig_obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
    2752             :                 && memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
    2753           0 :                 && (mptr = zend_get_closure_invoke_method(orig_obj TSRMLS_CC)) != NULL)
    2754             :         {
    2755             :                 /* do nothing, mptr already set */
    2756           0 :         } else if (zend_hash_find(&ce->function_table, lcname, name_len + 1, (void **) &mptr) == FAILURE) {
    2757           0 :                 efree(lcname);
    2758           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2759             :                         "Method %s::%s() does not exist", ce->name, name_str);
    2760           0 :                 return;
    2761             :         }
    2762           0 :         efree(lcname);
    2763             : 
    2764           0 :         MAKE_STD_ZVAL(classname);
    2765           0 :         ZVAL_STRINGL(classname, mptr->common.scope->name, mptr->common.scope->name_length, 1);
    2766             : 
    2767           0 :         reflection_update_property(object, "class", classname);
    2768             : 
    2769           0 :         MAKE_STD_ZVAL(name);
    2770           0 :         ZVAL_STRING(name, mptr->common.function_name, 1);
    2771           0 :         reflection_update_property(object, "name", name);
    2772           0 :         intern->ptr = mptr;
    2773           0 :         intern->ref_type = REF_TYPE_FUNCTION;
    2774           0 :         intern->ce = ce;
    2775             : }
    2776             : /* }}} */
    2777             : 
    2778             : /* {{{ proto public string ReflectionMethod::__toString()
    2779             :    Returns a string representation */
    2780           0 : ZEND_METHOD(reflection_method, __toString)
    2781             : {
    2782             :         reflection_object *intern;
    2783             :         zend_function *mptr;
    2784             :         string str;
    2785             : 
    2786           0 :         if (zend_parse_parameters_none() == FAILURE) {
    2787           0 :                 return;
    2788             :         }
    2789           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    2790           0 :         string_init(&str);
    2791           0 :         _function_string(&str, mptr, intern->ce, "" TSRMLS_CC);
    2792           0 :         RETURN_STRINGL(str.string, str.len - 1, 0);
    2793             : }
    2794             : /* }}} */
    2795             : 
    2796             : /* {{{ proto public mixed ReflectionMethod::getClosure([mixed object])
    2797             :    Invokes the function */
    2798           0 : ZEND_METHOD(reflection_method, getClosure)
    2799             : {
    2800             :         reflection_object *intern;
    2801             :         zval *obj;
    2802             :         zend_function *mptr;
    2803             : 
    2804           0 :         METHOD_NOTSTATIC(reflection_method_ptr);
    2805           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    2806             : 
    2807           0 :         if (mptr->common.fn_flags & ZEND_ACC_STATIC)  {
    2808           0 :                 zend_create_closure(return_value, mptr, mptr->common.scope, NULL TSRMLS_CC);
    2809             :         } else {
    2810           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
    2811           0 :                         return;
    2812             :                 }
    2813             : 
    2814           0 :                 if (!instanceof_function(Z_OBJCE_P(obj), mptr->common.scope TSRMLS_CC)) {
    2815           0 :                         _DO_THROW("Given object is not an instance of the class this method was declared in");
    2816             :                         /* Returns from this function */
    2817             :                 }
    2818             : 
    2819             :                 /* This is an original closure object and __invoke is to be called. */
    2820           0 :                 if (Z_OBJCE_P(obj) == zend_ce_closure && mptr->type == ZEND_INTERNAL_FUNCTION &&
    2821           0 :                         (mptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0)
    2822             :                 {
    2823           0 :                         RETURN_ZVAL(obj, 1, 0);
    2824             :                 } else {
    2825           0 :                         zend_create_closure(return_value, mptr, mptr->common.scope, obj TSRMLS_CC);
    2826             :                 }
    2827             :         }
    2828             : }
    2829             : /* }}} */
    2830             : 
    2831             : /* {{{ proto public mixed ReflectionMethod::invoke(mixed object, mixed* args)
    2832             :    Invokes the method. */
    2833           0 : ZEND_METHOD(reflection_method, invoke)
    2834             : {
    2835             :         zval *retval_ptr;
    2836           0 :         zval ***params = NULL;
    2837             :         zval *object_ptr;
    2838             :         reflection_object *intern;
    2839             :         zend_function *mptr;
    2840           0 :         int result, num_args = 0;
    2841             :         zend_fcall_info fci;
    2842             :         zend_fcall_info_cache fcc;
    2843             :         zend_class_entry *obj_ce;
    2844             : 
    2845           0 :         METHOD_NOTSTATIC(reflection_method_ptr);
    2846             : 
    2847           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    2848             : 
    2849           0 :         if ((!(mptr->common.fn_flags & ZEND_ACC_PUBLIC)
    2850           0 :                  || (mptr->common.fn_flags & ZEND_ACC_ABSTRACT))
    2851           0 :                  && intern->ignore_visibility == 0)
    2852             :         {
    2853           0 :                 if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
    2854           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2855             :                                 "Trying to invoke abstract method %s::%s()",
    2856           0 :                                 mptr->common.scope->name, mptr->common.function_name);
    2857             :                 } else {
    2858           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2859             :                                 "Trying to invoke %s method %s::%s() from scope %s",
    2860           0 :                                 mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private",
    2861           0 :                                 mptr->common.scope->name, mptr->common.function_name,
    2862           0 :                                 Z_OBJCE_P(getThis())->name);
    2863             :                 }
    2864           0 :                 return;
    2865             :         }
    2866             : 
    2867           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &params, &num_args) == FAILURE) {
    2868           0 :                 return;
    2869             :         }
    2870             : 
    2871             :         /* In case this is a static method, we should'nt pass an object_ptr
    2872             :          * (which is used as calling context aka $this). We can thus ignore the
    2873             :          * first parameter.
    2874             :          *
    2875             :          * Else, we verify that the given object is an instance of the class.
    2876             :          */
    2877           0 :         if (mptr->common.fn_flags & ZEND_ACC_STATIC) {
    2878           0 :                 object_ptr = NULL;
    2879           0 :                 obj_ce = mptr->common.scope;
    2880             :         } else {
    2881           0 :                 if (Z_TYPE_PP(params[0]) != IS_OBJECT) {
    2882           0 :                         efree(params);
    2883           0 :                         _DO_THROW("Non-object passed to Invoke()");
    2884             :                         /* Returns from this function */
    2885             :                 }
    2886             : 
    2887           0 :                 obj_ce = Z_OBJCE_PP(params[0]);
    2888             : 
    2889           0 :                 if (!instanceof_function(obj_ce, mptr->common.scope TSRMLS_CC)) {
    2890           0 :                         if (params) {
    2891           0 :                                 efree(params);
    2892             :                         }
    2893           0 :                         _DO_THROW("Given object is not an instance of the class this method was declared in");
    2894             :                         /* Returns from this function */
    2895             :                 }
    2896             : 
    2897           0 :                 object_ptr = *params[0];
    2898             :         }
    2899             : 
    2900           0 :         fci.size = sizeof(fci);
    2901           0 :         fci.function_table = NULL;
    2902           0 :         fci.function_name = NULL;
    2903           0 :         fci.symbol_table = NULL;
    2904           0 :         fci.object_ptr = object_ptr;
    2905           0 :         fci.retval_ptr_ptr = &retval_ptr;
    2906           0 :         fci.param_count = num_args - 1;
    2907           0 :         fci.params = params + 1;
    2908           0 :         fci.no_separation = 1;
    2909             : 
    2910           0 :         fcc.initialized = 1;
    2911           0 :         fcc.function_handler = mptr;
    2912           0 :         fcc.calling_scope = obj_ce;
    2913           0 :         fcc.called_scope = intern->ce;
    2914           0 :         fcc.object_ptr = object_ptr;
    2915             : 
    2916           0 :         result = zend_call_function(&fci, &fcc TSRMLS_CC);
    2917             : 
    2918           0 :         if (params) {
    2919           0 :                 efree(params);
    2920             :         }
    2921             : 
    2922           0 :         if (result == FAILURE) {
    2923           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2924           0 :                         "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name);
    2925           0 :                 return;
    2926             :         }
    2927             : 
    2928           0 :         if (retval_ptr) {
    2929           0 :                 COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
    2930             :         }
    2931             : }
    2932             : /* }}} */
    2933             : 
    2934             : /* {{{ proto public mixed ReflectionMethod::invokeArgs(mixed object, array args)
    2935             :    Invokes the function and pass its arguments as array. */
    2936           0 : ZEND_METHOD(reflection_method, invokeArgs)
    2937             : {
    2938             :         zval *retval_ptr;
    2939             :         zval ***params;
    2940             :         zval *object;
    2941             :         reflection_object *intern;
    2942             :         zend_function *mptr;
    2943             :         int argc;
    2944             :         int result;
    2945             :         zend_fcall_info fci;
    2946             :         zend_fcall_info_cache fcc;
    2947             :         zend_class_entry *obj_ce;
    2948             :         zval *param_array;
    2949             : 
    2950           0 :         METHOD_NOTSTATIC(reflection_method_ptr);
    2951             : 
    2952           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    2953             : 
    2954           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o!a", &object, &param_array) == FAILURE) {
    2955           0 :                 return;
    2956             :         }
    2957             : 
    2958           0 :         if ((!(mptr->common.fn_flags & ZEND_ACC_PUBLIC)
    2959           0 :                  || (mptr->common.fn_flags & ZEND_ACC_ABSTRACT))
    2960           0 :                  && intern->ignore_visibility == 0)
    2961             :         {
    2962           0 :                 if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
    2963           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2964             :                                 "Trying to invoke abstract method %s::%s()",
    2965           0 :                                 mptr->common.scope->name, mptr->common.function_name);
    2966             :                 } else {
    2967           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2968             :                                 "Trying to invoke %s method %s::%s() from scope %s",
    2969           0 :                                 mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private",
    2970           0 :                                 mptr->common.scope->name, mptr->common.function_name,
    2971           0 :                                 Z_OBJCE_P(getThis())->name);
    2972             :                 }
    2973           0 :                 return;
    2974             :         }
    2975             : 
    2976           0 :         argc = zend_hash_num_elements(Z_ARRVAL_P(param_array));
    2977             : 
    2978           0 :         params = safe_emalloc(sizeof(zval **), argc, 0);
    2979           0 :         zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, &params TSRMLS_CC);
    2980           0 :         params -= argc;
    2981             : 
    2982             :         /* In case this is a static method, we should'nt pass an object_ptr
    2983             :          * (which is used as calling context aka $this). We can thus ignore the
    2984             :          * first parameter.
    2985             :          *
    2986             :          * Else, we verify that the given object is an instance of the class.
    2987             :          */
    2988           0 :         if (mptr->common.fn_flags & ZEND_ACC_STATIC) {
    2989           0 :                 object = NULL;
    2990           0 :                 obj_ce = mptr->common.scope;
    2991             :         } else {
    2992           0 :                 if (!object) {
    2993           0 :                         efree(params);
    2994           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    2995             :                                 "Trying to invoke non static method %s::%s() without an object",
    2996           0 :                                 mptr->common.scope->name, mptr->common.function_name);
    2997           0 :                         return;
    2998             :                 }
    2999             : 
    3000           0 :                 obj_ce = Z_OBJCE_P(object);
    3001             : 
    3002           0 :                 if (!instanceof_function(obj_ce, mptr->common.scope TSRMLS_CC)) {
    3003           0 :                         efree(params);
    3004           0 :                         _DO_THROW("Given object is not an instance of the class this method was declared in");
    3005             :                         /* Returns from this function */
    3006             :                 }
    3007             :         }
    3008             : 
    3009           0 :         fci.size = sizeof(fci);
    3010           0 :         fci.function_table = NULL;
    3011           0 :         fci.function_name = NULL;
    3012           0 :         fci.symbol_table = NULL;
    3013           0 :         fci.object_ptr = object;
    3014           0 :         fci.retval_ptr_ptr = &retval_ptr;
    3015           0 :         fci.param_count = argc;
    3016           0 :         fci.params = params;
    3017           0 :         fci.no_separation = 1;
    3018             : 
    3019           0 :         fcc.initialized = 1;
    3020           0 :         fcc.function_handler = mptr;
    3021           0 :         fcc.calling_scope = obj_ce;
    3022           0 :         fcc.called_scope = intern->ce;
    3023           0 :         fcc.object_ptr = object;
    3024             :         
    3025             :         /* 
    3026             :          * Copy the zend_function when calling via handler (e.g. Closure::__invoke())
    3027             :          */
    3028           0 :         if (mptr->type == ZEND_INTERNAL_FUNCTION &&
    3029           0 :                 (mptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) {
    3030           0 :                 fcc.function_handler = _copy_function(mptr TSRMLS_CC);
    3031             :         }
    3032             : 
    3033           0 :         result = zend_call_function(&fci, &fcc TSRMLS_CC);
    3034             : 
    3035           0 :         efree(params);
    3036             : 
    3037           0 :         if (result == FAILURE) {
    3038           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    3039           0 :                         "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name);
    3040           0 :                 return;
    3041             :         }
    3042             : 
    3043           0 :         if (retval_ptr) {
    3044           0 :                 COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
    3045             :         }
    3046             : }
    3047             : /* }}} */
    3048             : 
    3049             : /* {{{ proto public bool ReflectionMethod::isFinal()
    3050             :    Returns whether this method is final */
    3051           0 : ZEND_METHOD(reflection_method, isFinal)
    3052             : {
    3053           0 :         _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_FINAL);
    3054           0 : }
    3055             : /* }}} */
    3056             : 
    3057             : /* {{{ proto public bool ReflectionMethod::isAbstract()
    3058             :    Returns whether this method is abstract */
    3059           0 : ZEND_METHOD(reflection_method, isAbstract)
    3060             : {
    3061           0 :         _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_ABSTRACT);
    3062           0 : }
    3063             : /* }}} */
    3064             : 
    3065             : /* {{{ proto public bool ReflectionMethod::isPublic()
    3066             :    Returns whether this method is public */
    3067           0 : ZEND_METHOD(reflection_method, isPublic)
    3068             : {
    3069           0 :         _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC);
    3070           0 : }
    3071             : /* }}} */
    3072             : 
    3073             : /* {{{ proto public bool ReflectionMethod::isPrivate()
    3074             :    Returns whether this method is private */
    3075           0 : ZEND_METHOD(reflection_method, isPrivate)
    3076             : {
    3077           0 :         _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PRIVATE);
    3078           0 : }
    3079             : /* }}} */
    3080             : 
    3081             : /* {{{ proto public bool ReflectionMethod::isProtected()
    3082             :    Returns whether this method is protected */
    3083           0 : ZEND_METHOD(reflection_method, isProtected)
    3084             : {
    3085           0 :         _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PROTECTED);
    3086           0 : }
    3087             : /* }}} */
    3088             : 
    3089             : /* {{{ proto public bool ReflectionMethod::isStatic()
    3090             :    Returns whether this method is static */
    3091           0 : ZEND_METHOD(reflection_method, isStatic)
    3092             : {
    3093           0 :         _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_STATIC);
    3094           0 : }
    3095             : /* }}} */
    3096             : 
    3097             : /* {{{ proto public bool ReflectionFunction::isDeprecated()
    3098             :    Returns whether this function is deprecated */
    3099           0 : ZEND_METHOD(reflection_function, isDeprecated)
    3100             : {
    3101           0 :         _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_DEPRECATED);
    3102           0 : }
    3103             : /* }}} */
    3104             : 
    3105             : /* {{{ proto public bool ReflectionFunction::isGenerator()
    3106             :    Returns whether this function is a generator */
    3107           0 : ZEND_METHOD(reflection_function, isGenerator)
    3108             : {
    3109           0 :         _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_GENERATOR);
    3110           0 : }
    3111             : /* }}} */
    3112             : 
    3113             : /* {{{ proto public bool ReflectionFunction::isVariadic()
    3114             :    Returns whether this function is variadic */
    3115           0 : ZEND_METHOD(reflection_function, isVariadic)
    3116             : {
    3117           0 :         _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_VARIADIC);
    3118           0 : }
    3119             : /* }}} */
    3120             : 
    3121             : /* {{{ proto public bool ReflectionFunction::inNamespace()
    3122             :    Returns whether this function is defined in namespace */
    3123           0 : ZEND_METHOD(reflection_function, inNamespace)
    3124             : {
    3125             :         zval **name;
    3126             :         const char *backslash;
    3127             : 
    3128           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3129           0 :                 return;
    3130             :         }
    3131           0 :         if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
    3132           0 :                 RETURN_FALSE;
    3133             :         }
    3134           0 :         if (Z_TYPE_PP(name) == IS_STRING
    3135           0 :                 && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
    3136           0 :                 && backslash > Z_STRVAL_PP(name))
    3137             :         {
    3138           0 :                 RETURN_TRUE;
    3139             :         }
    3140           0 :         RETURN_FALSE;
    3141             : }
    3142             : /* }}} */
    3143             : 
    3144             : /* {{{ proto public string ReflectionFunction::getNamespaceName()
    3145             :    Returns the name of namespace where this function is defined */
    3146           0 : ZEND_METHOD(reflection_function, getNamespaceName)
    3147             : {
    3148             :         zval **name;
    3149             :         const char *backslash;
    3150             : 
    3151           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3152           0 :                 return;
    3153             :         }
    3154           0 :         if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
    3155           0 :                 RETURN_FALSE;
    3156             :         }
    3157           0 :         if (Z_TYPE_PP(name) == IS_STRING
    3158           0 :                 && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
    3159           0 :                 && backslash > Z_STRVAL_PP(name))
    3160             :         {
    3161           0 :                 RETURN_STRINGL(Z_STRVAL_PP(name), backslash - Z_STRVAL_PP(name), 1);
    3162             :         }
    3163           0 :         RETURN_EMPTY_STRING();
    3164             : }
    3165             : /* }}} */
    3166             : 
    3167             : /* {{{ proto public string ReflectionFunction::getShortName()
    3168             :    Returns the short name of the function (without namespace part) */
    3169           0 : ZEND_METHOD(reflection_function, getShortName)
    3170             : {
    3171             :         zval **name;
    3172             :         const char *backslash;
    3173             : 
    3174           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3175           0 :                 return;
    3176             :         }
    3177           0 :         if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
    3178           0 :                 RETURN_FALSE;
    3179             :         }
    3180           0 :         if (Z_TYPE_PP(name) == IS_STRING
    3181           0 :                 && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
    3182           0 :                 && backslash > Z_STRVAL_PP(name))
    3183             :         {
    3184           0 :                 RETURN_STRINGL(backslash + 1, Z_STRLEN_PP(name) - (backslash - Z_STRVAL_PP(name) + 1), 1);
    3185             :         }
    3186           0 :         RETURN_ZVAL(*name, 1, 0);
    3187             : }
    3188             : /* }}} */
    3189             : 
    3190             : /* {{{ proto public bool ReflectionMethod::isConstructor()
    3191             :    Returns whether this method is the constructor */
    3192           0 : ZEND_METHOD(reflection_method, isConstructor)
    3193             : {
    3194             :         reflection_object *intern;
    3195             :         zend_function *mptr;
    3196             : 
    3197           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3198           0 :                 return;
    3199             :         }
    3200           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    3201             :         /* we need to check if the ctor is the ctor of the class level we we
    3202             :          * looking at since we might be looking at an inherited old style ctor
    3203             :          * defined in base class. */
    3204           0 :         RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_CTOR && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope);
    3205             : }
    3206             : /* }}} */
    3207             : 
    3208             : /* {{{ proto public bool ReflectionMethod::isDestructor()
    3209             :    Returns whether this method is static */
    3210           0 : ZEND_METHOD(reflection_method, isDestructor)
    3211             : {
    3212             :         reflection_object *intern;
    3213             :         zend_function *mptr;
    3214             : 
    3215           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3216           0 :                 return;
    3217             :         }
    3218           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    3219           0 :         RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_DTOR);
    3220             : }
    3221             : /* }}} */
    3222             : 
    3223             : /* {{{ proto public int ReflectionMethod::getModifiers()
    3224             :    Returns a bitfield of the access modifiers for this method */
    3225           0 : ZEND_METHOD(reflection_method, getModifiers)
    3226             : {
    3227             :         reflection_object *intern;
    3228             :         zend_function *mptr;
    3229             : 
    3230           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3231           0 :                 return;
    3232             :         }
    3233           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    3234             : 
    3235           0 :         RETURN_LONG(mptr->common.fn_flags);
    3236             : }
    3237             : /* }}} */
    3238             : 
    3239             : /* {{{ proto public ReflectionClass ReflectionMethod::getDeclaringClass()
    3240             :    Get the declaring class */
    3241           0 : ZEND_METHOD(reflection_method, getDeclaringClass)
    3242             : {
    3243             :         reflection_object *intern;
    3244             :         zend_function *mptr;
    3245             : 
    3246           0 :         METHOD_NOTSTATIC(reflection_method_ptr);
    3247           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    3248             : 
    3249           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3250           0 :                 return;
    3251             :         }
    3252             : 
    3253           0 :         zend_reflection_class_factory(mptr->common.scope, return_value TSRMLS_CC);
    3254             : }
    3255             : /* }}} */
    3256             : 
    3257             : /* {{{ proto public ReflectionClass ReflectionMethod::getPrototype()
    3258             :    Get the prototype */
    3259           0 : ZEND_METHOD(reflection_method, getPrototype)
    3260             : {
    3261             :         reflection_object *intern;
    3262             :         zend_function *mptr;
    3263             : 
    3264           0 :         METHOD_NOTSTATIC(reflection_method_ptr);
    3265           0 :         GET_REFLECTION_OBJECT_PTR(mptr);
    3266             : 
    3267           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3268           0 :                 return;
    3269             :         }
    3270             : 
    3271           0 :         if (!mptr->common.prototype) {
    3272           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    3273           0 :                         "Method %s::%s does not have a prototype", intern->ce->name, mptr->common.function_name);
    3274           0 :                 return;
    3275             :         }
    3276             : 
    3277           0 :         reflection_method_factory(mptr->common.prototype->common.scope, mptr->common.prototype, NULL, return_value TSRMLS_CC);
    3278             : }
    3279             : /* }}} */
    3280             : 
    3281             : /* {{{ proto public void ReflectionMethod::setAccessible(bool visible)
    3282             :    Sets whether non-public methods can be invoked */
    3283           0 : ZEND_METHOD(reflection_method, setAccessible)
    3284             : {
    3285             :         reflection_object *intern;
    3286             :         zend_bool visible;
    3287             : 
    3288           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &visible) == FAILURE) {
    3289           0 :                 return;
    3290             :         }
    3291             : 
    3292           0 :         intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
    3293             : 
    3294           0 :         if (intern == NULL) {
    3295           0 :                 return;
    3296             :         }
    3297             : 
    3298           0 :         intern->ignore_visibility = visible;
    3299             : }
    3300             : /* }}} */
    3301             : 
    3302             : /* {{{ proto public static mixed ReflectionClass::export(mixed argument [, bool return]) throws ReflectionException
    3303             :    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
    3304           0 : ZEND_METHOD(reflection_class, export)
    3305             : {
    3306           0 :         _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_class_ptr, 1);
    3307           0 : }
    3308             : /* }}} */
    3309             : 
    3310             : /* {{{ reflection_class_object_ctor */
    3311           0 : static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_object)
    3312             : {
    3313             :         zval *argument;
    3314             :         zval *object;
    3315             :         zval *classname;
    3316             :         reflection_object *intern;
    3317             :         zend_class_entry **ce;
    3318             : 
    3319           0 :         if (is_object) {
    3320           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &argument) == FAILURE) {
    3321           0 :                         return;
    3322             :                 }
    3323             :         } else {
    3324           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &argument) == FAILURE) {
    3325           0 :                         return;
    3326             :                 }
    3327             :         }
    3328             : 
    3329           0 :         object = getThis();
    3330           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    3331           0 :         if (intern == NULL) {
    3332           0 :                 return;
    3333             :         }
    3334             : 
    3335           0 :         if (Z_TYPE_P(argument) == IS_OBJECT) {
    3336           0 :                 MAKE_STD_ZVAL(classname);
    3337           0 :                 ZVAL_STRINGL(classname, Z_OBJCE_P(argument)->name, Z_OBJCE_P(argument)->name_length, 1);
    3338           0 :                 reflection_update_property(object, "name", classname);
    3339           0 :                 intern->ptr = Z_OBJCE_P(argument);
    3340           0 :                 if (is_object) {
    3341           0 :                         intern->obj = argument;
    3342           0 :                         zval_add_ref(&argument);
    3343             :                 }
    3344             :         } else {
    3345           0 :                 convert_to_string_ex(&argument);
    3346           0 :                 if (zend_lookup_class(Z_STRVAL_P(argument), Z_STRLEN_P(argument), &ce TSRMLS_CC) == FAILURE) {
    3347           0 :                         if (!EG(exception)) {
    3348           0 :                                 zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(argument));
    3349             :                         }
    3350           0 :                         return;
    3351             :                 }
    3352             : 
    3353           0 :                 MAKE_STD_ZVAL(classname);
    3354           0 :                 ZVAL_STRINGL(classname, (*ce)->name, (*ce)->name_length, 1);
    3355           0 :                 reflection_update_property(object, "name", classname);
    3356             : 
    3357           0 :                 intern->ptr = *ce;
    3358             :         }
    3359           0 :         intern->ref_type = REF_TYPE_OTHER;
    3360             : }
    3361             : /* }}} */
    3362             : 
    3363             : /* {{{ proto public void ReflectionClass::__construct(mixed argument) throws ReflectionException
    3364             :    Constructor. Takes a string or an instance as an argument */
    3365           0 : ZEND_METHOD(reflection_class, __construct)
    3366             : {
    3367           0 :         reflection_class_object_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
    3368           0 : }
    3369             : /* }}} */
    3370             : 
    3371             : /* {{{ add_class_vars */
    3372           0 : static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value TSRMLS_DC)
    3373             : {
    3374             :         HashPosition pos;
    3375             :         zend_property_info *prop_info;
    3376             :         zval *prop, *prop_copy;
    3377             :         char *key;
    3378             :         uint key_len;
    3379             :         ulong num_index;
    3380             : 
    3381           0 :         zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos);
    3382           0 :         while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop_info, &pos) == SUCCESS) {
    3383           0 :                 zend_hash_get_current_key_ex(&ce->properties_info, &key, &key_len, &num_index, 0, &pos);
    3384           0 :                 zend_hash_move_forward_ex(&ce->properties_info, &pos);
    3385           0 :                 if (((prop_info->flags & ZEND_ACC_SHADOW) &&
    3386           0 :                      prop_info->ce != ce) ||
    3387           0 :                     ((prop_info->flags & ZEND_ACC_PROTECTED) &&
    3388           0 :                      !zend_check_protected(prop_info->ce, ce)) ||
    3389           0 :                     ((prop_info->flags & ZEND_ACC_PRIVATE) &&
    3390           0 :                      prop_info->ce != ce)) {
    3391           0 :                         continue;
    3392             :                 }
    3393           0 :                 prop = NULL;
    3394           0 :                 if (prop_info->offset >= 0) {
    3395           0 :                         if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) {
    3396           0 :                                 prop = ce->default_static_members_table[prop_info->offset];
    3397           0 :                         } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) {
    3398           0 :                                 prop = ce->default_properties_table[prop_info->offset];
    3399             :                         }
    3400             :                 }
    3401           0 :                 if (!prop) {
    3402           0 :                         continue;
    3403             :                 }
    3404             : 
    3405             :                 /* copy: enforce read only access */
    3406           0 :                 ALLOC_ZVAL(prop_copy);
    3407           0 :                 *prop_copy = *prop;
    3408           0 :                 zval_copy_ctor(prop_copy);
    3409           0 :                 INIT_PZVAL(prop_copy);
    3410             : 
    3411             :                 /* this is necessary to make it able to work with default array
    3412             :                 * properties, returned to user */
    3413           0 :                 if (IS_CONSTANT_TYPE(Z_TYPE_P(prop_copy))) {
    3414           0 :                         zval_update_constant(&prop_copy, 1 TSRMLS_CC);
    3415             :                 }
    3416             : 
    3417           0 :                 add_assoc_zval(return_value, key, prop_copy);
    3418             :         }
    3419           0 : }
    3420             : /* }}} */
    3421             : 
    3422             : /* {{{ proto public array ReflectionClass::getStaticProperties()
    3423             :    Returns an associative array containing all static property values of the class */
    3424           0 : ZEND_METHOD(reflection_class, getStaticProperties)
    3425             : {
    3426             :         reflection_object *intern;
    3427             :         zend_class_entry *ce;
    3428             : 
    3429           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3430           0 :                 return;
    3431             :         }
    3432             : 
    3433           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3434             : 
    3435           0 :         zend_update_class_constants(ce TSRMLS_CC);
    3436             : 
    3437           0 :         array_init(return_value);
    3438           0 :         add_class_vars(ce, 1, return_value TSRMLS_CC);
    3439             : }
    3440             : /* }}} */
    3441             : 
    3442             : /* {{{ proto public mixed ReflectionClass::getStaticPropertyValue(string name [, mixed default])
    3443             :    Returns the value of a static property */
    3444           0 : ZEND_METHOD(reflection_class, getStaticPropertyValue)
    3445             : {
    3446             :         reflection_object *intern;
    3447             :         zend_class_entry *ce;
    3448             :         char *name;
    3449             :         int name_len;
    3450           0 :         zval **prop, *def_value = NULL;
    3451             : 
    3452           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &name, &name_len, &def_value) == FAILURE) {
    3453           0 :                 return;
    3454             :         }
    3455             : 
    3456           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3457             : 
    3458           0 :         zend_update_class_constants(ce TSRMLS_CC);
    3459           0 :         prop = zend_std_get_static_property(ce, name, name_len, 1, NULL TSRMLS_CC);
    3460           0 :         if (!prop) {
    3461           0 :                 if (def_value) {
    3462           0 :                         RETURN_ZVAL(def_value, 1, 0);
    3463             :                 } else {
    3464           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    3465             :                                 "Class %s does not have a property named %s", ce->name, name);
    3466             :                 }
    3467           0 :                 return;
    3468             :         } else {
    3469           0 :                 RETURN_ZVAL(*prop, 1, 0);
    3470             :         }
    3471             : }
    3472             : /* }}} */
    3473             : 
    3474             : /* {{{ proto public void ReflectionClass::setStaticPropertyValue($name, $value)
    3475             :    Sets the value of a static property */
    3476           0 : ZEND_METHOD(reflection_class, setStaticPropertyValue)
    3477             : {
    3478             :         reflection_object *intern;
    3479             :         zend_class_entry *ce;
    3480             :         char *name;
    3481             :         int name_len;
    3482             :         zval **variable_ptr, *value;
    3483             :         int refcount;
    3484             :         zend_uchar is_ref;
    3485             : 
    3486           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &value) == FAILURE) {
    3487           0 :                 return;
    3488             :         }
    3489             : 
    3490           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3491             : 
    3492           0 :         zend_update_class_constants(ce TSRMLS_CC);
    3493           0 :         variable_ptr = zend_std_get_static_property(ce, name, name_len, 1, NULL TSRMLS_CC);
    3494           0 :         if (!variable_ptr) {
    3495           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    3496             :                                 "Class %s does not have a property named %s", ce->name, name);
    3497           0 :                 return;
    3498             :         }
    3499           0 :         refcount = Z_REFCOUNT_PP(variable_ptr);
    3500           0 :         is_ref = Z_ISREF_PP(variable_ptr);
    3501           0 :         zval_dtor(*variable_ptr);
    3502           0 :         **variable_ptr = *value;
    3503           0 :         zval_copy_ctor(*variable_ptr);
    3504           0 :         Z_SET_REFCOUNT_PP(variable_ptr, refcount);
    3505           0 :         Z_SET_ISREF_TO_PP(variable_ptr, is_ref);
    3506             : 
    3507             : }
    3508             : /* }}} */
    3509             : 
    3510             : /* {{{ proto public array ReflectionClass::getDefaultProperties()
    3511             :    Returns an associative array containing copies of all default property values of the class */
    3512           0 : ZEND_METHOD(reflection_class, getDefaultProperties)
    3513             : {
    3514             :         reflection_object *intern;
    3515             :         zend_class_entry *ce;
    3516             : 
    3517           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3518           0 :                 return;
    3519             :         }
    3520           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3521           0 :         array_init(return_value);
    3522           0 :         zend_update_class_constants(ce TSRMLS_CC);
    3523           0 :         add_class_vars(ce, 1, return_value TSRMLS_CC);
    3524           0 :         add_class_vars(ce, 0, return_value TSRMLS_CC);
    3525             : }
    3526             : /* }}} */
    3527             : 
    3528             : /* {{{ proto public string ReflectionClass::__toString()
    3529             :    Returns a string representation */
    3530           0 : ZEND_METHOD(reflection_class, __toString)
    3531             : {
    3532             :         reflection_object *intern;
    3533             :         zend_class_entry *ce;
    3534             :         string str;
    3535             : 
    3536           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3537           0 :                 return;
    3538             :         }
    3539           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3540           0 :         string_init(&str);
    3541           0 :         _class_string(&str, ce, intern->obj, "" TSRMLS_CC);
    3542           0 :         RETURN_STRINGL(str.string, str.len - 1, 0);
    3543             : }
    3544             : /* }}} */
    3545             : 
    3546             : /* {{{ proto public string ReflectionClass::getName()
    3547             :    Returns the class' name */
    3548           0 : ZEND_METHOD(reflection_class, getName)
    3549             : {
    3550           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3551           0 :                 return;
    3552             :         }
    3553           0 :         _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
    3554             : }
    3555             : /* }}} */
    3556             : 
    3557             : /* {{{ proto public bool ReflectionClass::isInternal()
    3558             :    Returns whether this class is an internal class */
    3559           0 : ZEND_METHOD(reflection_class, isInternal)
    3560             : {
    3561             :         reflection_object *intern;
    3562             :         zend_class_entry *ce;
    3563             : 
    3564           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3565           0 :                 return;
    3566             :         }
    3567           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3568           0 :         RETURN_BOOL(ce->type == ZEND_INTERNAL_CLASS);
    3569             : }
    3570             : /* }}} */
    3571             : 
    3572             : /* {{{ proto public bool ReflectionClass::isUserDefined()
    3573             :    Returns whether this class is user-defined */
    3574           0 : ZEND_METHOD(reflection_class, isUserDefined)
    3575             : {
    3576             :         reflection_object *intern;
    3577             :         zend_class_entry *ce;
    3578             : 
    3579           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3580           0 :                 return;
    3581             :         }
    3582           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3583           0 :         RETURN_BOOL(ce->type == ZEND_USER_CLASS);
    3584             : }
    3585             : /* }}} */
    3586             : 
    3587             : /* {{{ proto public string ReflectionClass::getFileName()
    3588             :    Returns the filename of the file this class was declared in */
    3589           0 : ZEND_METHOD(reflection_class, getFileName)
    3590             : {
    3591             :         reflection_object *intern;
    3592             :         zend_class_entry *ce;
    3593             : 
    3594           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3595           0 :                 return;
    3596             :         }
    3597           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3598           0 :         if (ce->type == ZEND_USER_CLASS) {
    3599           0 :                 RETURN_STRING(ce->info.user.filename, 1);
    3600             :         }
    3601           0 :         RETURN_FALSE;
    3602             : }
    3603             : /* }}} */
    3604             : 
    3605             : /* {{{ proto public int ReflectionClass::getStartLine()
    3606             :    Returns the line this class' declaration starts at */
    3607           0 : ZEND_METHOD(reflection_class, getStartLine)
    3608             : {
    3609             :         reflection_object *intern;
    3610             :         zend_class_entry *ce;
    3611             : 
    3612           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3613           0 :                 return;
    3614             :         }
    3615           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3616           0 :         if (ce->type == ZEND_USER_FUNCTION) {
    3617           0 :                 RETURN_LONG(ce->info.user.line_start);
    3618             :         }
    3619           0 :         RETURN_FALSE;
    3620             : }
    3621             : /* }}} */
    3622             : 
    3623             : /* {{{ proto public int ReflectionClass::getEndLine()
    3624             :    Returns the line this class' declaration ends at */
    3625           0 : ZEND_METHOD(reflection_class, getEndLine)
    3626             : {
    3627             :         reflection_object *intern;
    3628             :         zend_class_entry *ce;
    3629             : 
    3630           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3631           0 :                 return;
    3632             :         }
    3633           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3634           0 :         if (ce->type == ZEND_USER_CLASS) {
    3635           0 :                 RETURN_LONG(ce->info.user.line_end);
    3636             :         }
    3637           0 :         RETURN_FALSE;
    3638             : }
    3639             : /* }}} */
    3640             : 
    3641             : /* {{{ proto public string ReflectionClass::getDocComment()
    3642             :    Returns the doc comment for this class */
    3643           0 : ZEND_METHOD(reflection_class, getDocComment)
    3644             : {
    3645             :         reflection_object *intern;
    3646             :         zend_class_entry *ce;
    3647             : 
    3648           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3649           0 :                 return;
    3650             :         }
    3651           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3652           0 :         if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) {
    3653           0 :                 RETURN_STRINGL(ce->info.user.doc_comment, ce->info.user.doc_comment_len, 1);
    3654             :         }
    3655           0 :         RETURN_FALSE;
    3656             : }
    3657             : /* }}} */
    3658             : 
    3659             : /* {{{ proto public ReflectionMethod ReflectionClass::getConstructor()
    3660             :    Returns the class' constructor if there is one, NULL otherwise */
    3661           0 : ZEND_METHOD(reflection_class, getConstructor)
    3662             : {
    3663             :         reflection_object *intern;
    3664             :         zend_class_entry *ce;
    3665             : 
    3666           0 :         if (zend_parse_parameters_none() == FAILURE) {
    3667           0 :                 return;
    3668             :         }
    3669           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3670             : 
    3671           0 :         if (ce->constructor) {
    3672           0 :                 reflection_method_factory(ce, ce->constructor, NULL, return_value TSRMLS_CC);
    3673             :         } else {
    3674           0 :                 RETURN_NULL();
    3675             :         }
    3676             : }
    3677             : /* }}} */
    3678             : 
    3679             : /* {{{ proto public bool ReflectionClass::hasMethod(string name)
    3680             :    Returns whether a method exists or not */
    3681           0 : ZEND_METHOD(reflection_class, hasMethod)
    3682             : {
    3683             :         reflection_object *intern;
    3684             :         zend_class_entry *ce;
    3685             :         char *name, *lc_name;
    3686             :         int name_len;
    3687             : 
    3688           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    3689           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
    3690           0 :                 return;
    3691             :         }
    3692             : 
    3693           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3694           0 :         lc_name = zend_str_tolower_dup(name, name_len);
    3695           0 :         if ((ce == zend_ce_closure && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
    3696           0 :                 && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0)
    3697           0 :                 || zend_hash_exists(&ce->function_table, lc_name, name_len + 1)) {
    3698           0 :                 efree(lc_name);
    3699           0 :                 RETURN_TRUE;
    3700             :         } else {
    3701           0 :                 efree(lc_name);
    3702           0 :                 RETURN_FALSE;
    3703             :         }
    3704             : }
    3705             : /* }}} */
    3706             : 
    3707             : /* {{{ proto public ReflectionMethod ReflectionClass::getMethod(string name) throws ReflectionException
    3708             :    Returns the class' method specified by its name */
    3709           0 : ZEND_METHOD(reflection_class, getMethod)
    3710             : {
    3711             :         reflection_object *intern;
    3712             :         zend_class_entry *ce;
    3713             :         zend_function *mptr;
    3714             :         zval obj_tmp;
    3715             :         char *name, *lc_name;
    3716             :         int name_len;
    3717             : 
    3718           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    3719           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
    3720           0 :                 return;
    3721             :         }
    3722             : 
    3723           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3724           0 :         lc_name = zend_str_tolower_dup(name, name_len);
    3725           0 :         if (ce == zend_ce_closure && intern->obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
    3726             :                 && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
    3727           0 :                 && (mptr = zend_get_closure_invoke_method(intern->obj TSRMLS_CC)) != NULL)
    3728             :         {
    3729             :                 /* don't assign closure_object since we only reflect the invoke handler
    3730             :                    method and not the closure definition itself */
    3731           0 :                 reflection_method_factory(ce, mptr, NULL, return_value TSRMLS_CC);
    3732           0 :                 efree(lc_name);
    3733           0 :         } else if (ce == zend_ce_closure && !intern->obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
    3734             :                 && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
    3735           0 :                 && object_init_ex(&obj_tmp, ce) == SUCCESS && (mptr = zend_get_closure_invoke_method(&obj_tmp TSRMLS_CC)) != NULL) {
    3736             :                 /* don't assign closure_object since we only reflect the invoke handler
    3737             :                    method and not the closure definition itself */
    3738           0 :                 reflection_method_factory(ce, mptr, NULL, return_value TSRMLS_CC);
    3739             :                 zval_dtor(&obj_tmp);
    3740           0 :                 efree(lc_name);
    3741           0 :         } else if (zend_hash_find(&ce->function_table, lc_name, name_len + 1, (void**) &mptr) == SUCCESS) {
    3742           0 :                 reflection_method_factory(ce, mptr, NULL, return_value TSRMLS_CC);
    3743           0 :                 efree(lc_name);
    3744             :         } else {
    3745           0 :                 efree(lc_name);
    3746           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    3747             :                                 "Method %s does not exist", name);
    3748           0 :                 return;
    3749             :         }
    3750             : }
    3751             : /* }}} */
    3752             : 
    3753             : /* {{{ _addmethod */
    3754           0 : static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, long filter, zval *obj TSRMLS_DC)
    3755             : {
    3756             :         zval *method;
    3757           0 :         uint len = strlen(mptr->common.function_name);
    3758             :         zend_function *closure;
    3759             : 
    3760           0 :         if (mptr->common.fn_flags & filter) {
    3761           0 :                 ALLOC_ZVAL(method);
    3762           0 :                 if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
    3763           0 :                         && memcmp(mptr->common.function_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
    3764           0 :                         && (closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL)
    3765             :                 {
    3766           0 :                         mptr = closure;
    3767             :                 }
    3768             :                 /* don't assign closure_object since we only reflect the invoke handler
    3769             :                    method and not the closure definition itself, even if we have a
    3770             :                    closure */
    3771           0 :                 reflection_method_factory(ce, mptr, NULL, method TSRMLS_CC);
    3772           0 :                 add_next_index_zval(retval, method);
    3773             :         }
    3774           0 : }
    3775             : /* }}} */
    3776             : 
    3777             : /* {{{ _addmethod */
    3778           0 : static int _addmethod_va(zend_function *mptr TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
    3779             : {
    3780           0 :         zend_class_entry *ce = *va_arg(args, zend_class_entry**);
    3781           0 :         zval *retval = va_arg(args, zval*);
    3782           0 :         long filter = va_arg(args, long);
    3783           0 :         zval *obj = va_arg(args, zval *);
    3784             : 
    3785           0 :         _addmethod(mptr, ce, retval, filter, obj TSRMLS_CC);
    3786           0 :         return ZEND_HASH_APPLY_KEEP;
    3787             : }
    3788             : /* }}} */
    3789             : 
    3790             : /* {{{ proto public ReflectionMethod[] ReflectionClass::getMethods([long $filter])
    3791             :    Returns an array of this class' methods */
    3792           0 : ZEND_METHOD(reflection_class, getMethods)
    3793             : {
    3794             :         reflection_object *intern;
    3795             :         zend_class_entry *ce;
    3796           0 :         long filter = 0;
    3797           0 :         int argc = ZEND_NUM_ARGS();
    3798             : 
    3799           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    3800           0 :         if (argc) {
    3801           0 :                 if (zend_parse_parameters(argc TSRMLS_CC, "|l", &filter) == FAILURE) {
    3802           0 :                         return;
    3803             :                 }
    3804             :         } else {
    3805             :                 /* No parameters given, default to "return all" */
    3806           0 :                 filter = ZEND_ACC_PPP_MASK | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL | ZEND_ACC_STATIC;
    3807             :         }
    3808             : 
    3809           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3810             : 
    3811           0 :         array_init(return_value);
    3812           0 :         zend_hash_apply_with_arguments(&ce->function_table TSRMLS_CC, (apply_func_args_t) _addmethod_va, 4, &ce, return_value, filter, intern->obj);
    3813           0 :         if (intern->obj && instanceof_function(ce, zend_ce_closure TSRMLS_CC)) {
    3814           0 :                 zend_function *closure = zend_get_closure_invoke_method(intern->obj TSRMLS_CC);
    3815           0 :                 if (closure) {
    3816           0 :                         _addmethod(closure, ce, return_value, filter, intern->obj TSRMLS_CC);
    3817           0 :                         _free_function(closure TSRMLS_CC);
    3818             :                 }
    3819             :         }
    3820             : }
    3821             : /* }}} */
    3822             : 
    3823             : /* {{{ proto public bool ReflectionClass::hasProperty(string name)
    3824             :    Returns whether a property exists or not */
    3825           0 : ZEND_METHOD(reflection_class, hasProperty)
    3826             : {
    3827             :         reflection_object *intern;
    3828             :         zend_property_info *property_info;
    3829             :         zend_class_entry *ce;
    3830             :         char *name;
    3831             :         int name_len;
    3832             :         zval *property;
    3833             : 
    3834           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    3835           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
    3836           0 :                 return;
    3837             :         }
    3838             : 
    3839           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3840           0 :         if (zend_hash_find(&ce->properties_info, name, name_len+1, (void **) &property_info) == SUCCESS) {
    3841           0 :                 if (property_info->flags & ZEND_ACC_SHADOW) {
    3842           0 :                         RETURN_FALSE;
    3843             :                 }
    3844           0 :                 RETURN_TRUE;
    3845             :         } else {
    3846           0 :                 if (intern->obj && Z_OBJ_HANDLER_P(intern->obj, has_property)) {
    3847           0 :                         MAKE_STD_ZVAL(property);
    3848           0 :                         ZVAL_STRINGL(property, name, name_len, 1);
    3849           0 :                         if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 2, 0 TSRMLS_CC)) {
    3850           0 :                                 zval_ptr_dtor(&property);
    3851           0 :                                 RETURN_TRUE;
    3852             :                         }
    3853           0 :                         zval_ptr_dtor(&property);
    3854             :                 }
    3855           0 :                 RETURN_FALSE;
    3856             :         }
    3857             : }
    3858             : /* }}} */
    3859             : 
    3860             : /* {{{ proto public ReflectionProperty ReflectionClass::getProperty(string name) throws ReflectionException
    3861             :    Returns the class' property specified by its name */
    3862           0 : ZEND_METHOD(reflection_class, getProperty)
    3863             : {
    3864             :         reflection_object *intern;
    3865             :         zend_class_entry *ce, **pce;
    3866             :         zend_property_info *property_info;
    3867             :         char *name, *tmp, *classname;
    3868             :         int name_len, classname_len;
    3869             : 
    3870           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    3871           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
    3872           0 :                 return;
    3873             :         }
    3874             : 
    3875           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    3876           0 :         if (zend_hash_find(&ce->properties_info, name, name_len + 1, (void**) &property_info) == SUCCESS) {
    3877           0 :                 if ((property_info->flags & ZEND_ACC_SHADOW) == 0) {
    3878           0 :                         reflection_property_factory(ce, property_info, return_value TSRMLS_CC);
    3879           0 :                         return;
    3880             :                 }
    3881           0 :         } else if (intern->obj) {
    3882             :                 /* Check for dynamic properties */
    3883           0 :                 if (zend_hash_exists(Z_OBJ_HT_P(intern->obj)->get_properties(intern->obj TSRMLS_CC), name, name_len+1)) {
    3884             :                         zend_property_info property_info_tmp;
    3885           0 :                         property_info_tmp.flags = ZEND_ACC_IMPLICIT_PUBLIC;
    3886           0 :                         property_info_tmp.name = estrndup(name, name_len);
    3887           0 :                         property_info_tmp.name_length = name_len;
    3888           0 :                         property_info_tmp.h = zend_get_hash_value(name, name_len+1);
    3889           0 :                         property_info_tmp.doc_comment = NULL;
    3890           0 :                         property_info_tmp.ce = ce;
    3891             : 
    3892           0 :                         reflection_property_factory(ce, &property_info_tmp, return_value TSRMLS_CC);
    3893           0 :                         intern = (reflection_object *) zend_object_store_get_object(return_value TSRMLS_CC);
    3894           0 :                         intern->ref_type = REF_TYPE_DYNAMIC_PROPERTY;
    3895           0 :                         return;
    3896             :                 }
    3897             :         }
    3898           0 :         if ((tmp = strstr(name, "::")) != NULL) {
    3899           0 :                 classname_len = tmp - name;
    3900           0 :                 classname = zend_str_tolower_dup(name, classname_len);
    3901           0 :                 classname[classname_len] = '\0';
    3902           0 :                 name_len = name_len - (classname_len + 2);
    3903           0 :                 name = tmp + 2;
    3904             : 
    3905           0 :                 if (zend_lookup_class(classname, classname_len, &pce TSRMLS_CC) == FAILURE) {
    3906           0 :                         if (!EG(exception)) {
    3907           0 :                                 zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", classname);
    3908             :                         }
    3909           0 :                         efree(classname);
    3910           0 :                         return;
    3911             :                 }
    3912           0 :                 efree(classname);
    3913             : 
    3914           0 :                 if (!instanceof_function(ce, *pce TSRMLS_CC)) {
    3915           0 :                         zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Fully qualified property name %s::%s does not specify a base class of %s", (*pce)->name, name, ce->name);
    3916           0 :                         return;
    3917             :                 }
    3918           0 :                 ce = *pce;
    3919             : 
    3920           0 :                 if (zend_hash_find(&ce->properties_info, name, name_len + 1, (void**) &property_info) == SUCCESS && (property_info->flags & ZEND_ACC_SHADOW) == 0) {
    3921           0 :                         reflection_property_factory(ce, property_info, return_value TSRMLS_CC);
    3922           0 :                         return;
    3923             :                 }
    3924             :         }
    3925           0 :         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    3926             :                         "Property %s does not exist", name);
    3927             : }
    3928             : /* }}} */
    3929             : 
    3930             : /* {{{ _addproperty */
    3931           0 : static int _addproperty(zend_property_info *pptr TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
    3932             : {
    3933             :         zval *property;
    3934           0 :         zend_class_entry *ce = *va_arg(args, zend_class_entry**);
    3935           0 :         zval *retval = va_arg(args, zval*);
    3936           0 :         long filter = va_arg(args, long);
    3937             : 
    3938           0 :         if (pptr->flags      & ZEND_ACC_SHADOW) {
    3939           0 :                 return 0;
    3940             :         }
    3941             : 
    3942           0 :         if (pptr->flags      & filter) {
    3943           0 :                 ALLOC_ZVAL(property);
    3944           0 :                 reflection_property_factory(ce, pptr, property TSRMLS_CC);
    3945           0 :                 add_next_index_zval(retval, property);
    3946             :         }
    3947           0 :         return 0;
    3948             : }
    3949             : /* }}} */
    3950             : 
    3951             : /* {{{ _adddynproperty */
    3952           0 : static int _adddynproperty(zval **pptr TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
    3953             : {
    3954             :         zval *property;
    3955           0 :         zend_class_entry *ce = *va_arg(args, zend_class_entry**);
    3956           0 :         zval *retval = va_arg(args, zval*), member;
    3957             : 
    3958             :         /* under some circumstances, the properties hash table may contain numeric
    3959             :          * properties (e.g. when casting from array). This is a WONT FIX bug, at
    3960             :          * least for the moment. Ignore these */
    3961           0 :         if (hash_key->nKeyLength == 0) {
    3962           0 :                 return 0;
    3963             :         }
    3964             : 
    3965           0 :         if (hash_key->arKey[0] == '\0') {
    3966           0 :                 return 0; /* non public cannot be dynamic */
    3967             :         }
    3968             : 
    3969           0 :         ZVAL_STRINGL(&member, hash_key->arKey, hash_key->nKeyLength-1, 0);
    3970           0 :         if (zend_get_property_info(ce, &member, 1 TSRMLS_CC) == &EG(std_property_info)) {
    3971           0 :                 MAKE_STD_ZVAL(property);
    3972           0 :                 EG(std_property_info).flags = ZEND_ACC_IMPLICIT_PUBLIC;
    3973           0 :                 reflection_property_factory(ce, &EG(std_property_info), property TSRMLS_CC);
    3974           0 :                 add_next_index_zval(retval, property);
    3975             :         }
    3976           0 :         return 0;
    3977             : }
    3978             : /* }}} */
    3979             : 
    3980             : /* {{{ proto public ReflectionProperty[] ReflectionClass::getProperties([long $filter])
    3981             :    Returns an array of this class' properties */
    3982           0 : ZEND_METHOD(reflection_class, getProperties)
    3983             : {
    3984             :         reflection_object *intern;
    3985             :         zend_class_entry *ce;
    3986           0 :         long filter = 0;
    3987           0 :         int argc = ZEND_NUM_ARGS();
    3988             : 
    3989           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    3990           0 :         if (argc) {
    3991           0 :                 if (zend_parse_parameters(argc TSRMLS_CC, "|l", &filter) == FAILURE) {
    3992           0 :                         return;
    3993             :                 }
    3994             :         } else {
    3995             :                 /* No parameters given, default to "return all" */
    3996           0 :                 filter = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC;
    3997             :         }
    3998             : 
    3999           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4000             : 
    4001           0 :         array_init(return_value);
    4002           0 :         zend_hash_apply_with_arguments(&ce->properties_info TSRMLS_CC, (apply_func_args_t) _addproperty, 3, &ce, return_value, filter);
    4003             : 
    4004           0 :         if (intern->obj && (filter & ZEND_ACC_PUBLIC) != 0 && Z_OBJ_HT_P(intern->obj)->get_properties) {
    4005           0 :                 HashTable *properties = Z_OBJ_HT_P(intern->obj)->get_properties(intern->obj TSRMLS_CC);
    4006           0 :                 zend_hash_apply_with_arguments(properties TSRMLS_CC, (apply_func_args_t) _adddynproperty, 2, &ce, return_value);
    4007             :         }
    4008             : }
    4009             : /* }}} */
    4010             : 
    4011             : /* {{{ proto public bool ReflectionClass::hasConstant(string name)
    4012             :    Returns whether a constant exists or not */
    4013           0 : ZEND_METHOD(reflection_class, hasConstant)
    4014             : {
    4015             :         reflection_object *intern;
    4016             :         zend_class_entry *ce;
    4017             :         char *name;
    4018             :         int name_len;
    4019             : 
    4020           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4021           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
    4022           0 :                 return;
    4023             :         }
    4024             : 
    4025           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4026           0 :         if (zend_hash_exists(&ce->constants_table, name, name_len + 1)) {
    4027           0 :                 RETURN_TRUE;
    4028             :         } else {
    4029           0 :                 RETURN_FALSE;
    4030             :         }
    4031             : }
    4032             : /* }}} */
    4033             : 
    4034             : /* {{{ proto public array ReflectionClass::getConstants()
    4035             :    Returns an associative array containing this class' constants and their values */
    4036           0 : ZEND_METHOD(reflection_class, getConstants)
    4037             : {
    4038             :         zval *tmp_copy;
    4039             :         reflection_object *intern;
    4040             :         zend_class_entry *ce;
    4041             : 
    4042           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4043           0 :                 return;
    4044             :         }
    4045           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4046           0 :         array_init(return_value);
    4047           0 :         zend_hash_apply_with_argument(&ce->constants_table, (apply_func_arg_t)zval_update_constant_inline_change, ce TSRMLS_CC);
    4048           0 :         zend_hash_copy(Z_ARRVAL_P(return_value), &ce->constants_table, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *));
    4049             : }
    4050             : /* }}} */
    4051             : 
    4052             : /* {{{ proto public mixed ReflectionClass::getConstant(string name)
    4053             :    Returns the class' constant specified by its name */
    4054           0 : ZEND_METHOD(reflection_class, getConstant)
    4055             : {
    4056             :         reflection_object *intern;
    4057             :         zend_class_entry *ce;
    4058             :         zval **value;
    4059             :         char *name;
    4060             :         int name_len;
    4061             : 
    4062           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4063           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
    4064           0 :                 return;
    4065             :         }
    4066             : 
    4067           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4068           0 :         zend_hash_apply_with_argument(&ce->constants_table, (apply_func_arg_t)zval_update_constant_inline_change, ce TSRMLS_CC);
    4069           0 :         if (zend_hash_find(&ce->constants_table, name, name_len + 1, (void **) &value) == FAILURE) {
    4070           0 :                 RETURN_FALSE;
    4071             :         }
    4072           0 :         MAKE_COPY_ZVAL(value, return_value);
    4073             : }
    4074             : /* }}} */
    4075             : 
    4076             : /* {{{ _class_check_flag */
    4077           0 : static void _class_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask)
    4078             : {
    4079             :         reflection_object *intern;
    4080             :         zend_class_entry *ce;
    4081             : 
    4082           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4083           0 :                 return;
    4084             :         }
    4085           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4086           0 :         RETVAL_BOOL(ce->ce_flags & mask);
    4087             : }
    4088             : /* }}} */
    4089             : 
    4090             : /* {{{ proto public bool ReflectionClass::isInstantiable()
    4091             :    Returns whether this class is instantiable */
    4092           0 : ZEND_METHOD(reflection_class, isInstantiable)
    4093             : {
    4094             :         reflection_object *intern;
    4095             :         zend_class_entry *ce;
    4096             : 
    4097           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4098           0 :                 return;
    4099             :         }
    4100           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4101           0 :         if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) {
    4102           0 :                 RETURN_FALSE;
    4103             :         }
    4104             : 
    4105             :         /* Basically, the class is instantiable. Though, if there is a constructor
    4106             :          * and it is not publicly accessible, it isn't! */
    4107           0 :         if (!ce->constructor) {
    4108           0 :                 RETURN_TRUE;
    4109             :         }
    4110             : 
    4111           0 :         RETURN_BOOL(ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC);
    4112             : }
    4113             : /* }}} */
    4114             : 
    4115             : /* {{{ proto public bool ReflectionClass::isCloneable()
    4116             :    Returns whether this class is cloneable */
    4117           0 : ZEND_METHOD(reflection_class, isCloneable)
    4118             : {
    4119             :         reflection_object *intern;
    4120             :         zend_class_entry *ce;
    4121             :         zval obj;
    4122             : 
    4123           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4124           0 :                 return;
    4125             :         }
    4126           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4127           0 :         if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) {
    4128           0 :                 RETURN_FALSE;
    4129             :         }
    4130           0 :         if (intern->obj) {
    4131           0 :                 if (ce->clone) {
    4132           0 :                         RETURN_BOOL(ce->clone->common.fn_flags & ZEND_ACC_PUBLIC);
    4133             :                 } else {
    4134           0 :                         RETURN_BOOL(Z_OBJ_HANDLER_P(intern->obj, clone_obj) != NULL);
    4135             :                 }
    4136             :         } else {
    4137           0 :                 if (ce->clone) {
    4138           0 :                         RETURN_BOOL(ce->clone->common.fn_flags & ZEND_ACC_PUBLIC);
    4139             :                 } else {
    4140           0 :                         object_init_ex(&obj, ce);
    4141           0 :                         RETVAL_BOOL(Z_OBJ_HANDLER(obj, clone_obj) != NULL);
    4142             :                         zval_dtor(&obj);
    4143             :                 }
    4144             :         }
    4145             : }
    4146             : /* }}} */
    4147             : 
    4148             : /* {{{ proto public bool ReflectionClass::isInterface()
    4149             :    Returns whether this is an interface or a class */
    4150           0 : ZEND_METHOD(reflection_class, isInterface)
    4151             : {
    4152           0 :         _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_INTERFACE);
    4153           0 : }
    4154             : /* }}} */
    4155             : 
    4156             : /* {{{ proto public bool ReflectionClass::isTrait()
    4157             :    Returns whether this is a trait */
    4158           0 : ZEND_METHOD(reflection_class, isTrait)
    4159             : {
    4160           0 :         _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT & ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
    4161           0 : }
    4162             : /* }}} */
    4163             : 
    4164             : /* {{{ proto public bool ReflectionClass::isFinal()
    4165             :    Returns whether this class is final */
    4166           0 : ZEND_METHOD(reflection_class, isFinal)
    4167             : {
    4168           0 :         _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_FINAL_CLASS);
    4169           0 : }
    4170             : /* }}} */
    4171             : 
    4172             : /* {{{ proto public bool ReflectionClass::isAbstract()
    4173             :    Returns whether this class is abstract */
    4174           0 : ZEND_METHOD(reflection_class, isAbstract)
    4175             : {
    4176           0 :         _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
    4177           0 : }
    4178             : /* }}} */
    4179             : 
    4180             : /* {{{ proto public int ReflectionClass::getModifiers()
    4181             :    Returns a bitfield of the access modifiers for this class */
    4182           0 : ZEND_METHOD(reflection_class, getModifiers)
    4183             : {
    4184             :         reflection_object *intern;
    4185             :         zend_class_entry *ce;
    4186             : 
    4187           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4188           0 :                 return;
    4189             :         }
    4190           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4191             : 
    4192           0 :         RETURN_LONG(ce->ce_flags);
    4193             : }
    4194             : /* }}} */
    4195             : 
    4196             : /* {{{ proto public bool ReflectionClass::isInstance(stdclass object)
    4197             :    Returns whether the given object is an instance of this class */
    4198           0 : ZEND_METHOD(reflection_class, isInstance)
    4199             : {
    4200             :         reflection_object *intern;
    4201             :         zend_class_entry *ce;
    4202             :         zval *object;
    4203             : 
    4204           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4205           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) {
    4206           0 :                 return;
    4207             :         }
    4208           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4209           0 :         RETURN_BOOL(HAS_CLASS_ENTRY(*object) && instanceof_function(Z_OBJCE_P(object), ce TSRMLS_CC));
    4210             : }
    4211             : /* }}} */
    4212             : 
    4213             : /* {{{ proto public stdclass ReflectionClass::newInstance(mixed* args, ...)
    4214             :    Returns an instance of this class */
    4215           0 : ZEND_METHOD(reflection_class, newInstance)
    4216             : {
    4217           0 :         zval *retval_ptr = NULL;
    4218             :         reflection_object *intern;
    4219             :         zend_class_entry *ce, *old_scope;
    4220             :         zend_function *constructor;
    4221             : 
    4222           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4223           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4224             : 
    4225           0 :         object_init_ex(return_value, ce);
    4226             : 
    4227           0 :         old_scope = EG(scope);
    4228           0 :         EG(scope) = ce;
    4229           0 :         constructor = Z_OBJ_HT_P(return_value)->get_constructor(return_value TSRMLS_CC);
    4230           0 :         EG(scope) = old_scope;
    4231             : 
    4232             :         /* Run the constructor if there is one */
    4233           0 :         if (constructor) {
    4234           0 :                 zval ***params = NULL;
    4235           0 :                 int num_args = 0;
    4236             :                 zend_fcall_info fci;
    4237             :                 zend_fcall_info_cache fcc;
    4238             : 
    4239           0 :                 if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
    4240           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name);
    4241             :                         zval_dtor(return_value);
    4242           0 :                         RETURN_NULL();
    4243             :                 }
    4244             : 
    4245           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "*", &params, &num_args) == FAILURE) {
    4246           0 :                         if (params) {
    4247           0 :                                 efree(params);
    4248             :                         }
    4249             :                         zval_dtor(return_value);
    4250           0 :                         RETURN_FALSE;
    4251             :                 }
    4252             : 
    4253           0 :                 fci.size = sizeof(fci);
    4254           0 :                 fci.function_table = EG(function_table);
    4255           0 :                 fci.function_name = NULL;
    4256           0 :                 fci.symbol_table = NULL;
    4257           0 :                 fci.object_ptr = return_value;
    4258           0 :                 fci.retval_ptr_ptr = &retval_ptr;
    4259           0 :                 fci.param_count = num_args;
    4260           0 :                 fci.params = params;
    4261           0 :                 fci.no_separation = 1;
    4262             : 
    4263           0 :                 fcc.initialized = 1;
    4264           0 :                 fcc.function_handler = constructor;
    4265           0 :                 fcc.calling_scope = EG(scope);
    4266           0 :                 fcc.called_scope = Z_OBJCE_P(return_value);
    4267           0 :                 fcc.object_ptr = return_value;
    4268             : 
    4269           0 :                 if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
    4270           0 :                         if (params) {
    4271           0 :                                 efree(params);
    4272             :                         }
    4273           0 :                         if (retval_ptr) {
    4274           0 :                                 zval_ptr_dtor(&retval_ptr);
    4275             :                         }
    4276           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invocation of %s's constructor failed", ce->name);
    4277             :                         zval_dtor(return_value);
    4278           0 :                         RETURN_NULL();
    4279             :                 }
    4280           0 :                 if (retval_ptr) {
    4281           0 :                         zval_ptr_dtor(&retval_ptr);
    4282             :                 }
    4283           0 :                 if (params) {
    4284           0 :                         efree(params);
    4285             :                 }
    4286           0 :         } else if (ZEND_NUM_ARGS()) {
    4287           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name);
    4288             :         }
    4289             : }
    4290             : /* }}} */
    4291             : 
    4292             : /* {{{ proto public stdclass ReflectionClass::newInstanceWithoutConstructor()
    4293             :    Returns an instance of this class without invoking its constructor */
    4294           0 : ZEND_METHOD(reflection_class, newInstanceWithoutConstructor)
    4295             : {
    4296             :         reflection_object *intern;
    4297             :         zend_class_entry *ce;
    4298             : 
    4299           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4300           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4301             : 
    4302           0 :         if (ce->create_object != NULL) {
    4303           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class that cannot be instantiated without invoking its constructor", ce->name);
    4304             :         }
    4305             : 
    4306           0 :         object_init_ex(return_value, ce);
    4307             : }
    4308             : /* }}} */
    4309             : 
    4310             : /* {{{ proto public stdclass ReflectionClass::newInstanceArgs([array args])
    4311             :    Returns an instance of this class */
    4312           0 : ZEND_METHOD(reflection_class, newInstanceArgs)
    4313             : {
    4314           0 :         zval *retval_ptr = NULL;
    4315             :         reflection_object *intern;
    4316             :         zend_class_entry *ce, *old_scope;
    4317           0 :         int argc = 0;
    4318             :         HashTable *args;
    4319             :         zend_function *constructor;
    4320             : 
    4321             : 
    4322           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4323           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4324             : 
    4325           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|h", &args) == FAILURE) {
    4326           0 :                 return;
    4327             :         }
    4328             : 
    4329           0 :         if (ZEND_NUM_ARGS() > 0) {
    4330           0 :                 argc = args->nNumOfElements;
    4331             :         }
    4332             : 
    4333           0 :         object_init_ex(return_value, ce);
    4334             : 
    4335           0 :         old_scope = EG(scope);
    4336           0 :         EG(scope) = ce;
    4337           0 :         constructor = Z_OBJ_HT_P(return_value)->get_constructor(return_value TSRMLS_CC);
    4338           0 :         EG(scope) = old_scope;
    4339             : 
    4340             :         /* Run the constructor if there is one */
    4341           0 :         if (constructor) {
    4342           0 :                 zval ***params = NULL;
    4343             :                 zend_fcall_info fci;
    4344             :                 zend_fcall_info_cache fcc;
    4345             : 
    4346           0 :                 if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
    4347           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name);
    4348             :                         zval_dtor(return_value);
    4349           0 :                         RETURN_NULL();
    4350             :                 }
    4351             : 
    4352           0 :                 if (argc) {
    4353           0 :                         params = safe_emalloc(sizeof(zval **), argc, 0);
    4354           0 :                         zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, &params TSRMLS_CC);
    4355           0 :                         params -= argc;
    4356             :                 }
    4357             : 
    4358           0 :                 fci.size = sizeof(fci);
    4359           0 :                 fci.function_table = EG(function_table);
    4360           0 :                 fci.function_name = NULL;
    4361           0 :                 fci.symbol_table = NULL;
    4362           0 :                 fci.object_ptr = return_value;
    4363           0 :                 fci.retval_ptr_ptr = &retval_ptr;
    4364           0 :                 fci.param_count = argc;
    4365           0 :                 fci.params = params;
    4366           0 :                 fci.no_separation = 1;
    4367             : 
    4368           0 :                 fcc.initialized = 1;
    4369           0 :                 fcc.function_handler = constructor;
    4370           0 :                 fcc.calling_scope = EG(scope);
    4371           0 :                 fcc.called_scope = Z_OBJCE_P(return_value);
    4372           0 :                 fcc.object_ptr = return_value;
    4373             : 
    4374           0 :                 if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
    4375           0 :                         if (params) {
    4376           0 :                                 efree(params);
    4377             :                         }
    4378           0 :                         if (retval_ptr) {
    4379           0 :                                 zval_ptr_dtor(&retval_ptr);
    4380             :                         }
    4381           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invocation of %s's constructor failed", ce->name);
    4382             :                         zval_dtor(return_value);
    4383           0 :                         RETURN_NULL();
    4384             :                 }
    4385           0 :                 if (retval_ptr) {
    4386           0 :                         zval_ptr_dtor(&retval_ptr);
    4387             :                 }
    4388           0 :                 if (params) {
    4389           0 :                         efree(params);
    4390             :                 }
    4391           0 :         } else if (argc) {
    4392           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name);
    4393             :         }
    4394             : }
    4395             : /* }}} */
    4396             : 
    4397             : /* {{{ proto public ReflectionClass[] ReflectionClass::getInterfaces()
    4398             :    Returns an array of interfaces this class implements */
    4399           0 : ZEND_METHOD(reflection_class, getInterfaces)
    4400             : {
    4401             :         reflection_object *intern;
    4402             :         zend_class_entry *ce;
    4403             : 
    4404           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4405           0 :                 return;
    4406             :         }
    4407           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4408             : 
    4409             :         /* Return an empty array if this class implements no interfaces */
    4410           0 :         array_init(return_value);
    4411             : 
    4412           0 :         if (ce->num_interfaces) {
    4413             :                 zend_uint i;
    4414             : 
    4415           0 :                 for (i=0; i < ce->num_interfaces; i++) {
    4416             :                         zval *interface;
    4417           0 :                         ALLOC_ZVAL(interface);
    4418           0 :                         zend_reflection_class_factory(ce->interfaces[i], interface TSRMLS_CC);
    4419           0 :                         add_assoc_zval_ex(return_value, ce->interfaces[i]->name, ce->interfaces[i]->name_length + 1, interface);
    4420             :                 }
    4421             :         }
    4422             : }
    4423             : /* }}} */
    4424             : 
    4425             : /* {{{ proto public String[] ReflectionClass::getInterfaceNames()
    4426             :    Returns an array of names of interfaces this class implements */
    4427           0 : ZEND_METHOD(reflection_class, getInterfaceNames)
    4428             : {
    4429             :         reflection_object *intern;
    4430             :         zend_class_entry *ce;
    4431             :         zend_uint i;
    4432             : 
    4433           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4434           0 :                 return;
    4435             :         }
    4436           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4437             : 
    4438             :         /* Return an empty array if this class implements no interfaces */
    4439           0 :         array_init(return_value);
    4440             : 
    4441           0 :         for (i=0; i < ce->num_interfaces; i++) {
    4442           0 :                 add_next_index_stringl(return_value, ce->interfaces[i]->name, ce->interfaces[i]->name_length, 1);
    4443             :         }
    4444             : }
    4445             : /* }}} */
    4446             : 
    4447             : /* {{{ proto public ReflectionClass[] ReflectionClass::getTraits()
    4448             :    Returns an array of traits used by this class */
    4449           0 : ZEND_METHOD(reflection_class, getTraits)
    4450             : {
    4451             :         reflection_object *intern;
    4452             :         zend_class_entry *ce;
    4453             :         zend_uint i;
    4454             : 
    4455           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4456           0 :                 return;
    4457             :         }
    4458           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4459             : 
    4460           0 :         array_init(return_value);
    4461             : 
    4462           0 :         for (i=0; i < ce->num_traits; i++) {
    4463             :                 zval *trait;
    4464           0 :                 ALLOC_ZVAL(trait);
    4465           0 :                 zend_reflection_class_factory(ce->traits[i], trait TSRMLS_CC);
    4466           0 :                 add_assoc_zval_ex(return_value, ce->traits[i]->name, ce->traits[i]->name_length + 1, trait);
    4467             :         }
    4468             : }
    4469             : /* }}} */
    4470             : 
    4471             : /* {{{ proto public String[] ReflectionClass::getTraitNames()
    4472             :    Returns an array of names of traits used by this class */
    4473           0 : ZEND_METHOD(reflection_class, getTraitNames)
    4474             : {
    4475             :         reflection_object *intern;
    4476             :         zend_class_entry *ce;
    4477             :         zend_uint i;
    4478             : 
    4479           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4480           0 :                 return;
    4481             :         }
    4482           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4483             : 
    4484           0 :         array_init(return_value);
    4485             : 
    4486           0 :         for (i=0; i < ce->num_traits; i++) {
    4487           0 :                 add_next_index_stringl(return_value, ce->traits[i]->name, ce->traits[i]->name_length, 1);
    4488             :         }
    4489             : }
    4490             : /* }}} */
    4491             : 
    4492             : /* {{{ proto public arra ReflectionClass::getTraitaliases()
    4493             :    Returns an array of trait aliases */
    4494           0 : ZEND_METHOD(reflection_class, getTraitAliases)
    4495             : {
    4496             :         reflection_object *intern;
    4497             :         zend_class_entry *ce;
    4498             : 
    4499           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4500           0 :                 return;
    4501             :         }
    4502           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4503             : 
    4504           0 :         array_init(return_value);
    4505             : 
    4506           0 :         if (ce->trait_aliases) {
    4507           0 :                 zend_uint i = 0;
    4508           0 :                 while (ce->trait_aliases[i]) {
    4509             :                         char *method_name;
    4510             :                         int method_name_len;
    4511           0 :                         zend_trait_method_reference *cur_ref = ce->trait_aliases[i]->trait_method;
    4512             : 
    4513           0 :                         if (ce->trait_aliases[i]->alias) {
    4514           0 :                                 method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->ce->name, cur_ref->method_name);
    4515           0 :                                 add_assoc_stringl_ex(return_value, ce->trait_aliases[i]->alias, ce->trait_aliases[i]->alias_len + 1, method_name, method_name_len, 0);
    4516             :                         }
    4517           0 :                         i++;
    4518             :                 }
    4519             :         }
    4520             : }
    4521             : /* }}} */
    4522             : 
    4523             : /* {{{ proto public ReflectionClass ReflectionClass::getParentClass()
    4524             :    Returns the class' parent class, or, if none exists, FALSE */
    4525           0 : ZEND_METHOD(reflection_class, getParentClass)
    4526             : {
    4527             :         reflection_object *intern;
    4528             :         zend_class_entry *ce;
    4529             : 
    4530           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4531           0 :                 return;
    4532             :         }
    4533           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4534             : 
    4535           0 :         if (ce->parent) {
    4536           0 :                 zend_reflection_class_factory(ce->parent, return_value TSRMLS_CC);
    4537             :         } else {
    4538           0 :                 RETURN_FALSE;
    4539             :         }
    4540             : }
    4541             : /* }}} */
    4542             : 
    4543             : /* {{{ proto public bool ReflectionClass::isSubclassOf(string|ReflectionClass class)
    4544             :    Returns whether this class is a subclass of another class */
    4545           0 : ZEND_METHOD(reflection_class, isSubclassOf)
    4546             : {
    4547             :         reflection_object *intern, *argument;
    4548             :         zend_class_entry *ce, **pce, *class_ce;
    4549             :         zval *class_name;
    4550             : 
    4551           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4552           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4553             : 
    4554           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &class_name) == FAILURE) {
    4555           0 :                 return;
    4556             :         }
    4557             : 
    4558           0 :         switch(class_name->type) {
    4559             :                 case IS_STRING:
    4560           0 :                         if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) {
    4561           0 :                                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    4562           0 :                                                 "Class %s does not exist", Z_STRVAL_P(class_name));
    4563           0 :                                 return;
    4564             :                         }
    4565           0 :                         class_ce = *pce;
    4566           0 :                         break;
    4567             :                 case IS_OBJECT:
    4568           0 :                         if (instanceof_function(Z_OBJCE_P(class_name), reflection_class_ptr TSRMLS_CC)) {
    4569           0 :                                 argument = (reflection_object *) zend_object_store_get_object(class_name TSRMLS_CC);
    4570           0 :                                 if (argument == NULL || argument->ptr == NULL) {
    4571           0 :                                         php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Failed to retrieve the argument's reflection object");
    4572             :                                         /* Bails out */
    4573             :                                 }
    4574           0 :                                 class_ce = argument->ptr;
    4575           0 :                                 break;
    4576             :                         }
    4577             :                         /* no break */
    4578             :                 default:
    4579           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    4580             :                                         "Parameter one must either be a string or a ReflectionClass object");
    4581           0 :                         return;
    4582             :         }
    4583             : 
    4584           0 :         RETURN_BOOL((ce != class_ce && instanceof_function(ce, class_ce TSRMLS_CC)));
    4585             : }
    4586             : /* }}} */
    4587             : 
    4588             : /* {{{ proto public bool ReflectionClass::implementsInterface(string|ReflectionClass interface_name)
    4589             :    Returns whether this class is a subclass of another class */
    4590           0 : ZEND_METHOD(reflection_class, implementsInterface)
    4591             : {
    4592             :         reflection_object *intern, *argument;
    4593             :         zend_class_entry *ce, *interface_ce, **pce;
    4594             :         zval *interface;
    4595             : 
    4596           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4597           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4598             : 
    4599           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &interface) == FAILURE) {
    4600           0 :                 return;
    4601             :         }
    4602             : 
    4603           0 :         switch(interface->type) {
    4604             :                 case IS_STRING:
    4605           0 :                         if (zend_lookup_class(Z_STRVAL_P(interface), Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) {
    4606           0 :                                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    4607           0 :                                                 "Interface %s does not exist", Z_STRVAL_P(interface));
    4608           0 :                                 return;
    4609             :                         }
    4610           0 :                         interface_ce = *pce;
    4611           0 :                         break;
    4612             :                 case IS_OBJECT:
    4613           0 :                         if (instanceof_function(Z_OBJCE_P(interface), reflection_class_ptr TSRMLS_CC)) {
    4614           0 :                                 argument = (reflection_object *) zend_object_store_get_object(interface TSRMLS_CC);
    4615           0 :                                 if (argument == NULL || argument->ptr == NULL) {
    4616           0 :                                         php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Failed to retrieve the argument's reflection object");
    4617             :                                         /* Bails out */
    4618             :                                 }
    4619           0 :                                 interface_ce = argument->ptr;
    4620           0 :                                 break;
    4621             :                         }
    4622             :                         /* no break */
    4623             :                 default:
    4624           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    4625             :                                         "Parameter one must either be a string or a ReflectionClass object");
    4626           0 :                         return;
    4627             :         }
    4628             : 
    4629           0 :         if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) {
    4630           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    4631             :                                 "Interface %s is a Class", interface_ce->name);
    4632           0 :                 return;
    4633             :         }
    4634           0 :         RETURN_BOOL(instanceof_function(ce, interface_ce TSRMLS_CC));
    4635             : }
    4636             : /* }}} */
    4637             : 
    4638             : /* {{{ proto public bool ReflectionClass::isIterateable()
    4639             :    Returns whether this class is iterateable (can be used inside foreach) */
    4640           0 : ZEND_METHOD(reflection_class, isIterateable)
    4641             : {
    4642             :         reflection_object *intern;
    4643             :         zend_class_entry *ce;
    4644             : 
    4645           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4646           0 :                 return;
    4647             :         }
    4648             : 
    4649           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4650           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4651             : 
    4652           0 :         RETURN_BOOL(ce->get_iterator != NULL);
    4653             : }
    4654             : /* }}} */
    4655             : 
    4656             : /* {{{ proto public ReflectionExtension|NULL ReflectionClass::getExtension()
    4657             :    Returns NULL or the extension the class belongs to */
    4658           0 : ZEND_METHOD(reflection_class, getExtension)
    4659             : {
    4660             :         reflection_object *intern;
    4661             :         zend_class_entry *ce;
    4662             : 
    4663           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4664           0 :                 return;
    4665             :         }
    4666             : 
    4667           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4668           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4669             : 
    4670           0 :         if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module) {
    4671           0 :                 reflection_extension_factory(return_value, ce->info.internal.module->name TSRMLS_CC);
    4672             :         }
    4673             : }
    4674             : /* }}} */
    4675             : 
    4676             : /* {{{ proto public string|false ReflectionClass::getExtensionName()
    4677             :    Returns false or the name of the extension the class belongs to */
    4678           0 : ZEND_METHOD(reflection_class, getExtensionName)
    4679             : {
    4680             :         reflection_object *intern;
    4681             :         zend_class_entry *ce;
    4682             : 
    4683           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4684           0 :                 return;
    4685             :         }
    4686             : 
    4687           0 :         METHOD_NOTSTATIC(reflection_class_ptr);
    4688           0 :         GET_REFLECTION_OBJECT_PTR(ce);
    4689             : 
    4690           0 :         if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module) {
    4691           0 :                 RETURN_STRING(ce->info.internal.module->name, 1);
    4692             :         } else {
    4693           0 :                 RETURN_FALSE;
    4694             :         }
    4695             : }
    4696             : /* }}} */
    4697             : 
    4698             : /* {{{ proto public bool ReflectionClass::inNamespace()
    4699             :    Returns whether this class is defined in namespace */
    4700           0 : ZEND_METHOD(reflection_class, inNamespace)
    4701             : {
    4702             :         zval **name;
    4703             :         const char *backslash;
    4704             : 
    4705           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4706           0 :                 return;
    4707             :         }
    4708           0 :         if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
    4709           0 :                 RETURN_FALSE;
    4710             :         }
    4711           0 :         if (Z_TYPE_PP(name) == IS_STRING
    4712           0 :                 && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
    4713           0 :                 && backslash > Z_STRVAL_PP(name))
    4714             :         {
    4715           0 :                 RETURN_TRUE;
    4716             :         }
    4717           0 :         RETURN_FALSE;
    4718             : }
    4719             : /* }}} */
    4720             : 
    4721             : /* {{{ proto public string ReflectionClass::getNamespaceName()
    4722             :    Returns the name of namespace where this class is defined */
    4723           0 : ZEND_METHOD(reflection_class, getNamespaceName)
    4724             : {
    4725             :         zval **name;
    4726             :         const char *backslash;
    4727             : 
    4728           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4729           0 :                 return;
    4730             :         }
    4731           0 :         if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
    4732           0 :                 RETURN_FALSE;
    4733             :         }
    4734           0 :         if (Z_TYPE_PP(name) == IS_STRING
    4735           0 :                 && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
    4736           0 :                 && backslash > Z_STRVAL_PP(name))
    4737             :         {
    4738           0 :                 RETURN_STRINGL(Z_STRVAL_PP(name), backslash - Z_STRVAL_PP(name), 1);
    4739             :         }
    4740           0 :         RETURN_EMPTY_STRING();
    4741             : }
    4742             : /* }}} */
    4743             : 
    4744             : /* {{{ proto public string ReflectionClass::getShortName()
    4745             :    Returns the short name of the class (without namespace part) */
    4746           0 : ZEND_METHOD(reflection_class, getShortName)
    4747             : {
    4748             :         zval **name;
    4749             :         const char *backslash;
    4750             : 
    4751           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4752           0 :                 return;
    4753             :         }
    4754           0 :         if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
    4755           0 :                 RETURN_FALSE;
    4756             :         }
    4757           0 :         if (Z_TYPE_PP(name) == IS_STRING
    4758           0 :                 && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
    4759           0 :                 && backslash > Z_STRVAL_PP(name))
    4760             :         {
    4761           0 :                 RETURN_STRINGL(backslash + 1, Z_STRLEN_PP(name) - (backslash - Z_STRVAL_PP(name) + 1), 1);
    4762             :         }
    4763           0 :         RETURN_ZVAL(*name, 1, 0);
    4764             : }
    4765             : /* }}} */
    4766             : 
    4767             : /* {{{ proto public static mixed ReflectionObject::export(mixed argument [, bool return]) throws ReflectionException
    4768             :    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
    4769           0 : ZEND_METHOD(reflection_object, export)
    4770             : {
    4771           0 :         _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_object_ptr, 1);
    4772           0 : }
    4773             : /* }}} */
    4774             : 
    4775             : /* {{{ proto public void ReflectionObject::__construct(mixed argument) throws ReflectionException
    4776             :    Constructor. Takes an instance as an argument */
    4777           0 : ZEND_METHOD(reflection_object, __construct)
    4778             : {
    4779           0 :         reflection_class_object_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
    4780           0 : }
    4781             : /* }}} */
    4782             : 
    4783             : /* {{{ proto public static mixed ReflectionProperty::export(mixed class, string name [, bool return]) throws ReflectionException
    4784             :    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
    4785           0 : ZEND_METHOD(reflection_property, export)
    4786             : {
    4787           0 :         _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_property_ptr, 2);
    4788           0 : }
    4789             : /* }}} */
    4790             : 
    4791             : /* {{{ proto public void ReflectionProperty::__construct(mixed class, string name)
    4792             :    Constructor. Throws an Exception in case the given property does not exist */
    4793           0 : ZEND_METHOD(reflection_property, __construct)
    4794             : {
    4795             :         zval *propname, *classname;
    4796             :         char *name_str;
    4797             :         const char *class_name, *prop_name;
    4798           0 :         int name_len, dynam_prop = 0;
    4799             :         zval *object;
    4800             :         reflection_object *intern;
    4801             :         zend_class_entry **pce;
    4802             :         zend_class_entry *ce;
    4803           0 :         zend_property_info *property_info = NULL;
    4804             :         property_reference *reference;
    4805             : 
    4806           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &classname, &name_str, &name_len) == FAILURE) {
    4807           0 :                 return;
    4808             :         }
    4809             : 
    4810           0 :         object = getThis();
    4811           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    4812           0 :         if (intern == NULL) {
    4813           0 :                 return;
    4814             :         }
    4815             : 
    4816             :         /* Find the class entry */
    4817           0 :         switch (Z_TYPE_P(classname)) {
    4818             :                 case IS_STRING:
    4819           0 :                         if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) {
    4820           0 :                                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    4821           0 :                                                 "Class %s does not exist", Z_STRVAL_P(classname));
    4822           0 :                                 return;
    4823             :                         }
    4824           0 :                         ce = *pce;
    4825           0 :                         break;
    4826             : 
    4827             :                 case IS_OBJECT:
    4828           0 :                         ce = Z_OBJCE_P(classname);
    4829           0 :                         break;
    4830             : 
    4831             :                 default:
    4832           0 :                         _DO_THROW("The parameter class is expected to be either a string or an object");
    4833             :                         /* returns out of this function */
    4834             :         }
    4835             : 
    4836           0 :         if (zend_hash_find(&ce->properties_info, name_str, name_len + 1, (void **) &property_info) == FAILURE || (property_info->flags & ZEND_ACC_SHADOW)) {
    4837             :                 /* Check for dynamic properties */
    4838           0 :                 if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT && Z_OBJ_HT_P(classname)->get_properties) {
    4839           0 :                         if (zend_hash_exists(Z_OBJ_HT_P(classname)->get_properties(classname TSRMLS_CC), name_str, name_len+1)) {
    4840           0 :                                 dynam_prop = 1;
    4841             :                         }
    4842             :                 }
    4843           0 :                 if (dynam_prop == 0) {
    4844           0 :                         zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Property %s::$%s does not exist", ce->name, name_str);
    4845           0 :                         return;
    4846             :                 }
    4847             :         }
    4848             : 
    4849           0 :         if (dynam_prop == 0 && (property_info->flags & ZEND_ACC_PRIVATE) == 0) {
    4850             :                 /* we have to search the class hierarchy for this (implicit) public or protected property */
    4851           0 :                 zend_class_entry *tmp_ce = ce;
    4852             :                 zend_property_info *tmp_info;
    4853             : 
    4854           0 :                 while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) != SUCCESS) {
    4855           0 :                         ce = tmp_ce;
    4856           0 :                         property_info = tmp_info;
    4857           0 :                         tmp_ce = tmp_ce->parent;
    4858             :                 }
    4859             :         }
    4860             : 
    4861           0 :         MAKE_STD_ZVAL(classname);
    4862           0 :         MAKE_STD_ZVAL(propname);
    4863             : 
    4864           0 :         if (dynam_prop == 0) {
    4865           0 :                 zend_unmangle_property_name(property_info->name, property_info->name_length, &class_name, &prop_name);
    4866           0 :                 ZVAL_STRINGL(classname, property_info->ce->name, property_info->ce->name_length, 1);
    4867           0 :                 ZVAL_STRING(propname, prop_name, 1);
    4868             :         } else {
    4869           0 :                 ZVAL_STRINGL(classname, ce->name, ce->name_length, 1);
    4870           0 :                 ZVAL_STRINGL(propname, name_str, name_len, 1);
    4871             :         }
    4872           0 :         reflection_update_property(object, "class", classname);
    4873           0 :         reflection_update_property(object, "name", propname);
    4874             : 
    4875           0 :         reference = (property_reference*) emalloc(sizeof(property_reference));
    4876           0 :         if (dynam_prop) {
    4877           0 :                 reference->prop.flags = ZEND_ACC_IMPLICIT_PUBLIC;
    4878           0 :                 reference->prop.name = Z_STRVAL_P(propname);
    4879           0 :                 reference->prop.name_length = Z_STRLEN_P(propname);
    4880           0 :                 reference->prop.h = zend_get_hash_value(name_str, name_len+1);
    4881           0 :                 reference->prop.doc_comment = NULL;
    4882           0 :                 reference->prop.ce = ce;
    4883             :         } else {
    4884           0 :                 reference->prop = *property_info;
    4885             :         }
    4886           0 :         reference->ce = ce;
    4887           0 :         intern->ptr = reference;
    4888           0 :         intern->ref_type = REF_TYPE_PROPERTY;
    4889           0 :         intern->ce = ce;
    4890           0 :         intern->ignore_visibility = 0;
    4891             : }
    4892             : /* }}} */
    4893             : 
    4894             : /* {{{ proto public string ReflectionProperty::__toString()
    4895             :    Returns a string representation */
    4896           0 : ZEND_METHOD(reflection_property, __toString)
    4897             : {
    4898             :         reflection_object *intern;
    4899             :         property_reference *ref;
    4900             :         string str;
    4901             : 
    4902           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4903           0 :                 return;
    4904             :         }
    4905           0 :         GET_REFLECTION_OBJECT_PTR(ref);
    4906           0 :         string_init(&str);
    4907           0 :         _property_string(&str, &ref->prop, NULL, "" TSRMLS_CC);
    4908           0 :         RETURN_STRINGL(str.string, str.len - 1, 0);
    4909             : }
    4910             : /* }}} */
    4911             : 
    4912             : /* {{{ proto public string ReflectionProperty::getName()
    4913             :    Returns the class' name */
    4914           0 : ZEND_METHOD(reflection_property, getName)
    4915             : {
    4916           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4917           0 :                 return;
    4918             :         }
    4919           0 :         _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
    4920             : }
    4921             : /* }}} */
    4922             : 
    4923           0 : static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /* {{{ */
    4924             : {
    4925             :         reflection_object *intern;
    4926             :         property_reference *ref;
    4927             : 
    4928           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4929           0 :                 return;
    4930             :         }
    4931           0 :         GET_REFLECTION_OBJECT_PTR(ref);
    4932           0 :         RETURN_BOOL(ref->prop.flags & mask);
    4933             : }
    4934             : /* }}} */
    4935             : 
    4936             : /* {{{ proto public bool ReflectionProperty::isPublic()
    4937             :    Returns whether this property is public */
    4938           0 : ZEND_METHOD(reflection_property, isPublic)
    4939             : {
    4940           0 :         _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC);
    4941           0 : }
    4942             : /* }}} */
    4943             : 
    4944             : /* {{{ proto public bool ReflectionProperty::isPrivate()
    4945             :    Returns whether this property is private */
    4946           0 : ZEND_METHOD(reflection_property, isPrivate)
    4947             : {
    4948           0 :         _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PRIVATE);
    4949           0 : }
    4950             : /* }}} */
    4951             : 
    4952             : /* {{{ proto public bool ReflectionProperty::isProtected()
    4953             :    Returns whether this property is protected */
    4954           0 : ZEND_METHOD(reflection_property, isProtected)
    4955             : {
    4956           0 :         _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PROTECTED);
    4957           0 : }
    4958             : /* }}} */
    4959             : 
    4960             : /* {{{ proto public bool ReflectionProperty::isStatic()
    4961             :    Returns whether this property is static */
    4962           0 : ZEND_METHOD(reflection_property, isStatic)
    4963             : {
    4964           0 :         _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_STATIC);
    4965           0 : }
    4966             : /* }}} */
    4967             : 
    4968             : /* {{{ proto public bool ReflectionProperty::isDefault()
    4969             :    Returns whether this property is default (declared at compilation time). */
    4970           0 : ZEND_METHOD(reflection_property, isDefault)
    4971             : {
    4972           0 :         _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ~ZEND_ACC_IMPLICIT_PUBLIC);
    4973           0 : }
    4974             : /* }}} */
    4975             : 
    4976             : /* {{{ proto public int ReflectionProperty::getModifiers()
    4977             :    Returns a bitfield of the access modifiers for this property */
    4978           0 : ZEND_METHOD(reflection_property, getModifiers)
    4979             : {
    4980             :         reflection_object *intern;
    4981             :         property_reference *ref;
    4982             : 
    4983           0 :         if (zend_parse_parameters_none() == FAILURE) {
    4984           0 :                 return;
    4985             :         }
    4986           0 :         GET_REFLECTION_OBJECT_PTR(ref);
    4987             : 
    4988           0 :         RETURN_LONG(ref->prop.flags);
    4989             : }
    4990             : /* }}} */
    4991             : 
    4992             : /* {{{ proto public mixed ReflectionProperty::getValue([stdclass object])
    4993             :    Returns this property's value */
    4994           0 : ZEND_METHOD(reflection_property, getValue)
    4995             : {
    4996             :         reflection_object *intern;
    4997             :         property_reference *ref;
    4998             :         zval *object, name;
    4999           0 :         zval *member_p = NULL;
    5000             : 
    5001           0 :         METHOD_NOTSTATIC(reflection_property_ptr);
    5002           0 :         GET_REFLECTION_OBJECT_PTR(ref);
    5003             : 
    5004           0 :         if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) {
    5005           0 :                 _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC);
    5006           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    5007           0 :                         "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
    5008             :                 zval_dtor(&name);
    5009           0 :                 return;
    5010             :         }
    5011             : 
    5012           0 :         if ((ref->prop.flags & ZEND_ACC_STATIC)) {
    5013           0 :                 zend_update_class_constants(intern->ce TSRMLS_CC);
    5014           0 :                 if (!CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) {
    5015           0 :                         php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name);
    5016             :                         /* Bails out */
    5017             :                 }
    5018           0 :                 *return_value= *CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset];
    5019             :                 zval_copy_ctor(return_value);
    5020           0 :                 INIT_PZVAL(return_value);
    5021             :         } else {
    5022             :                 const char *class_name, *prop_name;
    5023             : 
    5024           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) {
    5025           0 :                         return;
    5026             :                 }
    5027           0 :                 zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name);
    5028           0 :                 member_p = zend_read_property(ref->ce, object, prop_name, strlen(prop_name), 1 TSRMLS_CC);
    5029           0 :                 MAKE_COPY_ZVAL(&member_p, return_value);
    5030           0 :                 if (member_p != EG(uninitialized_zval_ptr)) {
    5031           0 :                         zval_add_ref(&member_p);
    5032           0 :                         zval_ptr_dtor(&member_p);
    5033             :                 }
    5034             :         }
    5035             : }
    5036             : /* }}} */
    5037             : 
    5038             : /* {{{ proto public void ReflectionProperty::setValue([stdclass object,] mixed value)
    5039             :    Sets this property's value */
    5040           0 : ZEND_METHOD(reflection_property, setValue)
    5041             : {
    5042             :         reflection_object *intern;
    5043             :         property_reference *ref;
    5044             :         zval **variable_ptr;
    5045             :         zval *object, name;
    5046             :         zval *value;
    5047             :         zval *tmp;
    5048             : 
    5049           0 :         METHOD_NOTSTATIC(reflection_property_ptr);
    5050           0 :         GET_REFLECTION_OBJECT_PTR(ref);
    5051             : 
    5052           0 :         if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
    5053           0 :                 _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC);
    5054           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    5055           0 :                         "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
    5056             :                 zval_dtor(&name);
    5057           0 :                 return;
    5058             :         }
    5059             : 
    5060           0 :         if ((ref->prop.flags & ZEND_ACC_STATIC)) {
    5061           0 :                 if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
    5062           0 :                         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &tmp, &value) == FAILURE) {
    5063           0 :                                 return;
    5064             :                         }
    5065             :                 }
    5066           0 :                 zend_update_class_constants(intern->ce TSRMLS_CC);
    5067             : 
    5068           0 :                 if (!CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) {
    5069           0 :                         php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name);
    5070             :                         /* Bails out */
    5071             :                 }
    5072           0 :                 variable_ptr = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset];
    5073           0 :                 if (*variable_ptr != value) {
    5074           0 :                         if (PZVAL_IS_REF(*variable_ptr)) {
    5075           0 :                                 zval garbage = **variable_ptr; /* old value should be destroyed */
    5076             : 
    5077             :                                 /* To check: can't *variable_ptr be some system variable like error_zval here? */
    5078           0 :                                 Z_TYPE_PP(variable_ptr) = Z_TYPE_P(value);
    5079           0 :                                 (*variable_ptr)->value = value->value;
    5080           0 :                                 if (Z_REFCOUNT_P(value) > 0) {
    5081           0 :                                         zval_copy_ctor(*variable_ptr);
    5082             :                                 }
    5083             :                                 zval_dtor(&garbage);
    5084             :                         } else {
    5085           0 :                                 zval *garbage = *variable_ptr;
    5086             : 
    5087             :                                 /* if we assign referenced variable, we should separate it */
    5088           0 :                                 Z_ADDREF_P(value);
    5089           0 :                                 if (PZVAL_IS_REF(value)) {
    5090           0 :                                         SEPARATE_ZVAL(&value);
    5091             :                                 }
    5092           0 :                                 *variable_ptr = value;
    5093           0 :                                 zval_ptr_dtor(&garbage);
    5094             :                         }
    5095             :                 }
    5096             :         } else {
    5097             :                 const char *class_name, *prop_name;
    5098             : 
    5099           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oz", &object, &value) == FAILURE) {
    5100           0 :                         return;
    5101             :                 }
    5102           0 :                 zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name);
    5103           0 :                 zend_update_property(ref->ce, object, prop_name, strlen(prop_name), value TSRMLS_CC);
    5104             :         }
    5105             : }
    5106             : /* }}} */
    5107             : 
    5108             : /* {{{ proto public ReflectionClass ReflectionProperty::getDeclaringClass()
    5109             :    Get the declaring class */
    5110           0 : ZEND_METHOD(reflection_property, getDeclaringClass)
    5111             : {
    5112             :         reflection_object *intern;
    5113             :         property_reference *ref;
    5114             :         zend_class_entry *tmp_ce, *ce;
    5115             :         zend_property_info *tmp_info;
    5116             :         const char *prop_name, *class_name;
    5117             :         int prop_name_len;
    5118             : 
    5119           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5120           0 :                 return;
    5121             :         }
    5122           0 :         GET_REFLECTION_OBJECT_PTR(ref);
    5123             : 
    5124           0 :         if (zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name) != SUCCESS) {
    5125           0 :                 RETURN_FALSE;
    5126             :         }
    5127             : 
    5128           0 :         prop_name_len = strlen(prop_name);
    5129           0 :         ce = tmp_ce = ref->ce;
    5130           0 :         while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, prop_name_len + 1, (void **) &tmp_info) == SUCCESS) {
    5131           0 :                 if (tmp_info->flags & ZEND_ACC_PRIVATE || tmp_info->flags & ZEND_ACC_SHADOW) {
    5132             :                         /* it's a private property, so it can't be inherited */
    5133             :                         break;
    5134             :                 }
    5135           0 :                 ce = tmp_ce;
    5136           0 :                 if (tmp_ce == tmp_info->ce) {
    5137             :                         /* declared in this class, done */
    5138           0 :                         break;
    5139             :                 }
    5140           0 :                 tmp_ce = tmp_ce->parent;
    5141             :         }
    5142             : 
    5143           0 :         zend_reflection_class_factory(ce, return_value TSRMLS_CC);
    5144             : }
    5145             : /* }}} */
    5146             : 
    5147             : /* {{{ proto public string ReflectionProperty::getDocComment()
    5148             :    Returns the doc comment for this property */
    5149           0 : ZEND_METHOD(reflection_property, getDocComment)
    5150             : {
    5151             :         reflection_object *intern;
    5152             :         property_reference *ref;
    5153             : 
    5154           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5155           0 :                 return;
    5156             :         }
    5157           0 :         GET_REFLECTION_OBJECT_PTR(ref);
    5158           0 :         if (ref->prop.doc_comment) {
    5159           0 :                 RETURN_STRINGL(ref->prop.doc_comment, ref->prop.doc_comment_len, 1);
    5160             :         }
    5161           0 :         RETURN_FALSE;
    5162             : }
    5163             : /* }}} */
    5164             : 
    5165             : /* {{{ proto public int ReflectionProperty::setAccessible(bool visible)
    5166             :    Sets whether non-public properties can be requested */
    5167           0 : ZEND_METHOD(reflection_property, setAccessible)
    5168             : {
    5169             :         reflection_object *intern;
    5170             :         zend_bool visible;
    5171             : 
    5172           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &visible) == FAILURE) {
    5173           0 :                 return;
    5174             :         }
    5175             : 
    5176           0 :         intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
    5177             : 
    5178           0 :         if (intern == NULL) {
    5179           0 :                 return;
    5180             :         }
    5181             : 
    5182           0 :         intern->ignore_visibility = visible;
    5183             : }
    5184             : /* }}} */
    5185             : 
    5186             : /* {{{ proto public static mixed ReflectionExtension::export(string name [, bool return]) throws ReflectionException
    5187             :    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
    5188           0 : ZEND_METHOD(reflection_extension, export)
    5189             : {
    5190           0 :         _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_extension_ptr, 1);
    5191           0 : }
    5192             : /* }}} */
    5193             : 
    5194             : /* {{{ proto public void ReflectionExtension::__construct(string name)
    5195             :    Constructor. Throws an Exception in case the given extension does not exist */
    5196           0 : ZEND_METHOD(reflection_extension, __construct)
    5197             : {
    5198             :         zval *name;
    5199             :         zval *object;
    5200             :         char *lcname;
    5201             :         reflection_object *intern;
    5202             :         zend_module_entry *module;
    5203             :         char *name_str;
    5204             :         int name_len;
    5205             :         ALLOCA_FLAG(use_heap)
    5206             : 
    5207           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len) == FAILURE) {
    5208           0 :                 return;
    5209             :         }
    5210             : 
    5211           0 :         object = getThis();
    5212           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    5213           0 :         if (intern == NULL) {
    5214           0 :                 return;
    5215             :         }
    5216           0 :         lcname = do_alloca(name_len + 1, use_heap);
    5217           0 :         zend_str_tolower_copy(lcname, name_str, name_len);
    5218           0 :         if (zend_hash_find(&module_registry, lcname, name_len + 1, (void **)&module) == FAILURE) {
    5219           0 :                 free_alloca(lcname, use_heap);
    5220           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    5221             :                         "Extension %s does not exist", name_str);
    5222           0 :                 return;
    5223             :         }
    5224           0 :         free_alloca(lcname, use_heap);
    5225           0 :         MAKE_STD_ZVAL(name);
    5226           0 :         ZVAL_STRING(name, module->name, 1);
    5227           0 :         reflection_update_property( object, "name", name);
    5228           0 :         intern->ptr = module;
    5229           0 :         intern->ref_type = REF_TYPE_OTHER;
    5230           0 :         intern->ce = NULL;
    5231             : }
    5232             : /* }}} */
    5233             : 
    5234             : /* {{{ proto public string ReflectionExtension::__toString()
    5235             :    Returns a string representation */
    5236           0 : ZEND_METHOD(reflection_extension, __toString)
    5237             : {
    5238             :         reflection_object *intern;
    5239             :         zend_module_entry *module;
    5240             :         string str;
    5241             : 
    5242           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5243           0 :                 return;
    5244             :         }
    5245           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5246           0 :         string_init(&str);
    5247           0 :         _extension_string(&str, module, "" TSRMLS_CC);
    5248           0 :         RETURN_STRINGL(str.string, str.len - 1, 0);
    5249             : }
    5250             : /* }}} */
    5251             : 
    5252             : /* {{{ proto public string ReflectionExtension::getName()
    5253             :    Returns this extension's name */
    5254           0 : ZEND_METHOD(reflection_extension, getName)
    5255             : {
    5256           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5257           0 :                 return;
    5258             :         }
    5259           0 :         _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
    5260             : }
    5261             : /* }}} */
    5262             : 
    5263             : /* {{{ proto public string ReflectionExtension::getVersion()
    5264             :    Returns this extension's version */
    5265           0 : ZEND_METHOD(reflection_extension, getVersion)
    5266             : {
    5267             :         reflection_object *intern;
    5268             :         zend_module_entry *module;
    5269             : 
    5270           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5271           0 :                 return;
    5272             :         }
    5273           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5274             : 
    5275             :         /* An extension does not necessarily have a version number */
    5276           0 :         if (module->version == NO_VERSION_YET) {
    5277           0 :                 RETURN_NULL();
    5278             :         } else {
    5279           0 :                 RETURN_STRING(module->version, 1);
    5280             :         }
    5281             : }
    5282             : /* }}} */
    5283             : 
    5284             : /* {{{ proto public ReflectionFunction[] ReflectionExtension::getFunctions()
    5285             :    Returns an array of this extension's functions */
    5286           0 : ZEND_METHOD(reflection_extension, getFunctions)
    5287             : {
    5288             :         reflection_object *intern;
    5289             :         zend_module_entry *module;
    5290             :         HashPosition iterator;
    5291             :         zval *function;
    5292             :         zend_function *fptr;
    5293             : 
    5294           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5295           0 :                 return;
    5296             :         }
    5297           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5298             : 
    5299           0 :         array_init(return_value);
    5300           0 :         zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator);
    5301           0 :         while (zend_hash_get_current_data_ex(CG(function_table), (void **) &fptr, &iterator) == SUCCESS) {
    5302           0 :                 if (fptr->common.type==ZEND_INTERNAL_FUNCTION
    5303           0 :                         && fptr->internal_function.module == module) {
    5304           0 :                         ALLOC_ZVAL(function);
    5305           0 :                         reflection_function_factory(fptr, NULL, function TSRMLS_CC);
    5306           0 :                         add_assoc_zval(return_value, fptr->common.function_name, function);
    5307             :                 }
    5308           0 :                 zend_hash_move_forward_ex(CG(function_table), &iterator);
    5309             :         }
    5310             : }
    5311             : /* }}} */
    5312             : 
    5313           0 : static int _addconstant(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
    5314             : {
    5315             :         zval *const_val;
    5316           0 :         zval *retval = va_arg(args, zval*);
    5317           0 :         int number = va_arg(args, int);
    5318             : 
    5319           0 :         if (number == constant->module_number) {
    5320           0 :                 ALLOC_ZVAL(const_val);
    5321           0 :                 *const_val = constant->value;
    5322             :                 zval_copy_ctor(const_val);
    5323           0 :                 INIT_PZVAL(const_val);
    5324           0 :                 add_assoc_zval_ex(retval, constant->name, constant->name_len, const_val);
    5325             :         }
    5326           0 :         return 0;
    5327             : }
    5328             : /* }}} */
    5329             : 
    5330             : /* {{{ proto public array ReflectionExtension::getConstants()
    5331             :    Returns an associative array containing this extension's constants and their values */
    5332           0 : ZEND_METHOD(reflection_extension, getConstants)
    5333             : {
    5334             :         reflection_object *intern;
    5335             :         zend_module_entry *module;
    5336             : 
    5337           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5338           0 :                 return;
    5339             :         }
    5340           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5341             : 
    5342           0 :         array_init(return_value);
    5343           0 :         zend_hash_apply_with_arguments(EG(zend_constants) TSRMLS_CC, (apply_func_args_t) _addconstant, 2, return_value, module->module_number);
    5344             : }
    5345             : /* }}} */
    5346             : 
    5347             : /* {{{ _addinientry */
    5348           0 : static int _addinientry(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
    5349             : {
    5350           0 :         zval *retval = va_arg(args, zval*);
    5351           0 :         int number = va_arg(args, int);
    5352             : 
    5353           0 :         if (number == ini_entry->module_number) {
    5354           0 :                 if (ini_entry->value) {
    5355           0 :                         add_assoc_stringl(retval, ini_entry->name, ini_entry->value, ini_entry->value_length, 1);
    5356             :                 } else {
    5357           0 :                         add_assoc_null(retval, ini_entry->name);
    5358             :                 }
    5359             :         }
    5360           0 :         return ZEND_HASH_APPLY_KEEP;
    5361             : }
    5362             : /* }}} */
    5363             : 
    5364             : /* {{{ proto public array ReflectionExtension::getINIEntries()
    5365             :    Returns an associative array containing this extension's INI entries and their values */
    5366           0 : ZEND_METHOD(reflection_extension, getINIEntries)
    5367             : {
    5368             :         reflection_object *intern;
    5369             :         zend_module_entry *module;
    5370             : 
    5371           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5372           0 :                 return;
    5373             :         }
    5374           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5375             : 
    5376           0 :         array_init(return_value);
    5377           0 :         zend_hash_apply_with_arguments(EG(ini_directives) TSRMLS_CC, (apply_func_args_t) _addinientry, 2, return_value, module->module_number);
    5378             : }
    5379             : /* }}} */
    5380             : 
    5381             : /* {{{ add_extension_class */
    5382           0 : static int add_extension_class(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
    5383             : {
    5384           0 :         zval *class_array = va_arg(args, zval*), *zclass;
    5385           0 :         struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*);
    5386           0 :         int add_reflection_class = va_arg(args, int);
    5387             : 
    5388           0 :         if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) {
    5389           0 :                 if (add_reflection_class) {
    5390           0 :                         ALLOC_ZVAL(zclass);
    5391           0 :                         zend_reflection_class_factory(*pce, zclass TSRMLS_CC);
    5392           0 :                         add_assoc_zval_ex(class_array, (*pce)->name, (*pce)->name_length + 1, zclass);
    5393             :                 } else {
    5394           0 :                         add_next_index_stringl(class_array, (*pce)->name, (*pce)->name_length, 1);
    5395             :                 }
    5396             :         }
    5397           0 :         return ZEND_HASH_APPLY_KEEP;
    5398             : }
    5399             : /* }}} */
    5400             : 
    5401             : /* {{{ proto public ReflectionClass[] ReflectionExtension::getClasses()
    5402             :    Returns an array containing ReflectionClass objects for all classes of this extension */
    5403           0 : ZEND_METHOD(reflection_extension, getClasses)
    5404             : {
    5405             :         reflection_object *intern;
    5406             :         zend_module_entry *module;
    5407             : 
    5408           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5409           0 :                 return;
    5410             :         }
    5411           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5412             : 
    5413           0 :         array_init(return_value);
    5414           0 :         zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) add_extension_class, 3, return_value, module, 1);
    5415             : }
    5416             : /* }}} */
    5417             : 
    5418             : /* {{{ proto public array ReflectionExtension::getClassNames()
    5419             :    Returns an array containing all names of all classes of this extension */
    5420           0 : ZEND_METHOD(reflection_extension, getClassNames)
    5421             : {
    5422             :         reflection_object *intern;
    5423             :         zend_module_entry *module;
    5424             : 
    5425           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5426           0 :                 return;
    5427             :         }
    5428           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5429             : 
    5430           0 :         array_init(return_value);
    5431           0 :         zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) add_extension_class, 3, return_value, module, 0);
    5432             : }
    5433             : /* }}} */
    5434             : 
    5435             : /* {{{ proto public array ReflectionExtension::getDependencies()
    5436             :    Returns an array containing all names of all extensions this extension depends on */
    5437           0 : ZEND_METHOD(reflection_extension, getDependencies)
    5438             : {
    5439             :         reflection_object *intern;
    5440             :         zend_module_entry *module;
    5441             :         const zend_module_dep *dep;
    5442             : 
    5443           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5444           0 :                 return;
    5445             :         }
    5446           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5447             : 
    5448           0 :         array_init(return_value);
    5449             : 
    5450           0 :         dep = module->deps;
    5451             : 
    5452           0 :         if (!dep)
    5453             :         {
    5454           0 :                 return;
    5455             :         }
    5456             : 
    5457           0 :         while(dep->name) {
    5458             :                 char *relation;
    5459             :                 char *rel_type;
    5460             :                 int len;
    5461             : 
    5462           0 :                 switch(dep->type) {
    5463             :                 case MODULE_DEP_REQUIRED:
    5464           0 :                         rel_type = "Required";
    5465           0 :                         break;
    5466             :                 case MODULE_DEP_CONFLICTS:
    5467           0 :                         rel_type = "Conflicts";
    5468           0 :                         break;
    5469             :                 case MODULE_DEP_OPTIONAL:
    5470           0 :                         rel_type = "Optional";
    5471           0 :                         break;
    5472             :                 default:
    5473           0 :                         rel_type = "Error"; /* shouldn't happen */
    5474             :                         break;
    5475             :                 }
    5476             : 
    5477           0 :                 len = spprintf(&relation, 0, "%s%s%s%s%s",
    5478             :                                                 rel_type,
    5479           0 :                                                 dep->rel ? " " : "",
    5480           0 :                                                 dep->rel ? dep->rel : "",
    5481           0 :                                                 dep->version ? " " : "",
    5482           0 :                                                 dep->version ? dep->version : "");
    5483           0 :                 add_assoc_stringl(return_value, dep->name, relation, len, 0);
    5484           0 :                 dep++;
    5485             :         }
    5486             : }
    5487             : /* }}} */
    5488             : 
    5489             : /* {{{ proto public void ReflectionExtension::info()
    5490             :        Prints phpinfo block for the extension */
    5491           0 : ZEND_METHOD(reflection_extension, info)
    5492             : {
    5493             :         reflection_object *intern;
    5494             :         zend_module_entry *module;
    5495             : 
    5496           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5497           0 :                 return;
    5498             :         }
    5499           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5500             : 
    5501           0 :         php_info_print_module(module TSRMLS_CC);
    5502             : }
    5503             : /* }}} */
    5504             : 
    5505             : /* {{{ proto public bool ReflectionExtension::isPersistent()
    5506             :        Returns whether this extension is persistent */
    5507           0 : ZEND_METHOD(reflection_extension, isPersistent)
    5508             : {
    5509             :         reflection_object *intern;
    5510             :     zend_module_entry *module;
    5511             : 
    5512           0 :     if (zend_parse_parameters_none() == FAILURE) {
    5513           0 :                 return;
    5514             :         }
    5515           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5516             : 
    5517           0 :         RETURN_BOOL(module->type == MODULE_PERSISTENT);
    5518             : }
    5519             : /* }}} */
    5520             : 
    5521             : /* {{{ proto public bool ReflectionExtension::isTemporary()
    5522             :        Returns whether this extension is temporary */
    5523           0 : ZEND_METHOD(reflection_extension, isTemporary)
    5524             : {
    5525             :         reflection_object *intern;
    5526             :         zend_module_entry *module;
    5527             : 
    5528           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5529           0 :                 return;
    5530             :         }
    5531           0 :         GET_REFLECTION_OBJECT_PTR(module);
    5532             : 
    5533           0 :         RETURN_BOOL(module->type == MODULE_TEMPORARY);
    5534             : }
    5535             : /* }}} */
    5536             : 
    5537             : /* {{{ proto public static mixed ReflectionZendExtension::export(string name [, bool return]) throws ReflectionException
    5538             :  *    Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
    5539           0 : ZEND_METHOD(reflection_zend_extension, export)
    5540             : {
    5541           0 :         _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_zend_extension_ptr, 1);
    5542           0 : }
    5543             : /* }}} */
    5544             : 
    5545             : /* {{{ proto public void ReflectionZendExtension::__construct(string name)
    5546             :        Constructor. Throws an Exception in case the given Zend extension does not exist */
    5547           0 : ZEND_METHOD(reflection_zend_extension, __construct)
    5548             : {
    5549             :         zval *name;
    5550             :         zval *object;
    5551             :         reflection_object *intern;
    5552             :         zend_extension *extension;
    5553             :         char *name_str;
    5554             :         int name_len;
    5555             : 
    5556           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len) == FAILURE) {
    5557           0 :                 return;
    5558             :         }
    5559             : 
    5560           0 :         object = getThis();
    5561           0 :         intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
    5562           0 :         if (intern == NULL) {
    5563           0 :                 return;
    5564             :         }
    5565             : 
    5566           0 :         extension = zend_get_extension(name_str);
    5567           0 :         if (!extension) {
    5568           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    5569             :                                 "Zend Extension %s does not exist", name_str);
    5570           0 :                 return;
    5571             :         }
    5572           0 :         MAKE_STD_ZVAL(name);
    5573           0 :         ZVAL_STRING(name, extension->name, 1);
    5574           0 :         reflection_update_property(object, "name", name);
    5575           0 :         intern->ptr = extension;
    5576           0 :         intern->ref_type = REF_TYPE_OTHER;
    5577           0 :         intern->ce = NULL;
    5578             : }
    5579             : /* }}} */
    5580             : 
    5581             : /* {{{ proto public string ReflectionZendExtension::__toString()
    5582             :        Returns a string representation */
    5583           0 : ZEND_METHOD(reflection_zend_extension, __toString)
    5584             : {
    5585             :         reflection_object *intern;
    5586             :         zend_extension *extension;
    5587             :         string str;
    5588             : 
    5589           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5590           0 :                 return;
    5591             :         }
    5592           0 :         GET_REFLECTION_OBJECT_PTR(extension);
    5593           0 :         string_init(&str);
    5594           0 :         _zend_extension_string(&str, extension, "" TSRMLS_CC);
    5595           0 :         RETURN_STRINGL(str.string, str.len - 1, 0);
    5596             : }
    5597             : /* }}} */
    5598             : 
    5599             : /* {{{ proto public string ReflectionZendExtension::getName()
    5600             :        Returns the name of this Zend extension */
    5601           0 : ZEND_METHOD(reflection_zend_extension, getName)
    5602             : {
    5603             :         reflection_object *intern;
    5604             :         zend_extension *extension;
    5605             : 
    5606           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5607           0 :                 return;
    5608             :         }
    5609           0 :         GET_REFLECTION_OBJECT_PTR(extension);
    5610             : 
    5611           0 :         RETURN_STRING(extension->name, 1);
    5612             : }
    5613             : /* }}} */
    5614             : 
    5615             : /* {{{ proto public string ReflectionZendExtension::getVersion()
    5616             :        Returns the version information of this Zend extension */
    5617           0 : ZEND_METHOD(reflection_zend_extension, getVersion)
    5618             : {
    5619             :         reflection_object *intern;
    5620             :         zend_extension *extension;
    5621             : 
    5622           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5623           0 :                 return;
    5624             :         }
    5625           0 :         GET_REFLECTION_OBJECT_PTR(extension);
    5626             : 
    5627           0 :         RETURN_STRING(extension->version ? extension->version : "", 1);
    5628             : }
    5629             : /* }}} */
    5630             : 
    5631             : /* {{{ proto public void ReflectionZendExtension::getAuthor()
    5632             :  * Returns the name of this Zend extension's author */
    5633           0 : ZEND_METHOD(reflection_zend_extension, getAuthor)
    5634             : {
    5635             :         reflection_object *intern;
    5636             :         zend_extension *extension;
    5637             : 
    5638           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5639           0 :                 return;
    5640             :         }
    5641           0 :         GET_REFLECTION_OBJECT_PTR(extension);
    5642             : 
    5643           0 :         RETURN_STRING(extension->author ? extension->author : "", 1);
    5644             : }
    5645             : /* }}} */
    5646             : 
    5647             : /* {{{ proto public void ReflectionZendExtension::getURL()
    5648             :        Returns this Zend extension's URL*/
    5649           0 : ZEND_METHOD(reflection_zend_extension, getURL)
    5650             : {
    5651             :         reflection_object *intern;
    5652             :         zend_extension *extension;
    5653             : 
    5654           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5655           0 :                 return;
    5656             :         }
    5657           0 :         GET_REFLECTION_OBJECT_PTR(extension);
    5658             : 
    5659           0 :         RETURN_STRING(extension->URL ? extension->URL : "", 1);
    5660             : }
    5661             : /* }}} */
    5662             : 
    5663             : /* {{{ proto public void ReflectionZendExtension::getCopyright()
    5664             :        Returns this Zend extension's copyright information */
    5665           0 : ZEND_METHOD(reflection_zend_extension, getCopyright)
    5666             : {
    5667             :         reflection_object *intern;
    5668             :         zend_extension *extension;
    5669             : 
    5670           0 :         if (zend_parse_parameters_none() == FAILURE) {
    5671           0 :                 return;
    5672             :         }
    5673           0 :         GET_REFLECTION_OBJECT_PTR(extension);
    5674             : 
    5675           0 :         RETURN_STRING(extension->copyright ? extension->copyright : "", 1);
    5676             : }
    5677             : /* }}} */
    5678             : 
    5679             : /* {{{ method tables */
    5680             : static const zend_function_entry reflection_exception_functions[] = {
    5681             :         PHP_FE_END
    5682             : };
    5683             : 
    5684             : ZEND_BEGIN_ARG_INFO(arginfo_reflection__void, 0)
    5685             : ZEND_END_ARG_INFO()
    5686             : 
    5687             : 
    5688             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_getModifierNames, 0)
    5689             :         ZEND_ARG_INFO(0, modifiers)
    5690             : ZEND_END_ARG_INFO()
    5691             : 
    5692             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_export, 0, 0, 1)
    5693             :         ZEND_ARG_OBJ_INFO(0, reflector, Reflector, 0)
    5694             :         ZEND_ARG_INFO(0, return)
    5695             : ZEND_END_ARG_INFO()
    5696             : 
    5697             : static const zend_function_entry reflection_functions[] = {
    5698             :         ZEND_ME(reflection, getModifierNames, arginfo_reflection_getModifierNames, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
    5699             :         ZEND_ME(reflection, export, arginfo_reflection_export, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
    5700             :         PHP_FE_END
    5701             : };
    5702             : 
    5703             : static const zend_function_entry reflector_functions[] = {
    5704             :         ZEND_FENTRY(export, NULL, NULL, ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT|ZEND_ACC_PUBLIC)
    5705             :         ZEND_ABSTRACT_ME(reflector, __toString, arginfo_reflection__void)
    5706             :         PHP_FE_END
    5707             : };
    5708             : 
    5709             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_function_export, 0, 0, 1)
    5710             :         ZEND_ARG_INFO(0, name)
    5711             :         ZEND_ARG_INFO(0, return)
    5712             : ZEND_END_ARG_INFO()
    5713             : 
    5714             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_function___construct, 0)
    5715             :         ZEND_ARG_INFO(0, name)
    5716             : ZEND_END_ARG_INFO()
    5717             : 
    5718             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_function_invoke, 0, 0, 0)
    5719             :         ZEND_ARG_INFO(0, args)
    5720             : ZEND_END_ARG_INFO()
    5721             : 
    5722             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_function_invokeArgs, 0)
    5723             :         ZEND_ARG_ARRAY_INFO(0, args, 0)
    5724             : ZEND_END_ARG_INFO()
    5725             : 
    5726             : static const zend_function_entry reflection_function_abstract_functions[] = {
    5727             :         ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
    5728             :         PHP_ABSTRACT_ME(reflection_function, __toString, arginfo_reflection__void)
    5729             :         ZEND_ME(reflection_function, inNamespace, arginfo_reflection__void, 0)
    5730             :         ZEND_ME(reflection_function, isClosure, arginfo_reflection__void, 0)
    5731             :         ZEND_ME(reflection_function, isDeprecated, arginfo_reflection__void, 0)
    5732             :         ZEND_ME(reflection_function, isInternal, arginfo_reflection__void, 0)
    5733             :         ZEND_ME(reflection_function, isUserDefined, arginfo_reflection__void, 0)
    5734             :         ZEND_ME(reflection_function, isGenerator, arginfo_reflection__void, 0)
    5735             :         ZEND_ME(reflection_function, isVariadic, arginfo_reflection__void, 0)
    5736             :         ZEND_ME(reflection_function, getClosureThis, arginfo_reflection__void, 0)
    5737             :         ZEND_ME(reflection_function, getClosureScopeClass, arginfo_reflection__void, 0)
    5738             :         ZEND_ME(reflection_function, getDocComment, arginfo_reflection__void, 0)
    5739             :         ZEND_ME(reflection_function, getEndLine, arginfo_reflection__void, 0)
    5740             :         ZEND_ME(reflection_function, getExtension, arginfo_reflection__void, 0)
    5741             :         ZEND_ME(reflection_function, getExtensionName, arginfo_reflection__void, 0)
    5742             :         ZEND_ME(reflection_function, getFileName, arginfo_reflection__void, 0)
    5743             :         ZEND_ME(reflection_function, getName, arginfo_reflection__void, 0)
    5744             :         ZEND_ME(reflection_function, getNamespaceName, arginfo_reflection__void, 0)
    5745             :         ZEND_ME(reflection_function, getNumberOfParameters, arginfo_reflection__void, 0)
    5746             :         ZEND_ME(reflection_function, getNumberOfRequiredParameters, arginfo_reflection__void, 0)
    5747             :         ZEND_ME(reflection_function, getParameters, arginfo_reflection__void, 0)
    5748             :         ZEND_ME(reflection_function, getShortName, arginfo_reflection__void, 0)
    5749             :         ZEND_ME(reflection_function, getStartLine, arginfo_reflection__void, 0)
    5750             :         ZEND_ME(reflection_function, getStaticVariables, arginfo_reflection__void, 0)
    5751             :         ZEND_ME(reflection_function, returnsReference, arginfo_reflection__void, 0)
    5752             :         PHP_FE_END
    5753             : };
    5754             : 
    5755             : static const zend_function_entry reflection_function_functions[] = {
    5756             :         ZEND_ME(reflection_function, __construct, arginfo_reflection_function___construct, 0)
    5757             :         ZEND_ME(reflection_function, __toString, arginfo_reflection__void, 0)
    5758             :         ZEND_ME(reflection_function, export, arginfo_reflection_function_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
    5759             :         ZEND_ME(reflection_function, isDisabled, arginfo_reflection__void, 0)
    5760             :         ZEND_ME(reflection_function, invoke, arginfo_reflection_function_invoke, 0)
    5761             :         ZEND_ME(reflection_function, invokeArgs, arginfo_reflection_function_invokeArgs, 0)
    5762             :         ZEND_ME(reflection_function, getClosure, arginfo_reflection__void, 0)
    5763             :         PHP_FE_END
    5764             : };
    5765             : 
    5766             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_method_export, 0, 0, 2)
    5767             :         ZEND_ARG_INFO(0, class)
    5768             :         ZEND_ARG_INFO(0, name)
    5769             :         ZEND_ARG_INFO(0, return)
    5770             : ZEND_END_ARG_INFO()
    5771             : 
    5772             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_method___construct, 0, 0, 1)
    5773             :         ZEND_ARG_INFO(0, class_or_method)
    5774             :         ZEND_ARG_INFO(0, name)
    5775             : ZEND_END_ARG_INFO()
    5776             : 
    5777             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_invoke, 0)
    5778             :         ZEND_ARG_INFO(0, object)
    5779             :         ZEND_ARG_INFO(0, args)
    5780             : ZEND_END_ARG_INFO()
    5781             : 
    5782             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_invokeArgs, 0)
    5783             :         ZEND_ARG_INFO(0, object)
    5784             :         ZEND_ARG_ARRAY_INFO(0, args, 0)
    5785             : ZEND_END_ARG_INFO()
    5786             : 
    5787             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_setAccessible, 0)
    5788             :         ZEND_ARG_INFO(0, value)
    5789             : ZEND_END_ARG_INFO()
    5790             : 
    5791             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_getClosure, 0)
    5792             :         ZEND_ARG_INFO(0, object)
    5793             : ZEND_END_ARG_INFO()
    5794             : 
    5795             : static const zend_function_entry reflection_method_functions[] = {
    5796             :         ZEND_ME(reflection_method, export, arginfo_reflection_method_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
    5797             :         ZEND_ME(reflection_method, __construct, arginfo_reflection_method___construct, 0)
    5798             :         ZEND_ME(reflection_method, __toString, arginfo_reflection__void, 0)
    5799             :         ZEND_ME(reflection_method, isPublic, arginfo_reflection__void, 0)
    5800             :         ZEND_ME(reflection_method, isPrivate, arginfo_reflection__void, 0)
    5801             :         ZEND_ME(reflection_method, isProtected, arginfo_reflection__void, 0)
    5802             :         ZEND_ME(reflection_method, isAbstract, arginfo_reflection__void, 0)
    5803             :         ZEND_ME(reflection_method, isFinal, arginfo_reflection__void, 0)
    5804             :         ZEND_ME(reflection_method, isStatic, arginfo_reflection__void, 0)
    5805             :         ZEND_ME(reflection_method, isConstructor, arginfo_reflection__void, 0)
    5806             :         ZEND_ME(reflection_method, isDestructor, arginfo_reflection__void, 0)
    5807             :         ZEND_ME(reflection_method, getClosure, arginfo_reflection_method_getClosure, 0)
    5808             :         ZEND_ME(reflection_method, getModifiers, arginfo_reflection__void, 0)
    5809             :         ZEND_ME(reflection_method, invoke, arginfo_reflection_method_invoke, 0)
    5810             :         ZEND_ME(reflection_method, invokeArgs, arginfo_reflection_method_invokeArgs, 0)
    5811             :         ZEND_ME(reflection_method, getDeclaringClass, arginfo_reflection__void, 0)
    5812             :         ZEND_ME(reflection_method, getPrototype, arginfo_reflection__void, 0)
    5813             :         ZEND_ME(reflection_property, setAccessible, arginfo_reflection_method_setAccessible, 0)
    5814             :         PHP_FE_END
    5815             : };
    5816             : 
    5817             : 
    5818             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_export, 0, 0, 1)
    5819             :         ZEND_ARG_INFO(0, argument)
    5820             :         ZEND_ARG_INFO(0, return)
    5821             : ZEND_END_ARG_INFO()
    5822             : 
    5823             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class___construct, 0)
    5824             :         ZEND_ARG_INFO(0, argument)
    5825             : ZEND_END_ARG_INFO()
    5826             : 
    5827             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_getStaticPropertyValue, 0, 0, 1)
    5828             :         ZEND_ARG_INFO(0, name)
    5829             :         ZEND_ARG_INFO(0, default)
    5830             : ZEND_END_ARG_INFO()
    5831             : 
    5832             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_setStaticPropertyValue, 0)
    5833             :         ZEND_ARG_INFO(0, name)
    5834             :         ZEND_ARG_INFO(0, value)
    5835             : ZEND_END_ARG_INFO()
    5836             : 
    5837             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_hasMethod, 0)
    5838             :         ZEND_ARG_INFO(0, name)
    5839             : ZEND_END_ARG_INFO()
    5840             : 
    5841             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_getMethod, 0)
    5842             :         ZEND_ARG_INFO(0, name)
    5843             : ZEND_END_ARG_INFO()
    5844             : 
    5845             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_getMethods, 0, 0, 0)
    5846             :         ZEND_ARG_INFO(0, filter)
    5847             : ZEND_END_ARG_INFO()
    5848             : 
    5849             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_hasProperty, 0)
    5850             :         ZEND_ARG_INFO(0, name)
    5851             : ZEND_END_ARG_INFO()
    5852             : 
    5853             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_getProperty, 0)
    5854             :         ZEND_ARG_INFO(0, name)
    5855             : ZEND_END_ARG_INFO()
    5856             : 
    5857             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_getProperties, 0, 0, 0)
    5858             :         ZEND_ARG_INFO(0, filter)
    5859             : ZEND_END_ARG_INFO()
    5860             : 
    5861             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_hasConstant, 0)
    5862             :         ZEND_ARG_INFO(0, name)
    5863             : ZEND_END_ARG_INFO()
    5864             : 
    5865             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_getConstant, 0)
    5866             :         ZEND_ARG_INFO(0, name)
    5867             : ZEND_END_ARG_INFO()
    5868             : 
    5869             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_isInstance, 0)
    5870             :         ZEND_ARG_INFO(0, object)
    5871             : ZEND_END_ARG_INFO()
    5872             : 
    5873             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_newInstance, 0)
    5874             :         ZEND_ARG_INFO(0, args)
    5875             : ZEND_END_ARG_INFO()
    5876             : 
    5877             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_newInstanceWithoutConstructor, 0)
    5878             : ZEND_END_ARG_INFO()
    5879             : 
    5880             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_newInstanceArgs, 0, 0, 0)
    5881             :         ZEND_ARG_ARRAY_INFO(0, args, 0)
    5882             : ZEND_END_ARG_INFO()
    5883             : 
    5884             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_isSubclassOf, 0)
    5885             :         ZEND_ARG_INFO(0, class)
    5886             : ZEND_END_ARG_INFO()
    5887             : 
    5888             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_implementsInterface, 0)
    5889             :         ZEND_ARG_INFO(0, interface)
    5890             : ZEND_END_ARG_INFO()
    5891             : 
    5892             : static const zend_function_entry reflection_class_functions[] = {
    5893             :         ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
    5894             :         ZEND_ME(reflection_class, export, arginfo_reflection_class_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
    5895             :         ZEND_ME(reflection_class, __construct, arginfo_reflection_class___construct, 0)
    5896             :         ZEND_ME(reflection_class, __toString, arginfo_reflection__void, 0)
    5897             :         ZEND_ME(reflection_class, getName, arginfo_reflection__void, 0)
    5898             :         ZEND_ME(reflection_class, isInternal, arginfo_reflection__void, 0)
    5899             :         ZEND_ME(reflection_class, isUserDefined, arginfo_reflection__void, 0)
    5900             :         ZEND_ME(reflection_class, isInstantiable, arginfo_reflection__void, 0)
    5901             :         ZEND_ME(reflection_class, isCloneable, arginfo_reflection__void, 0)
    5902             :         ZEND_ME(reflection_class, getFileName, arginfo_reflection__void, 0)
    5903             :         ZEND_ME(reflection_class, getStartLine, arginfo_reflection__void, 0)
    5904             :         ZEND_ME(reflection_class, getEndLine, arginfo_reflection__void, 0)
    5905             :         ZEND_ME(reflection_class, getDocComment, arginfo_reflection__void, 0)
    5906             :         ZEND_ME(reflection_class, getConstructor, arginfo_reflection__void, 0)
    5907             :         ZEND_ME(reflection_class, hasMethod, arginfo_reflection_class_hasMethod, 0)
    5908             :         ZEND_ME(reflection_class, getMethod, arginfo_reflection_class_getMethod, 0)
    5909             :         ZEND_ME(reflection_class, getMethods, arginfo_reflection_class_getMethods, 0)
    5910             :         ZEND_ME(reflection_class, hasProperty, arginfo_reflection_class_hasProperty, 0)
    5911             :         ZEND_ME(reflection_class, getProperty, arginfo_reflection_class_getProperty, 0)
    5912             :         ZEND_ME(reflection_class, getProperties, arginfo_reflection_class_getProperties, 0)
    5913             :         ZEND_ME(reflection_class, hasConstant, arginfo_reflection_class_hasConstant, 0)
    5914             :         ZEND_ME(reflection_class, getConstants, arginfo_reflection__void, 0)
    5915             :         ZEND_ME(reflection_class, getConstant, arginfo_reflection_class_getConstant, 0)
    5916             :         ZEND_ME(reflection_class, getInterfaces, arginfo_reflection__void, 0)
    5917             :         ZEND_ME(reflection_class, getInterfaceNames, arginfo_reflection__void, 0)
    5918             :         ZEND_ME(reflection_class, isInterface, arginfo_reflection__void, 0)
    5919             :         ZEND_ME(reflection_class, getTraits, arginfo_reflection__void, 0)
    5920             :         ZEND_ME(reflection_class, getTraitNames, arginfo_reflection__void, 0)
    5921             :         ZEND_ME(reflection_class, getTraitAliases, arginfo_reflection__void, 0)
    5922             :         ZEND_ME(reflection_class, isTrait, arginfo_reflection__void, 0)
    5923             :         ZEND_ME(reflection_class, isAbstract, arginfo_reflection__void, 0)
    5924             :         ZEND_ME(reflection_class, isFinal, arginfo_reflection__void, 0)
    5925             :         ZEND_ME(reflection_class, getModifiers, arginfo_reflection__void, 0)
    5926             :         ZEND_ME(reflection_class, isInstance, arginfo_reflection_class_isInstance, 0)
    5927             :         ZEND_ME(reflection_class, newInstance, arginfo_reflection_class_newInstance, 0)
    5928             :         ZEND_ME(reflection_class, newInstanceWithoutConstructor, arginfo_reflection_class_newInstanceWithoutConstructor, 0)
    5929             :         ZEND_ME(reflection_class, newInstanceArgs, arginfo_reflection_class_newInstanceArgs, 0)
    5930             :         ZEND_ME(reflection_class, getParentClass, arginfo_reflection__void, 0)
    5931             :         ZEND_ME(reflection_class, isSubclassOf, arginfo_reflection_class_isSubclassOf, 0)
    5932             :         ZEND_ME(reflection_class, getStaticProperties, arginfo_reflection__void, 0)
    5933             :         ZEND_ME(reflection_class, getStaticPropertyValue, arginfo_reflection_class_getStaticPropertyValue, 0)
    5934             :         ZEND_ME(reflection_class, setStaticPropertyValue, arginfo_reflection_class_setStaticPropertyValue, 0)
    5935             :         ZEND_ME(reflection_class, getDefaultProperties, arginfo_reflection__void, 0)
    5936             :         ZEND_ME(reflection_class, isIterateable, arginfo_reflection__void, 0)
    5937             :         ZEND_ME(reflection_class, implementsInterface, arginfo_reflection_class_implementsInterface, 0)
    5938             :         ZEND_ME(reflection_class, getExtension, arginfo_reflection__void, 0)
    5939             :         ZEND_ME(reflection_class, getExtensionName, arginfo_reflection__void, 0)
    5940             :         ZEND_ME(reflection_class, inNamespace, arginfo_reflection__void, 0)
    5941             :         ZEND_ME(reflection_class, getNamespaceName, arginfo_reflection__void, 0)
    5942             :         ZEND_ME(reflection_class, getShortName, arginfo_reflection__void, 0)
    5943             :         PHP_FE_END
    5944             : };
    5945             : 
    5946             : 
    5947             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_object_export, 0, 0, 1)
    5948             :         ZEND_ARG_INFO(0, argument)
    5949             :         ZEND_ARG_INFO(0, return)
    5950             : ZEND_END_ARG_INFO()
    5951             : 
    5952             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_object___construct, 0)
    5953             :         ZEND_ARG_INFO(0, argument)
    5954             : ZEND_END_ARG_INFO()
    5955             : 
    5956             : static const zend_function_entry reflection_object_functions[] = {
    5957             :         ZEND_ME(reflection_object, export, arginfo_reflection_object_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
    5958             :         ZEND_ME(reflection_object, __construct, arginfo_reflection_object___construct, 0)
    5959             :         PHP_FE_END
    5960             : };
    5961             : 
    5962             : 
    5963             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_export, 0, 0, 2)
    5964             :         ZEND_ARG_INFO(0, class)
    5965             :         ZEND_ARG_INFO(0, name)
    5966             :         ZEND_ARG_INFO(0, return)
    5967             : ZEND_END_ARG_INFO()
    5968             : 
    5969             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property___construct, 0, 0, 2)
    5970             :         ZEND_ARG_INFO(0, class)
    5971             :         ZEND_ARG_INFO(0, name)
    5972             : ZEND_END_ARG_INFO()
    5973             : 
    5974             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_getValue, 0, 0, 0)
    5975             :         ZEND_ARG_INFO(0, object)
    5976             : ZEND_END_ARG_INFO()
    5977             : 
    5978             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_property_setValue, 0, 0, 1)
    5979             :         ZEND_ARG_INFO(0, object)
    5980             :         ZEND_ARG_INFO(0, value)
    5981             : ZEND_END_ARG_INFO()
    5982             : 
    5983             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_property_setAccessible, 0)
    5984             :         ZEND_ARG_INFO(0, visible)
    5985             : ZEND_END_ARG_INFO()
    5986             : 
    5987             : static const zend_function_entry reflection_property_functions[] = {
    5988             :         ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
    5989             :         ZEND_ME(reflection_property, export, arginfo_reflection_property_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
    5990             :         ZEND_ME(reflection_property, __construct, arginfo_reflection_property___construct, 0)
    5991             :         ZEND_ME(reflection_property, __toString, arginfo_reflection__void, 0)
    5992             :         ZEND_ME(reflection_property, getName, arginfo_reflection__void, 0)
    5993             :         ZEND_ME(reflection_property, getValue, arginfo_reflection_property_getValue, 0)
    5994             :         ZEND_ME(reflection_property, setValue, arginfo_reflection_property_setValue, 0)
    5995             :         ZEND_ME(reflection_property, isPublic, arginfo_reflection__void, 0)
    5996             :         ZEND_ME(reflection_property, isPrivate, arginfo_reflection__void, 0)
    5997             :         ZEND_ME(reflection_property, isProtected, arginfo_reflection__void, 0)
    5998             :         ZEND_ME(reflection_property, isStatic, arginfo_reflection__void, 0)
    5999             :         ZEND_ME(reflection_property, isDefault, arginfo_reflection__void, 0)
    6000             :         ZEND_ME(reflection_property, getModifiers, arginfo_reflection__void, 0)
    6001             :         ZEND_ME(reflection_property, getDeclaringClass, arginfo_reflection__void, 0)
    6002             :         ZEND_ME(reflection_property, getDocComment, arginfo_reflection__void, 0)
    6003             :         ZEND_ME(reflection_property, setAccessible, arginfo_reflection_property_setAccessible, 0)
    6004             :         PHP_FE_END
    6005             : };
    6006             : 
    6007             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_parameter_export, 0, 0, 2)
    6008             :         ZEND_ARG_INFO(0, function)
    6009             :         ZEND_ARG_INFO(0, parameter)
    6010             :         ZEND_ARG_INFO(0, return)
    6011             : ZEND_END_ARG_INFO()
    6012             : 
    6013             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_parameter___construct, 0)
    6014             :         ZEND_ARG_INFO(0, function)
    6015             :         ZEND_ARG_INFO(0, parameter)
    6016             : ZEND_END_ARG_INFO()
    6017             : 
    6018             : static const zend_function_entry reflection_parameter_functions[] = {
    6019             :         ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
    6020             :         ZEND_ME(reflection_parameter, export, arginfo_reflection_parameter_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
    6021             :         ZEND_ME(reflection_parameter, __construct, arginfo_reflection_parameter___construct, 0)
    6022             :         ZEND_ME(reflection_parameter, __toString, arginfo_reflection__void, 0)
    6023             :         ZEND_ME(reflection_parameter, getName, arginfo_reflection__void, 0)
    6024             :         ZEND_ME(reflection_parameter, isPassedByReference, arginfo_reflection__void, 0)
    6025             :         ZEND_ME(reflection_parameter, canBePassedByValue, arginfo_reflection__void, 0)
    6026             :         ZEND_ME(reflection_parameter, getDeclaringFunction, arginfo_reflection__void, 0)
    6027             :         ZEND_ME(reflection_parameter, getDeclaringClass, arginfo_reflection__void, 0)
    6028             :         ZEND_ME(reflection_parameter, getClass, arginfo_reflection__void, 0)
    6029             :         ZEND_ME(reflection_parameter, isArray, arginfo_reflection__void, 0)
    6030             :         ZEND_ME(reflection_parameter, isCallable, arginfo_reflection__void, 0)
    6031             :         ZEND_ME(reflection_parameter, allowsNull, arginfo_reflection__void, 0)
    6032             :         ZEND_ME(reflection_parameter, getPosition, arginfo_reflection__void, 0)
    6033             :         ZEND_ME(reflection_parameter, isOptional, arginfo_reflection__void, 0)
    6034             :         ZEND_ME(reflection_parameter, isDefaultValueAvailable, arginfo_reflection__void, 0)
    6035             :         ZEND_ME(reflection_parameter, getDefaultValue, arginfo_reflection__void, 0)
    6036             :         ZEND_ME(reflection_parameter, isDefaultValueConstant, arginfo_reflection__void, 0)
    6037             :         ZEND_ME(reflection_parameter, getDefaultValueConstantName, arginfo_reflection__void, 0)
    6038             :         ZEND_ME(reflection_parameter, isVariadic, arginfo_reflection__void, 0)
    6039             :         PHP_FE_END
    6040             : };
    6041             : 
    6042             : ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_extension_export, 0, 0, 1)
    6043             :         ZEND_ARG_INFO(0, name)
    6044             :         ZEND_ARG_INFO(0, return)
    6045             : ZEND_END_ARG_INFO()
    6046             : 
    6047             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_extension___construct, 0)
    6048             :         ZEND_ARG_INFO(0, name)
    6049             : ZEND_END_ARG_INFO()
    6050             : 
    6051             : static const zend_function_entry reflection_extension_functions[] = {
    6052             :         ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
    6053             :         ZEND_ME(reflection_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
    6054             :         ZEND_ME(reflection_extension, __construct, arginfo_reflection_extension___construct, 0)
    6055             :         ZEND_ME(reflection_extension, __toString, arginfo_reflection__void, 0)
    6056             :         ZEND_ME(reflection_extension, getName, arginfo_reflection__void, 0)
    6057             :         ZEND_ME(reflection_extension, getVersion, arginfo_reflection__void, 0)
    6058             :         ZEND_ME(reflection_extension, getFunctions, arginfo_reflection__void, 0)
    6059             :         ZEND_ME(reflection_extension, getConstants, arginfo_reflection__void, 0)
    6060             :         ZEND_ME(reflection_extension, getINIEntries, arginfo_reflection__void, 0)
    6061             :         ZEND_ME(reflection_extension, getClasses, arginfo_reflection__void, 0)
    6062             :         ZEND_ME(reflection_extension, getClassNames, arginfo_reflection__void, 0)
    6063             :         ZEND_ME(reflection_extension, getDependencies, arginfo_reflection__void, 0)
    6064             :         ZEND_ME(reflection_extension, info, arginfo_reflection__void, 0)
    6065             :         ZEND_ME(reflection_extension, isPersistent, arginfo_reflection__void, 0)
    6066             :         ZEND_ME(reflection_extension, isTemporary, arginfo_reflection__void, 0)
    6067             :         PHP_FE_END
    6068             : };
    6069             : 
    6070             : ZEND_BEGIN_ARG_INFO(arginfo_reflection_zend_extension___construct, 0)
    6071             :         ZEND_ARG_INFO(0, name)
    6072             : ZEND_END_ARG_INFO()
    6073             : 
    6074             : static const zend_function_entry reflection_zend_extension_functions[] = {
    6075             :         ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
    6076             :         ZEND_ME(reflection_zend_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
    6077             :         ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_extension___construct, 0)
    6078             :         ZEND_ME(reflection_zend_extension, __toString, arginfo_reflection__void, 0)
    6079             :         ZEND_ME(reflection_zend_extension, getName, arginfo_reflection__void, 0)
    6080             :         ZEND_ME(reflection_zend_extension, getVersion, arginfo_reflection__void, 0)
    6081             :         ZEND_ME(reflection_zend_extension, getAuthor, arginfo_reflection__void, 0)
    6082             :         ZEND_ME(reflection_zend_extension, getURL, arginfo_reflection__void, 0)
    6083             :         ZEND_ME(reflection_zend_extension, getCopyright, arginfo_reflection__void, 0)
    6084             :         PHP_FE_END
    6085             : };
    6086             : /* }}} */
    6087             : 
    6088             : const zend_function_entry reflection_ext_functions[] = { /* {{{ */
    6089             :         PHP_FE_END
    6090             : }; /* }}} */
    6091             : 
    6092             : static zend_object_handlers *zend_std_obj_handlers;
    6093             : 
    6094             : /* {{{ _reflection_write_property */
    6095           0 : static void _reflection_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC)
    6096             : {
    6097           0 :         if ((Z_TYPE_P(member) == IS_STRING)
    6098           0 :                 && zend_hash_exists(&Z_OBJCE_P(object)->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)
    6099           0 :                 && ((Z_STRLEN_P(member) == sizeof("name") - 1  && !memcmp(Z_STRVAL_P(member), "name",  sizeof("name")))
    6100           0 :                         || (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class")))))
    6101             :         {
    6102           0 :                 zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
    6103           0 :                         "Cannot set read-only property %s::$%s", Z_OBJCE_P(object)->name, Z_STRVAL_P(member));
    6104             :         }
    6105             :         else
    6106             :         {
    6107           0 :                 zend_std_obj_handlers->write_property(object, member, value, key TSRMLS_CC);
    6108             :         }
    6109           0 : }
    6110             : /* }}} */
    6111             : 
    6112           0 : PHP_MINIT_FUNCTION(reflection) /* {{{ */
    6113             : {
    6114             :         zend_class_entry _reflection_entry;
    6115             : 
    6116           0 :         zend_std_obj_handlers = zend_get_std_object_handlers();
    6117           0 :         memcpy(&reflection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
    6118           0 :         reflection_object_handlers.clone_obj = NULL;
    6119           0 :         reflection_object_handlers.write_property = _reflection_write_property;
    6120             : 
    6121           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionException", reflection_exception_functions);
    6122           0 :         reflection_exception_ptr = zend_register_internal_class_ex(&_reflection_entry, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
    6123             : 
    6124           0 :         INIT_CLASS_ENTRY(_reflection_entry, "Reflection", reflection_functions);
    6125           0 :         reflection_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
    6126             : 
    6127           0 :         INIT_CLASS_ENTRY(_reflection_entry, "Reflector", reflector_functions);
    6128           0 :         reflector_ptr = zend_register_internal_interface(&_reflection_entry TSRMLS_CC);
    6129             : 
    6130           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunctionAbstract", reflection_function_abstract_functions);
    6131           0 :         _reflection_entry.create_object = reflection_objects_new;
    6132           0 :         reflection_function_abstract_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
    6133           0 :         reflection_register_implement(reflection_function_abstract_ptr, reflector_ptr TSRMLS_CC);
    6134           0 :         zend_declare_property_string(reflection_function_abstract_ptr, "name", sizeof("name")-1, "", ZEND_ACC_ABSTRACT TSRMLS_CC);
    6135             : 
    6136           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunction", reflection_function_functions);
    6137           0 :         _reflection_entry.create_object = reflection_objects_new;
    6138           0 :         reflection_function_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr, NULL TSRMLS_CC);
    6139           0 :         zend_declare_property_string(reflection_function_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
    6140             : 
    6141           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(function, "IS_DEPRECATED", ZEND_ACC_DEPRECATED);
    6142             : 
    6143           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionParameter", reflection_parameter_functions);
    6144           0 :         _reflection_entry.create_object = reflection_objects_new;
    6145           0 :         reflection_parameter_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
    6146           0 :         reflection_register_implement(reflection_parameter_ptr, reflector_ptr TSRMLS_CC);
    6147           0 :         zend_declare_property_string(reflection_parameter_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
    6148             : 
    6149           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionMethod", reflection_method_functions);
    6150           0 :         _reflection_entry.create_object = reflection_objects_new;
    6151           0 :         reflection_method_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr, NULL TSRMLS_CC);
    6152           0 :         zend_declare_property_string(reflection_method_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
    6153           0 :         zend_declare_property_string(reflection_method_ptr, "class", sizeof("class")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
    6154             : 
    6155           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_STATIC", ZEND_ACC_STATIC);
    6156           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_PUBLIC", ZEND_ACC_PUBLIC);
    6157           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_PROTECTED", ZEND_ACC_PROTECTED);
    6158           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_PRIVATE", ZEND_ACC_PRIVATE);
    6159           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_ABSTRACT", ZEND_ACC_ABSTRACT);
    6160           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_FINAL", ZEND_ACC_FINAL);
    6161             : 
    6162           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionClass", reflection_class_functions);
    6163           0 :         _reflection_entry.create_object = reflection_objects_new;
    6164           0 :         reflection_class_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
    6165           0 :         reflection_register_implement(reflection_class_ptr, reflector_ptr TSRMLS_CC);
    6166           0 :         zend_declare_property_string(reflection_class_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
    6167             : 
    6168           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_IMPLICIT_ABSTRACT", ZEND_ACC_IMPLICIT_ABSTRACT_CLASS);
    6169           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_EXPLICIT_ABSTRACT", ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
    6170           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_FINAL", ZEND_ACC_FINAL_CLASS);
    6171             : 
    6172           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionObject", reflection_object_functions);
    6173           0 :         _reflection_entry.create_object = reflection_objects_new;
    6174           0 :         reflection_object_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_class_ptr, NULL TSRMLS_CC);
    6175             : 
    6176           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionProperty", reflection_property_functions);
    6177           0 :         _reflection_entry.create_object = reflection_objects_new;
    6178           0 :         reflection_property_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
    6179           0 :         reflection_register_implement(reflection_property_ptr, reflector_ptr TSRMLS_CC);
    6180           0 :         zend_declare_property_string(reflection_property_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
    6181           0 :         zend_declare_property_string(reflection_property_ptr, "class", sizeof("class")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
    6182             : 
    6183           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_STATIC", ZEND_ACC_STATIC);
    6184           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PUBLIC", ZEND_ACC_PUBLIC);
    6185           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PROTECTED", ZEND_ACC_PROTECTED);
    6186           0 :         REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PRIVATE", ZEND_ACC_PRIVATE);
    6187             : 
    6188           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionExtension", reflection_extension_functions);
    6189           0 :         _reflection_entry.create_object = reflection_objects_new;
    6190           0 :         reflection_extension_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
    6191           0 :         reflection_register_implement(reflection_extension_ptr, reflector_ptr TSRMLS_CC);
    6192           0 :         zend_declare_property_string(reflection_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
    6193             : 
    6194           0 :         INIT_CLASS_ENTRY(_reflection_entry, "ReflectionZendExtension", reflection_zend_extension_functions);
    6195           0 :         _reflection_entry.create_object = reflection_objects_new;
    6196           0 :         reflection_zend_extension_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
    6197           0 :         reflection_register_implement(reflection_zend_extension_ptr, reflector_ptr TSRMLS_CC);
    6198           0 :         zend_declare_property_string(reflection_zend_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
    6199             : 
    6200           0 :         return SUCCESS;
    6201             : } /* }}} */
    6202             : 
    6203           0 : PHP_MINFO_FUNCTION(reflection) /* {{{ */
    6204             : {
    6205           0 :         php_info_print_table_start();
    6206           0 :         php_info_print_table_header(2, "Reflection", "enabled");
    6207             : 
    6208           0 :         php_info_print_table_row(2, "Version", "$Id: 703e14113f05c361a7257390f119030d32900b40 $");
    6209             : 
    6210           0 :         php_info_print_table_end();
    6211           0 : } /* }}} */
    6212             : 
    6213             : zend_module_entry reflection_module_entry = { /* {{{ */
    6214             :         STANDARD_MODULE_HEADER,
    6215             :         "Reflection",
    6216             :         reflection_ext_functions,
    6217             :         PHP_MINIT(reflection),
    6218             :         NULL,
    6219             :         NULL,
    6220             :         NULL,
    6221             :         PHP_MINFO(reflection),
    6222             :         "$Id: 703e14113f05c361a7257390f119030d32900b40 $",
    6223             :         STANDARD_MODULE_PROPERTIES
    6224             : }; /* }}} */
    6225             : 
    6226             : /*
    6227             :  * Local variables:
    6228             :  * tab-width: 4
    6229             :  * c-basic-offset: 4
    6230             :  * indent-tabs-mode: t
    6231             :  * End:
    6232             :  * vim600: noet sw=4 ts=4 fdm=marker
    6233             :  */

Generated by: LCOV version 1.10

Generated at Wed, 16 Apr 2014 12:47:55 +0000 (8 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.