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

Generated by: LCOV version 1.10

Generated at Mon, 04 Aug 2014 15:49:11 +0000 (25 days ago)

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