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: 2463 2800 88.0 %
Date: 2015-09-02 Functions: 212 224 94.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10

Generated at Wed, 02 Sep 2015 17:19:17 +0000 (32 hours ago)

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