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 - Zend - zend_builtin_functions.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 1040 1147 90.7 %
Date: 2016-07-26 Functions: 67 68 98.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16             :    |          Zeev Suraski <zeev@zend.com>                                |
      17             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #include "zend.h"
      23             : #include "zend_API.h"
      24             : #include "zend_builtin_functions.h"
      25             : #include "zend_constants.h"
      26             : #include "zend_ini.h"
      27             : #include "zend_exceptions.h"
      28             : #include "zend_extensions.h"
      29             : #include "zend_closures.h"
      30             : #include "zend_generators.h"
      31             : 
      32             : #undef ZEND_TEST_EXCEPTIONS
      33             : 
      34             : #if ZEND_DEBUG
      35             : static zend_class_entry *zend_test_interface;
      36             : static zend_class_entry *zend_test_class;
      37             : static zend_object_handlers zend_test_class_handlers;
      38             : #endif
      39             : 
      40             : static ZEND_FUNCTION(zend_version);
      41             : static ZEND_FUNCTION(func_num_args);
      42             : static ZEND_FUNCTION(func_get_arg);
      43             : static ZEND_FUNCTION(func_get_args);
      44             : static ZEND_FUNCTION(strlen);
      45             : static ZEND_FUNCTION(strcmp);
      46             : static ZEND_FUNCTION(strncmp);
      47             : static ZEND_FUNCTION(strcasecmp);
      48             : static ZEND_FUNCTION(strncasecmp);
      49             : static ZEND_FUNCTION(each);
      50             : static ZEND_FUNCTION(error_reporting);
      51             : static ZEND_FUNCTION(define);
      52             : static ZEND_FUNCTION(defined);
      53             : static ZEND_FUNCTION(get_class);
      54             : static ZEND_FUNCTION(get_called_class);
      55             : static ZEND_FUNCTION(get_parent_class);
      56             : static ZEND_FUNCTION(method_exists);
      57             : static ZEND_FUNCTION(property_exists);
      58             : static ZEND_FUNCTION(class_exists);
      59             : static ZEND_FUNCTION(interface_exists);
      60             : static ZEND_FUNCTION(trait_exists);
      61             : static ZEND_FUNCTION(function_exists);
      62             : static ZEND_FUNCTION(class_alias);
      63             : #if ZEND_DEBUG
      64             : static ZEND_FUNCTION(leak);
      65             : static ZEND_FUNCTION(leak_variable);
      66             : #ifdef ZEND_TEST_EXCEPTIONS
      67             : static ZEND_FUNCTION(crash);
      68             : #endif
      69             : #endif
      70             : static ZEND_FUNCTION(get_included_files);
      71             : static ZEND_FUNCTION(is_subclass_of);
      72             : static ZEND_FUNCTION(is_a);
      73             : static ZEND_FUNCTION(get_class_vars);
      74             : static ZEND_FUNCTION(get_object_vars);
      75             : static ZEND_FUNCTION(get_class_methods);
      76             : static ZEND_FUNCTION(trigger_error);
      77             : static ZEND_FUNCTION(set_error_handler);
      78             : static ZEND_FUNCTION(restore_error_handler);
      79             : static ZEND_FUNCTION(set_exception_handler);
      80             : static ZEND_FUNCTION(restore_exception_handler);
      81             : static ZEND_FUNCTION(get_declared_classes);
      82             : static ZEND_FUNCTION(get_declared_traits);
      83             : static ZEND_FUNCTION(get_declared_interfaces);
      84             : static ZEND_FUNCTION(get_defined_functions);
      85             : static ZEND_FUNCTION(get_defined_vars);
      86             : static ZEND_FUNCTION(create_function);
      87             : static ZEND_FUNCTION(get_resource_type);
      88             : static ZEND_FUNCTION(get_resources);
      89             : static ZEND_FUNCTION(get_loaded_extensions);
      90             : static ZEND_FUNCTION(extension_loaded);
      91             : static ZEND_FUNCTION(get_extension_funcs);
      92             : static ZEND_FUNCTION(get_defined_constants);
      93             : static ZEND_FUNCTION(debug_backtrace);
      94             : static ZEND_FUNCTION(debug_print_backtrace);
      95             : #if ZEND_DEBUG
      96             : static ZEND_FUNCTION(zend_test_func);
      97             : static ZEND_FUNCTION(zend_test_func2);
      98             : #ifdef ZTS
      99             : static ZEND_FUNCTION(zend_thread_id);
     100             : #endif
     101             : #endif
     102             : static ZEND_FUNCTION(gc_mem_caches);
     103             : static ZEND_FUNCTION(gc_collect_cycles);
     104             : static ZEND_FUNCTION(gc_enabled);
     105             : static ZEND_FUNCTION(gc_enable);
     106             : static ZEND_FUNCTION(gc_disable);
     107             : 
     108             : /* {{{ arginfo */
     109             : ZEND_BEGIN_ARG_INFO(arginfo_zend__void, 0)
     110             : ZEND_END_ARG_INFO()
     111             : 
     112             : ZEND_BEGIN_ARG_INFO_EX(arginfo_func_get_arg, 0, 0, 1)
     113             :         ZEND_ARG_INFO(0, arg_num)
     114             : ZEND_END_ARG_INFO()
     115             : 
     116             : ZEND_BEGIN_ARG_INFO_EX(arginfo_strlen, 0, 0, 1)
     117             :         ZEND_ARG_INFO(0, str)
     118             : ZEND_END_ARG_INFO()
     119             : 
     120             : ZEND_BEGIN_ARG_INFO_EX(arginfo_strcmp, 0, 0, 2)
     121             :         ZEND_ARG_INFO(0, str1)
     122             :         ZEND_ARG_INFO(0, str2)
     123             : ZEND_END_ARG_INFO()
     124             : 
     125             : ZEND_BEGIN_ARG_INFO_EX(arginfo_strncmp, 0, 0, 3)
     126             :         ZEND_ARG_INFO(0, str1)
     127             :         ZEND_ARG_INFO(0, str2)
     128             :         ZEND_ARG_INFO(0, len)
     129             : ZEND_END_ARG_INFO()
     130             : 
     131             : ZEND_BEGIN_ARG_INFO_EX(arginfo_each, 0, 0, 1)
     132             :         ZEND_ARG_INFO(1, arr)
     133             : ZEND_END_ARG_INFO()
     134             : 
     135             : ZEND_BEGIN_ARG_INFO_EX(arginfo_error_reporting, 0, 0, 0)
     136             :         ZEND_ARG_INFO(0, new_error_level)
     137             : ZEND_END_ARG_INFO()
     138             : 
     139             : ZEND_BEGIN_ARG_INFO_EX(arginfo_define, 0, 0, 2)
     140             :         ZEND_ARG_INFO(0, constant_name)
     141             :         ZEND_ARG_INFO(0, value)
     142             :         ZEND_ARG_INFO(0, case_insensitive)
     143             : ZEND_END_ARG_INFO()
     144             : 
     145             : ZEND_BEGIN_ARG_INFO_EX(arginfo_defined, 0, 0, 1)
     146             :         ZEND_ARG_INFO(0, constant_name)
     147             : ZEND_END_ARG_INFO()
     148             : 
     149             : ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class, 0, 0, 0)
     150             :         ZEND_ARG_INFO(0, object)
     151             : ZEND_END_ARG_INFO()
     152             : 
     153             : ZEND_BEGIN_ARG_INFO_EX(arginfo_is_subclass_of, 0, 0, 2)
     154             :         ZEND_ARG_INFO(0, object)
     155             :         ZEND_ARG_INFO(0, class_name)
     156             :         ZEND_ARG_INFO(0, allow_string)
     157             : ZEND_END_ARG_INFO()
     158             : 
     159             : ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_vars, 0, 0, 1)
     160             :         ZEND_ARG_INFO(0, class_name)
     161             : ZEND_END_ARG_INFO()
     162             : 
     163             : ZEND_BEGIN_ARG_INFO_EX(arginfo_get_object_vars, 0, 0, 1)
     164             :         ZEND_ARG_INFO(0, obj)
     165             : ZEND_END_ARG_INFO()
     166             : 
     167             : ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_methods, 0, 0, 1)
     168             :         ZEND_ARG_INFO(0, class)
     169             : ZEND_END_ARG_INFO()
     170             : 
     171             : ZEND_BEGIN_ARG_INFO_EX(arginfo_method_exists, 0, 0, 2)
     172             :         ZEND_ARG_INFO(0, object)
     173             :         ZEND_ARG_INFO(0, method)
     174             : ZEND_END_ARG_INFO()
     175             : 
     176             : ZEND_BEGIN_ARG_INFO_EX(arginfo_property_exists, 0, 0, 2)
     177             :         ZEND_ARG_INFO(0, object_or_class)
     178             :         ZEND_ARG_INFO(0, property_name)
     179             : ZEND_END_ARG_INFO()
     180             : 
     181             : ZEND_BEGIN_ARG_INFO_EX(arginfo_class_exists, 0, 0, 1)
     182             :         ZEND_ARG_INFO(0, classname)
     183             :         ZEND_ARG_INFO(0, autoload)
     184             : ZEND_END_ARG_INFO()
     185             : 
     186             : ZEND_BEGIN_ARG_INFO_EX(arginfo_trait_exists, 0, 0, 1)
     187             :         ZEND_ARG_INFO(0, traitname)
     188             :         ZEND_ARG_INFO(0, autoload)
     189             : ZEND_END_ARG_INFO()
     190             : 
     191             : ZEND_BEGIN_ARG_INFO_EX(arginfo_function_exists, 0, 0, 1)
     192             :         ZEND_ARG_INFO(0, function_name)
     193             : ZEND_END_ARG_INFO()
     194             : 
     195             : ZEND_BEGIN_ARG_INFO_EX(arginfo_class_alias, 0, 0, 2)
     196             :         ZEND_ARG_INFO(0, user_class_name)
     197             :         ZEND_ARG_INFO(0, alias_name)
     198             :         ZEND_ARG_INFO(0, autoload)
     199             : ZEND_END_ARG_INFO()
     200             : 
     201             : #if ZEND_DEBUG
     202             : ZEND_BEGIN_ARG_INFO_EX(arginfo_leak_variable, 0, 0, 1)
     203             :         ZEND_ARG_INFO(0, variable)
     204             :         ZEND_ARG_INFO(0, leak_data)
     205             : ZEND_END_ARG_INFO()
     206             : #endif
     207             : 
     208             : ZEND_BEGIN_ARG_INFO_EX(arginfo_trigger_error, 0, 0, 1)
     209             :         ZEND_ARG_INFO(0, message)
     210             :         ZEND_ARG_INFO(0, error_type)
     211             : ZEND_END_ARG_INFO()
     212             : 
     213             : ZEND_BEGIN_ARG_INFO_EX(arginfo_set_error_handler, 0, 0, 1)
     214             :         ZEND_ARG_INFO(0, error_handler)
     215             :         ZEND_ARG_INFO(0, error_types)
     216             : ZEND_END_ARG_INFO()
     217             : 
     218             : ZEND_BEGIN_ARG_INFO_EX(arginfo_set_exception_handler, 0, 0, 1)
     219             :         ZEND_ARG_INFO(0, exception_handler)
     220             : ZEND_END_ARG_INFO()
     221             : 
     222             : ZEND_BEGIN_ARG_INFO_EX(arginfo_create_function, 0, 0, 2)
     223             :         ZEND_ARG_INFO(0, args)
     224             :         ZEND_ARG_INFO(0, code)
     225             : ZEND_END_ARG_INFO()
     226             : 
     227             : ZEND_BEGIN_ARG_INFO_EX(arginfo_get_resource_type, 0, 0, 1)
     228             :         ZEND_ARG_INFO(0, res)
     229             : ZEND_END_ARG_INFO()
     230             : 
     231             : ZEND_BEGIN_ARG_INFO_EX(arginfo_get_resources, 0, 0, 0)
     232             :         ZEND_ARG_INFO(0, type)
     233             : ZEND_END_ARG_INFO()
     234             : 
     235             : ZEND_BEGIN_ARG_INFO_EX(arginfo_get_loaded_extensions, 0, 0, 0)
     236             :         ZEND_ARG_INFO(0, zend_extensions)
     237             : ZEND_END_ARG_INFO()
     238             : 
     239             : ZEND_BEGIN_ARG_INFO_EX(arginfo_get_defined_constants, 0, 0, 0)
     240             :         ZEND_ARG_INFO(0, categorize)
     241             : ZEND_END_ARG_INFO()
     242             : 
     243             : ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_backtrace, 0, 0, 0)
     244             :         ZEND_ARG_INFO(0, options)
     245             :         ZEND_ARG_INFO(0, limit)
     246             : ZEND_END_ARG_INFO()
     247             : 
     248             : ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_print_backtrace, 0, 0, 0)
     249             :         ZEND_ARG_INFO(0, options)
     250             :         ZEND_ARG_INFO(0, limit)
     251             : ZEND_END_ARG_INFO()
     252             : 
     253             : ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1)
     254             :         ZEND_ARG_INFO(0, extension_name)
     255             : ZEND_END_ARG_INFO()
     256             : 
     257             : #if ZEND_DEBUG
     258             : ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func, IS_ARRAY, NULL, 0)
     259             : ZEND_END_ARG_INFO()
     260             : ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func2, IS_ARRAY, NULL, 1)
     261             : ZEND_END_ARG_INFO()
     262             : #endif
     263             : 
     264             : /* }}} */
     265             : 
     266             : #if ZEND_DEBUG
     267             : static zend_object *zend_test_class_new(zend_class_entry *class_type) /* {{{ */ {
     268             :         zend_object *obj = zend_objects_new(class_type);
     269             :         obj->handlers = &zend_test_class_handlers;
     270             :         return obj;
     271             : }
     272             : /* }}} */
     273             : 
     274             : static zend_function *zend_test_class_method_get(zend_object **object, zend_string *name, const zval *key) /* {{{ */ {
     275             :         zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
     276             :         fptr->type = ZEND_OVERLOADED_FUNCTION_TEMPORARY;
     277             :         fptr->num_args = 1;
     278             :         fptr->arg_info = NULL;
     279             :         fptr->scope = (*object)->ce;
     280             :         fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
     281             :         fptr->function_name = zend_string_copy(name);
     282             :         fptr->handler = ZEND_FN(zend_test_func);
     283             :         zend_set_function_arg_flags((zend_function*)fptr);
     284             : 
     285             :         return (zend_function*)fptr;
     286             : }
     287             : /* }}} */
     288             : 
     289             : static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, zend_string *name) /* {{{ */ {
     290             :         zend_internal_function *fptr = emalloc(sizeof(zend_internal_function));
     291             :         fptr->type = ZEND_OVERLOADED_FUNCTION;
     292             :         fptr->num_args = 1;
     293             :         fptr->arg_info = NULL;
     294             :         fptr->scope = ce;
     295             :         fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC;
     296             :         fptr->function_name = name;
     297             :         fptr->handler = ZEND_FN(zend_test_func);
     298             :         zend_set_function_arg_flags((zend_function*)fptr);
     299             : 
     300             :         return (zend_function*)fptr;
     301             : }
     302             : /* }}} */
     303             : 
     304             : static int zend_test_class_call_method(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ {
     305             :         RETVAL_STR(zend_string_copy(method));
     306             :         return 0;
     307             : }
     308             : /* }}} */
     309             : #endif
     310             : 
     311             : static const zend_function_entry builtin_functions[] = { /* {{{ */
     312             :         ZEND_FE(zend_version,           arginfo_zend__void)
     313             :         ZEND_FE(func_num_args,          arginfo_zend__void)
     314             :         ZEND_FE(func_get_arg,           arginfo_func_get_arg)
     315             :         ZEND_FE(func_get_args,          arginfo_zend__void)
     316             :         ZEND_FE(strlen,                 arginfo_strlen)
     317             :         ZEND_FE(strcmp,                 arginfo_strcmp)
     318             :         ZEND_FE(strncmp,                arginfo_strncmp)
     319             :         ZEND_FE(strcasecmp,             arginfo_strcmp)
     320             :         ZEND_FE(strncasecmp,            arginfo_strncmp)
     321             :         ZEND_FE(each,                   arginfo_each)
     322             :         ZEND_FE(error_reporting,        arginfo_error_reporting)
     323             :         ZEND_FE(define,                 arginfo_define)
     324             :         ZEND_FE(defined,                arginfo_defined)
     325             :         ZEND_FE(get_class,              arginfo_get_class)
     326             :         ZEND_FE(get_called_class,       arginfo_zend__void)
     327             :         ZEND_FE(get_parent_class,       arginfo_get_class)
     328             :         ZEND_FE(method_exists,          arginfo_method_exists)
     329             :         ZEND_FE(property_exists,        arginfo_property_exists)
     330             :         ZEND_FE(class_exists,           arginfo_class_exists)
     331             :         ZEND_FE(interface_exists,       arginfo_class_exists)
     332             :         ZEND_FE(trait_exists,           arginfo_trait_exists)
     333             :         ZEND_FE(function_exists,        arginfo_function_exists)
     334             :         ZEND_FE(class_alias,            arginfo_class_alias)
     335             : #if ZEND_DEBUG
     336             :         ZEND_FE(leak,                           NULL)
     337             :         ZEND_FE(leak_variable,          arginfo_leak_variable)
     338             : #ifdef ZEND_TEST_EXCEPTIONS
     339             :         ZEND_FE(crash,                          NULL)
     340             : #endif
     341             : #endif
     342             :         ZEND_FE(get_included_files,     arginfo_zend__void)
     343             :         ZEND_FALIAS(get_required_files, get_included_files,             arginfo_zend__void)
     344             :         ZEND_FE(is_subclass_of,         arginfo_is_subclass_of)
     345             :         ZEND_FE(is_a,                   arginfo_is_subclass_of)
     346             :         ZEND_FE(get_class_vars,         arginfo_get_class_vars)
     347             :         ZEND_FE(get_object_vars,        arginfo_get_object_vars)
     348             :         ZEND_FE(get_class_methods,      arginfo_get_class_methods)
     349             :         ZEND_FE(trigger_error,          arginfo_trigger_error)
     350             :         ZEND_FALIAS(user_error,         trigger_error,          arginfo_trigger_error)
     351             :         ZEND_FE(set_error_handler,              arginfo_set_error_handler)
     352             :         ZEND_FE(restore_error_handler,          arginfo_zend__void)
     353             :         ZEND_FE(set_exception_handler,          arginfo_set_exception_handler)
     354             :         ZEND_FE(restore_exception_handler,      arginfo_zend__void)
     355             :         ZEND_FE(get_declared_classes,           arginfo_zend__void)
     356             :         ZEND_FE(get_declared_traits,            arginfo_zend__void)
     357             :         ZEND_FE(get_declared_interfaces,        arginfo_zend__void)
     358             :         ZEND_FE(get_defined_functions,          arginfo_zend__void)
     359             :         ZEND_FE(get_defined_vars,               arginfo_zend__void)
     360             :         ZEND_FE(create_function,                arginfo_create_function)
     361             :         ZEND_FE(get_resource_type,              arginfo_get_resource_type)
     362             :         ZEND_FE(get_resources,                  arginfo_get_resources)
     363             :         ZEND_FE(get_loaded_extensions,          arginfo_get_loaded_extensions)
     364             :         ZEND_FE(extension_loaded,               arginfo_extension_loaded)
     365             :         ZEND_FE(get_extension_funcs,            arginfo_extension_loaded)
     366             :         ZEND_FE(get_defined_constants,          arginfo_get_defined_constants)
     367             :         ZEND_FE(debug_backtrace,                arginfo_debug_backtrace)
     368             :         ZEND_FE(debug_print_backtrace,          arginfo_debug_print_backtrace)
     369             : #if ZEND_DEBUG
     370             :         ZEND_FE(zend_test_func,         arginfo_zend_test_func)
     371             :         ZEND_FE(zend_test_func2,        arginfo_zend_test_func2)
     372             : #ifdef ZTS
     373             :         ZEND_FE(zend_thread_id,         NULL)
     374             : #endif
     375             : #endif
     376             :         ZEND_FE(gc_mem_caches,      arginfo_zend__void)
     377             :         ZEND_FE(gc_collect_cycles,      arginfo_zend__void)
     378             :         ZEND_FE(gc_enabled,             arginfo_zend__void)
     379             :         ZEND_FE(gc_enable,              arginfo_zend__void)
     380             :         ZEND_FE(gc_disable,             arginfo_zend__void)
     381             :         ZEND_FE_END
     382             : };
     383             : /* }}} */
     384             : 
     385       23453 : ZEND_MINIT_FUNCTION(core) { /* {{{ */
     386             :         zend_class_entry class_entry;
     387             : 
     388       23453 :         INIT_CLASS_ENTRY(class_entry, "stdClass", NULL);
     389       23453 :         zend_standard_class_def = zend_register_internal_class(&class_entry);
     390             : 
     391       23453 :         zend_register_default_classes();
     392             : 
     393             : #if ZEND_DEBUG
     394             :         INIT_CLASS_ENTRY(class_entry, "_ZendTestInterface", NULL);
     395             :         zend_test_interface = zend_register_internal_interface(&class_entry);
     396             :         zend_declare_class_constant_long(zend_test_interface, ZEND_STRL("DUMMY"), 0);
     397             :         INIT_CLASS_ENTRY(class_entry, "_ZendTestClass", NULL);
     398             :         zend_test_class = zend_register_internal_class_ex(&class_entry, NULL);
     399             :         zend_class_implements(zend_test_class, 1, zend_test_interface);
     400             :         zend_test_class->create_object = zend_test_class_new;
     401             :         zend_test_class->get_static_method = zend_test_class_static_method_get;
     402             : 
     403             :         memcpy(&zend_test_class_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
     404             :         zend_test_class_handlers.get_method = zend_test_class_method_get;
     405             :         zend_test_class_handlers.call_method = zend_test_class_call_method;
     406             : #endif
     407             : 
     408       23453 :         return SUCCESS;
     409             : }
     410             : /* }}} */
     411             : 
     412             : zend_module_entry zend_builtin_module = { /* {{{ */
     413             :     STANDARD_MODULE_HEADER,
     414             :         "Core",
     415             :         builtin_functions,
     416             :         ZEND_MINIT(core),
     417             :         NULL,
     418             :         NULL,
     419             :         NULL,
     420             :         NULL,
     421             :         ZEND_VERSION,
     422             :         STANDARD_MODULE_PROPERTIES
     423             : };
     424             : /* }}} */
     425             : 
     426       23453 : int zend_startup_builtin_functions(void) /* {{{ */
     427             : {
     428       23453 :         zend_builtin_module.module_number = 0;
     429       23453 :         zend_builtin_module.type = MODULE_PERSISTENT;
     430       23453 :         return (EG(current_module) = zend_register_module_ex(&zend_builtin_module)) == NULL ? FAILURE : SUCCESS;
     431             : }
     432             : /* }}} */
     433             : 
     434             : /* {{{ proto string zend_version(void)
     435             :    Get the version of the Zend Engine */
     436         142 : ZEND_FUNCTION(zend_version)
     437             : {
     438         284 :         RETURN_STRINGL(ZEND_VERSION, sizeof(ZEND_VERSION)-1);
     439             : }
     440             : /* }}} */
     441             : 
     442             : /* {{{ proto int gc_mem_caches(void)
     443             :    Reclaims memory used by MM caches.
     444             :    Returns number of freed bytes */
     445           0 : ZEND_FUNCTION(gc_mem_caches)
     446             : {
     447           0 :         RETURN_LONG(zend_mm_gc(zend_mm_get_heap()));
     448             : }
     449             : /* }}} */
     450             : 
     451             : /* {{{ proto int gc_collect_cycles(void)
     452             :    Forces collection of any existing garbage cycles.
     453             :    Returns number of freed zvals */
     454          67 : ZEND_FUNCTION(gc_collect_cycles)
     455             : {
     456          67 :         RETURN_LONG(gc_collect_cycles());
     457             : }
     458             : /* }}} */
     459             : 
     460             : /* {{{ proto void gc_enabled(void)
     461             :    Returns status of the circular reference collector */
     462           6 : ZEND_FUNCTION(gc_enabled)
     463             : {
     464           6 :         RETURN_BOOL(GC_G(gc_enabled));
     465             : }
     466             : /* }}} */
     467             : 
     468             : /* {{{ proto void gc_enable(void)
     469             :    Activates the circular reference collector */
     470           7 : ZEND_FUNCTION(gc_enable)
     471             : {
     472           7 :         zend_string *key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
     473           7 :         zend_alter_ini_entry_chars(key, "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
     474             :         zend_string_release(key);
     475           7 : }
     476             : /* }}} */
     477             : 
     478             : /* {{{ proto void gc_disable(void)
     479             :    Deactivates the circular reference collector */
     480           4 : ZEND_FUNCTION(gc_disable)
     481             : {
     482           4 :         zend_string *key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
     483           4 :         zend_alter_ini_entry_chars(key, "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
     484             :         zend_string_release(key);
     485           4 : }
     486             : /* }}} */
     487             : 
     488             : /* {{{ proto int func_num_args(void)
     489             :    Get the number of arguments that were passed to the function */
     490          15 : ZEND_FUNCTION(func_num_args)
     491             : {
     492          15 :         zend_execute_data *ex = EX(prev_execute_data);
     493             : 
     494          15 :         if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
     495           2 :                 zend_error(E_WARNING, "func_num_args():  Called from the global scope - no function context");
     496           2 :                 RETURN_LONG(-1);
     497             :         }
     498             : 
     499          13 :         if (zend_forbid_dynamic_call("func_num_args()") == FAILURE) {
     500           1 :                 RETURN_LONG(-1);
     501             :         }
     502             : 
     503          12 :         RETURN_LONG(ZEND_CALL_NUM_ARGS(ex));
     504             : }
     505             : /* }}} */
     506             : 
     507             : /* {{{ proto mixed func_get_arg(int arg_num)
     508             :    Get the $arg_num'th argument that was passed to the function */
     509          46 : ZEND_FUNCTION(func_get_arg)
     510             : {
     511             :         uint32_t arg_count, first_extra_arg;
     512             :         zval *arg;
     513             :         zend_long requested_offset;
     514             :         zend_execute_data *ex;
     515             : 
     516          46 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &requested_offset) == FAILURE) {
     517           5 :                 return;
     518             :         }
     519             : 
     520          41 :         if (requested_offset < 0) {
     521           4 :                 zend_error(E_WARNING, "func_get_arg():  The argument number should be >= 0");
     522           4 :                 RETURN_FALSE;
     523             :         }
     524             : 
     525          37 :         ex = EX(prev_execute_data);
     526          37 :         if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
     527           3 :                 zend_error(E_WARNING, "func_get_arg():  Called from the global scope - no function context");
     528           3 :                 RETURN_FALSE;
     529             :         }
     530             : 
     531          34 :         if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) {
     532           1 :                 RETURN_FALSE;
     533             :         }
     534             : 
     535          33 :         arg_count = ZEND_CALL_NUM_ARGS(ex);
     536             : 
     537          33 :         if ((zend_ulong)requested_offset >= arg_count) {
     538          12 :                 zend_error(E_WARNING, "func_get_arg():  Argument " ZEND_LONG_FMT " not passed to function", requested_offset);
     539          12 :                 RETURN_FALSE;
     540             :         }
     541             : 
     542          21 :         first_extra_arg = ex->func->op_array.num_args;
     543          28 :         if ((zend_ulong)requested_offset >= first_extra_arg && (ZEND_CALL_NUM_ARGS(ex) > first_extra_arg)) {
     544           7 :                 arg = ZEND_CALL_VAR_NUM(ex, ex->func->op_array.last_var + ex->func->op_array.T) + (requested_offset - first_extra_arg);
     545             :         } else {
     546          14 :                 arg = ZEND_CALL_ARG(ex, requested_offset + 1);
     547             :         }
     548          21 :         if (EXPECTED(!Z_ISUNDEF_P(arg))) {
     549          17 :                 ZVAL_DEREF(arg);
     550          17 :                 ZVAL_COPY(return_value, arg);
     551             :         }
     552             : }
     553             : /* }}} */
     554             : 
     555             : /* {{{ proto array func_get_args()
     556             :    Get an array of the arguments that were passed to the function */
     557          79 : ZEND_FUNCTION(func_get_args)
     558             : {
     559             :         zval *p, *q;
     560             :         uint32_t arg_count, first_extra_arg;
     561             :         uint32_t i, n;
     562          79 :         zend_execute_data *ex = EX(prev_execute_data);
     563             : 
     564          79 :         if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
     565           3 :                 zend_error(E_WARNING, "func_get_args():  Called from the global scope - no function context");
     566           3 :                 RETURN_FALSE;
     567             :         }
     568             : 
     569          76 :         if (zend_forbid_dynamic_call("func_get_args()") == FAILURE) {
     570           2 :                 RETURN_FALSE;
     571             :         }
     572             : 
     573          74 :         arg_count = ZEND_CALL_NUM_ARGS(ex);
     574             : 
     575          74 :         array_init_size(return_value, arg_count);
     576          74 :         if (arg_count) {
     577          54 :                 first_extra_arg = ex->func->op_array.num_args;
     578          54 :                 zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
     579          54 :                 ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
     580          54 :                         i = 0;
     581          54 :                         n = 0;
     582          54 :                         p = ZEND_CALL_ARG(ex, 1);
     583          54 :                         if (arg_count > first_extra_arg) {
     584          74 :                                 while (i < first_extra_arg) {
     585           8 :                                         q = p;
     586           8 :                                         if (EXPECTED(Z_TYPE_INFO_P(q) != IS_UNDEF)) {
     587           6 :                                                 ZVAL_DEREF(q);
     588           6 :                                                 if (Z_OPT_REFCOUNTED_P(q)) { 
     589             :                                                         Z_ADDREF_P(q);
     590             :                                                 }
     591           6 :                                                 n++;
     592             :                                         }
     593           8 :                                         ZEND_HASH_FILL_ADD(q);
     594           8 :                                         p++;
     595           8 :                                         i++;
     596             :                                 }
     597          33 :                                 p = ZEND_CALL_VAR_NUM(ex, ex->func->op_array.last_var + ex->func->op_array.T);
     598             :                         }
     599         185 :                         while (i < arg_count) {
     600          77 :                                 q = p;
     601          77 :                                 if (EXPECTED(Z_TYPE_INFO_P(q) != IS_UNDEF)) {
     602          77 :                                         ZVAL_DEREF(q);
     603          77 :                                         if (Z_OPT_REFCOUNTED_P(q)) { 
     604             :                                                 Z_ADDREF_P(q);
     605             :                                         }
     606          77 :                                         n++;
     607             :                                 }
     608          77 :                                 ZEND_HASH_FILL_ADD(q);
     609          77 :                                 p++;
     610          77 :                                 i++;
     611             :                         }
     612          54 :                 } ZEND_HASH_FILL_END();
     613          54 :                 Z_ARRVAL_P(return_value)->nNumOfElements = n;
     614             :         }
     615             : }
     616             : /* }}} */
     617             : 
     618             : /* {{{ proto int strlen(string str)
     619             :    Get string length
     620             :    Warning: This function is special-cased by zend_compile.c and so is usually bypassed */
     621         176 : ZEND_FUNCTION(strlen)
     622             : {
     623             :         zend_string *s;
     624             : 
     625             : #ifndef FAST_ZPP
     626             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &s) == FAILURE) {
     627             :                 return;
     628             :         }
     629             : #else
     630         176 :         ZEND_PARSE_PARAMETERS_START(1, 1)
     631         513 :                 Z_PARAM_STR(s)
     632         176 :         ZEND_PARSE_PARAMETERS_END();
     633             : #endif
     634             : 
     635         169 :         RETVAL_LONG(ZSTR_LEN(s));
     636             : }
     637             : /* }}} */
     638             : 
     639             : /* {{{ proto int strcmp(string str1, string str2)
     640             :    Binary safe string comparison */
     641      317056 : ZEND_FUNCTION(strcmp)
     642             : {
     643             :         zend_string *s1, *s2;
     644             : 
     645      317056 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &s1, &s2) == FAILURE) {
     646           5 :                 return;
     647             :         }
     648             : 
     649      317051 :         RETURN_LONG(zend_binary_strcmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2)));
     650             : }
     651             : /* }}} */
     652             : 
     653             : /* {{{ proto int strncmp(string str1, string str2, int len)
     654             :    Binary safe string comparison */
     655       16198 : ZEND_FUNCTION(strncmp)
     656             : {
     657             :         zend_string *s1, *s2;
     658             :         zend_long len;
     659             : 
     660       16198 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSl", &s1, &s2, &len) == FAILURE) {
     661          20 :                 return;
     662             :         }
     663             : 
     664       16178 :         if (len < 0) {
     665           3 :                 zend_error(E_WARNING, "Length must be greater than or equal to 0");
     666           3 :                 RETURN_FALSE;
     667             :         }
     668             : 
     669       16175 :         RETURN_LONG(zend_binary_strncmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2), len));
     670             : }
     671             : /* }}} */
     672             : 
     673             : /* {{{ proto int strcasecmp(string str1, string str2)
     674             :    Binary safe case-insensitive string comparison */
     675         777 : ZEND_FUNCTION(strcasecmp)
     676             : {
     677             :         zend_string *s1, *s2;
     678             : 
     679         777 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &s1, &s2) == FAILURE) {
     680           6 :                 return;
     681             :         }
     682             : 
     683         771 :         RETURN_LONG(zend_binary_strcasecmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2)));
     684             : }
     685             : /* }}} */
     686             : 
     687             : /* {{{ proto int strncasecmp(string str1, string str2, int len)
     688             :    Binary safe string comparison */
     689       22744 : ZEND_FUNCTION(strncasecmp)
     690             : {
     691             :         zend_string *s1, *s2;
     692             :         zend_long len;
     693             : 
     694       22744 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSl", &s1, &s2, &len) == FAILURE) {
     695          32 :                 return;
     696             :         }
     697             : 
     698       22712 :         if (len < 0) {
     699           3 :                 zend_error(E_WARNING, "Length must be greater than or equal to 0");
     700           3 :                 RETURN_FALSE;
     701             :         }
     702             : 
     703       22709 :         RETURN_LONG(zend_binary_strncasecmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2), len));
     704             : }
     705             : /* }}} */
     706             : 
     707             : /* {{{ proto mixed each(array &arr)
     708             :    Return the currently pointed key..value pair in the passed array, and advance the pointer to the next element, or false if there is no element at this place */
     709        1443 : ZEND_FUNCTION(each)
     710             : {
     711             :         zval *array, *entry, tmp;
     712             :         zend_ulong num_key;
     713             :         HashTable *target_hash;
     714             :         zend_string *key;
     715             : 
     716        1443 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "z/", &array) == FAILURE) {
     717           5 :                 return;
     718             :         }
     719             : 
     720        2911 :         target_hash = HASH_OF(array);
     721        1438 :         if (!target_hash) {
     722          29 :                 zend_error(E_WARNING,"Variable passed to each() is not an array or object");
     723          29 :                 return;
     724             :         }
     725             :         while (1) {
     726        1409 :                 entry = zend_hash_get_current_data(target_hash);
     727        1409 :                 if (!entry) {
     728          52 :                         RETURN_FALSE;
     729        1357 :                 } else if (Z_TYPE_P(entry) == IS_INDIRECT) {
     730           3 :                         entry = Z_INDIRECT_P(entry);
     731           3 :                         if (Z_TYPE_P(entry) == IS_UNDEF) {
     732           0 :                                 zend_hash_move_forward(target_hash);
     733           0 :                                 continue;
     734             :                         }
     735             :                 }
     736        1357 :                 break;
     737           0 :         }
     738        1357 :         array_init_size(return_value, 4);
     739        1357 :         zend_hash_real_init(Z_ARRVAL_P(return_value), 0);
     740             : 
     741             :         /* add value elements */
     742        1357 :         if (Z_ISREF_P(entry)) {
     743           3 :                 ZVAL_DUP(&tmp, Z_REFVAL_P(entry));
     744           3 :                 entry = &tmp;
     745           3 :                 if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
     746             :         } else {
     747        1354 :                 if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
     748        1354 :                 if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
     749             :         }
     750        1357 :         zend_hash_index_add_new(Z_ARRVAL_P(return_value), 1, entry);
     751        1357 :         zend_hash_add_new(Z_ARRVAL_P(return_value), CG(known_strings)[ZEND_STR_VALUE], entry);
     752             : 
     753             :         /* add the key elements */
     754        1357 :         if (zend_hash_get_current_key(target_hash, &key, &num_key) == HASH_KEY_IS_STRING) {
     755          36 :                 ZVAL_STR_COPY(&tmp, key);
     756          36 :                 if (Z_REFCOUNTED(tmp)) Z_ADDREF(tmp);
     757             :         } else {
     758        1321 :                 ZVAL_LONG(&tmp, num_key);
     759             :         }
     760        1357 :         zend_hash_index_add_new(Z_ARRVAL_P(return_value), 0, &tmp);
     761        1357 :         zend_hash_add_new(Z_ARRVAL_P(return_value), CG(known_strings)[ZEND_STR_KEY], &tmp);
     762        1357 :         zend_hash_move_forward(target_hash);
     763             : }
     764             : /* }}} */
     765             : 
     766             : /* {{{ proto int error_reporting([int new_error_level])
     767             :    Return the current error_reporting level, and if an argument was passed - change to the new level */
     768        2155 : ZEND_FUNCTION(error_reporting)
     769             : {
     770        2155 :         zval *err = NULL;
     771             :         int old_error_reporting;
     772             : 
     773             : #ifndef FAST_ZPP
     774             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &err) == FAILURE) {
     775             :                 return;
     776             :         }
     777             : #else
     778        2155 :         ZEND_PARSE_PARAMETERS_START(0, 1)
     779        2155 :                 Z_PARAM_OPTIONAL
     780        2155 :                 Z_PARAM_ZVAL(err)
     781        2155 :         ZEND_PARSE_PARAMETERS_END();
     782             : #endif
     783             : 
     784        2155 :         old_error_reporting = EG(error_reporting);
     785        2155 :         if (ZEND_NUM_ARGS() != 0) {
     786         759 :                 zend_string *new_val = zval_get_string(err);
     787             :                 do {
     788         379 :                         zend_ini_entry *p = EG(error_reporting_ini_entry);
     789             : 
     790         379 :                         if (!p) {
     791         620 :                                 p = zend_hash_find_ptr(EG(ini_directives), CG(known_strings)[ZEND_STR_ERROR_REPORTING]);
     792         310 :                                 if (p) {
     793         310 :                                         EG(error_reporting_ini_entry) = p;
     794             :                                 } else {
     795           0 :                                         break;
     796             :                                 }
     797             :                         }
     798         379 :                         if (!p->modified) {
     799         310 :                                 if (!EG(modified_ini_directives)) {
     800         306 :                                         ALLOC_HASHTABLE(EG(modified_ini_directives));
     801         306 :                                         zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
     802             :                                 }
     803         620 :                                 if (EXPECTED(zend_hash_add_ptr(EG(modified_ini_directives), CG(known_strings)[ZEND_STR_ERROR_REPORTING], p) != NULL)) {
     804         310 :                                         p->orig_value = p->value;
     805         310 :                                         p->orig_modifiable = p->modifiable;
     806         310 :                                         p->modified = 1;
     807             :                                 }
     808          69 :                         } else if (p->orig_value != p->value) {
     809          67 :                                 zend_string_release(p->value);
     810             :                         }
     811             : 
     812         379 :                         p->value = new_val;
     813         758 :                         if (Z_TYPE_P(err) == IS_LONG) {
     814         379 :                                 EG(error_reporting) = Z_LVAL_P(err);
     815             :                         } else {
     816           0 :                                 EG(error_reporting) = atoi(ZSTR_VAL(p->value));
     817             :                         }
     818             :                 } while (0);
     819             :         }
     820             : 
     821        2154 :         RETVAL_LONG(old_error_reporting);
     822             : }
     823             : /* }}} */
     824             : 
     825           7 : static int validate_constant_array(HashTable *ht) /* {{{ */
     826             : {
     827           7 :         int ret = 1;
     828             :         zval *val;
     829             : 
     830           7 :         ht->u.v.nApplyCount++;
     831          35 :         ZEND_HASH_FOREACH_VAL_IND(ht, val) {
     832          10 :                 ZVAL_DEREF(val);
     833          10 :                 if (Z_REFCOUNTED_P(val)) {
     834           5 :                         if (Z_TYPE_P(val) == IS_ARRAY) {
     835           2 :                                 if (!Z_IMMUTABLE_P(val)) {
     836           2 :                                         if (Z_ARRVAL_P(val)->u.v.nApplyCount > 0) {
     837           1 :                                                 zend_error(E_WARNING, "Constants cannot be recursive arrays");
     838           1 :                                                 ret = 0;
     839           1 :                                                 break;
     840           1 :                                         } else if (!validate_constant_array(Z_ARRVAL_P(val))) {
     841           0 :                                                 ret = 0;
     842           0 :                                                 break;
     843             :                                         }
     844             :                                 }
     845           5 :                         } else if (Z_TYPE_P(val) != IS_STRING && Z_TYPE_P(val) != IS_RESOURCE) {
     846           1 :                                 zend_error(E_WARNING, "Constants may only evaluate to scalar values or arrays");
     847           1 :                                 ret = 0;
     848           1 :                                 break;
     849             :                         }
     850             :                 }
     851             :         } ZEND_HASH_FOREACH_END();
     852           7 :         ht->u.v.nApplyCount--;
     853           7 :         return ret;
     854             : }
     855             : /* }}} */
     856             : 
     857           5 : static void copy_constant_array(zval *dst, zval *src) /* {{{ */
     858             : {
     859             :         zend_string *key;
     860             :         zend_ulong idx;
     861             :         zval *new_val, *val;
     862             : 
     863           5 :         array_init_size(dst, zend_hash_num_elements(Z_ARRVAL_P(src)));
     864          29 :         ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(src), idx, key, val) {
     865             :                 /* constant arrays can't contain references */
     866           8 :                 ZVAL_DEREF(val);
     867           8 :                 if (key) {
     868           1 :                         new_val = zend_hash_add_new(Z_ARRVAL_P(dst), key, val);
     869             :                 } else {
     870           7 :                         new_val = zend_hash_index_add_new(Z_ARRVAL_P(dst), idx, val);
     871             :                 }
     872           8 :                 if (Z_TYPE_P(val) == IS_ARRAY) {
     873           1 :                         if (!Z_IMMUTABLE_P(val)) {
     874           1 :                                 copy_constant_array(new_val, val);
     875             :                         }
     876           7 :                 } else if (Z_REFCOUNTED_P(val)) {
     877             :                         Z_ADDREF_P(val);
     878           2 :                         if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_RESOURCE_EX)) {
     879           1 :                                 Z_TYPE_INFO_P(new_val) &= ~(IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT);
     880             :                         }
     881             :                 }
     882             :         } ZEND_HASH_FOREACH_END();
     883           5 : }
     884             : /* }}} */
     885             : 
     886             : /* {{{ proto bool define(string constant_name, mixed value[, boolean case_insensitive])
     887             :    Define a new constant */
     888        3453 : ZEND_FUNCTION(define)
     889             : {
     890             :         zend_string *name;
     891             :         zval *val, val_free;
     892        3453 :         zend_bool non_cs = 0;
     893        3453 :         int case_sensitive = CONST_CS;
     894             :         zend_constant c;
     895             : 
     896             : #ifndef FAST_ZPP
     897             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sz|b", &name, &val, &non_cs) == FAILURE) {
     898             :                 return;
     899             :         }
     900             : #else
     901        3453 :         ZEND_PARSE_PARAMETERS_START(2, 3)
     902       10353 :                 Z_PARAM_STR(name)
     903        3450 :                 Z_PARAM_ZVAL(val)
     904        3450 :                 Z_PARAM_OPTIONAL
     905        3726 :                 Z_PARAM_BOOL(non_cs)
     906        3453 :         ZEND_PARSE_PARAMETERS_END();
     907             : #endif
     908             : 
     909        3449 :         if (non_cs) {
     910         137 :                 case_sensitive = 0;
     911             :         }
     912             : 
     913             :         /* class constant, check if there is name and make sure class is valid & exists */
     914        6898 :         if (zend_memnstr(ZSTR_VAL(name), "::", sizeof("::") - 1, ZSTR_VAL(name) + ZSTR_LEN(name))) {
     915           3 :                 zend_error(E_WARNING, "Class constants cannot be defined or redefined");
     916           3 :                 RETURN_FALSE;
     917             :         }
     918             : 
     919        3446 :         ZVAL_UNDEF(&val_free);
     920             : 
     921             : repeat:
     922        6892 :         switch (Z_TYPE_P(val)) {
     923             :                 case IS_LONG:
     924             :                 case IS_DOUBLE:
     925             :                 case IS_STRING:
     926             :                 case IS_FALSE:
     927             :                 case IS_TRUE:
     928             :                 case IS_NULL:
     929        3433 :                         break;
     930             :                 case IS_RESOURCE:
     931           3 :                         ZVAL_COPY(&val_free, val);
     932             :                         /* TODO: better solution than this tricky disable dtor on resource? */
     933           3 :                         Z_TYPE_INFO(val_free) &= ~(IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT);
     934           3 :                         val = &val_free;
     935           3 :                         break;
     936             :                 case IS_ARRAY:
     937           6 :                         if (!Z_IMMUTABLE_P(val)) {
     938           6 :                                 if (!validate_constant_array(Z_ARRVAL_P(val))) {
     939           2 :                                         RETURN_FALSE;
     940             :                                 } else {
     941           4 :                                         copy_constant_array(&c.value, val);
     942           4 :                                         goto register_constant;
     943             :                                 }
     944             :                         }
     945           0 :                         break;
     946             :                 case IS_OBJECT:
     947           4 :                         if (Z_TYPE(val_free) == IS_UNDEF) {
     948           4 :                                 if (Z_OBJ_HT_P(val)->get) {
     949             :                                         zval rv;
     950           0 :                                         val = Z_OBJ_HT_P(val)->get(val, &rv);
     951           0 :                                         ZVAL_COPY_VALUE(&val_free, val);
     952           0 :                                         goto repeat;
     953           4 :                                 } else if (Z_OBJ_HT_P(val)->cast_object) {
     954           4 :                                         if (Z_OBJ_HT_P(val)->cast_object(val, &val_free, IS_STRING) == SUCCESS) {
     955           1 :                                                 val = &val_free;
     956           1 :                                                 break;
     957             :                                         }
     958             :                                 }
     959             :                         }
     960             :                         /* no break */
     961             :                 default:
     962           3 :                         zend_error(E_WARNING, "Constants may only evaluate to scalar values or arrays");
     963           3 :                         zval_ptr_dtor(&val_free);
     964           3 :                         RETURN_FALSE;
     965             :         }
     966             : 
     967        3437 :         ZVAL_DUP(&c.value, val);
     968        3437 :         zval_ptr_dtor(&val_free);
     969             : register_constant:
     970        3441 :         c.flags = case_sensitive; /* non persistent */
     971        6882 :         c.name = zend_string_copy(name);
     972        3441 :         c.module_number = PHP_USER_CONSTANT;
     973        3441 :         if (zend_register_constant(&c) == SUCCESS) {
     974        3435 :                 RETURN_TRUE;
     975             :         } else {
     976           6 :                 RETURN_FALSE;
     977             :         }
     978             : }
     979             : /* }}} */
     980             : 
     981             : /* {{{ proto bool defined(string constant_name)
     982             :    Check whether a constant exists
     983             :    Warning: This function is special-cased by zend_compile.c and so is usually bypassed */
     984          24 : ZEND_FUNCTION(defined)
     985             : {
     986             :         zend_string *name;
     987             : 
     988             : #ifndef FAST_ZPP
     989             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
     990             :                 return;
     991             :         }
     992             : #else
     993          24 :         ZEND_PARSE_PARAMETERS_START(1, 1)
     994          72 :                 Z_PARAM_STR(name)
     995          24 :         ZEND_PARSE_PARAMETERS_END();
     996             : #endif
     997             : 
     998          24 :         if (zend_get_constant_ex(name, zend_get_executed_scope(), ZEND_FETCH_CLASS_SILENT)) {
     999          13 :                 RETURN_TRUE;
    1000             :         } else {
    1001          11 :                 RETURN_FALSE;
    1002             :         }
    1003             : }
    1004             : /* }}} */
    1005             : 
    1006             : /* {{{ proto string get_class([object object])
    1007             :    Retrieves the class name */
    1008         736 : ZEND_FUNCTION(get_class)
    1009             : {
    1010         736 :         zval *obj = NULL;
    1011             : 
    1012         736 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "|o!", &obj) == FAILURE) {
    1013          24 :                 RETURN_FALSE;
    1014             :         }
    1015             : 
    1016         712 :         if (!obj) {
    1017          22 :                 zend_class_entry *scope = zend_get_executed_scope();
    1018             : 
    1019          22 :                 if (scope) {
    1020          17 :                         RETURN_STR_COPY(scope->name);
    1021             :                 } else {
    1022           5 :                         zend_error(E_WARNING, "get_class() called without object from outside a class");
    1023           5 :                         RETURN_FALSE;
    1024             :                 }
    1025             :         }
    1026             : 
    1027         690 :         RETURN_STR_COPY(Z_OBJCE_P(obj)->name);
    1028             : }
    1029             : /* }}} */
    1030             : 
    1031             : /* {{{ proto string get_called_class()
    1032             :    Retrieves the "Late Static Binding" class name */
    1033          45 : ZEND_FUNCTION(get_called_class)
    1034             : {
    1035             :         zend_class_entry *called_scope;
    1036             : 
    1037          45 :         if (zend_parse_parameters_none() == FAILURE) {
    1038           0 :                 return;
    1039             :         }
    1040             : 
    1041          45 :         called_scope = zend_get_called_scope(execute_data);
    1042          45 :         if (called_scope) {
    1043          43 :                 RETURN_STR_COPY(called_scope->name);
    1044             :         } else {
    1045           2 :                 zend_class_entry *scope = zend_get_executed_scope();
    1046           2 :                 if (!scope)  {
    1047           2 :                         zend_error(E_WARNING, "get_called_class() called from outside a class");
    1048             :                 }
    1049             :         }
    1050           2 :         RETURN_FALSE;
    1051             : }
    1052             : /* }}} */
    1053             : 
    1054             : /* {{{ proto mixed get_parent_class([mixed object])
    1055             :    Retrieves the parent class name for object or class or current scope or false if not in a scope. */
    1056          60 : ZEND_FUNCTION(get_parent_class)
    1057             : {
    1058             :         zval *arg;
    1059          60 :         zend_class_entry *ce = NULL;
    1060             : 
    1061          60 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &arg) == FAILURE) {
    1062           1 :                 return;
    1063             :         }
    1064             : 
    1065          59 :         if (!ZEND_NUM_ARGS()) {
    1066           5 :                 ce = zend_get_executed_scope();
    1067           5 :                 if (ce && ce->parent) {
    1068           2 :                         RETURN_STR_COPY(ce->parent->name);
    1069             :                 } else {
    1070           3 :                         RETURN_FALSE;
    1071             :                 }
    1072             :         }
    1073             : 
    1074         108 :         if (Z_TYPE_P(arg) == IS_OBJECT) {
    1075          18 :                 ce = Z_OBJ_P(arg)->ce;
    1076          72 :         } else if (Z_TYPE_P(arg) == IS_STRING) {
    1077          12 :             ce = zend_lookup_class(Z_STR_P(arg));
    1078             :         }
    1079             : 
    1080          54 :         if (ce && ce->parent) {
    1081           5 :                 RETURN_STR_COPY(ce->parent->name);
    1082             :         } else {
    1083          49 :                 RETURN_FALSE;
    1084             :         }
    1085             : }
    1086             : /* }}} */
    1087             : 
    1088         359 : static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /* {{{ */
    1089             : {
    1090             :         zval *obj;
    1091             :         zend_string *class_name;
    1092             :         zend_class_entry *instance_ce;
    1093             :         zend_class_entry *ce;
    1094         359 :         zend_bool allow_string = only_subclass;
    1095             :         zend_bool retval;
    1096             : 
    1097             : #ifndef FAST_ZPP
    1098             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "zS|b", &obj, &class_name, &allow_string) == FAILURE) {
    1099             :                 return;
    1100             :         }
    1101             : #else
    1102         359 :         ZEND_PARSE_PARAMETERS_START(2, 3)
    1103         355 :                 Z_PARAM_ZVAL(obj)
    1104        1065 :                 Z_PARAM_STR(class_name)
    1105         344 :                 Z_PARAM_OPTIONAL
    1106         510 :                 Z_PARAM_BOOL(allow_string)
    1107         359 :         ZEND_PARSE_PARAMETERS_END();
    1108             : #endif
    1109             :         /*
    1110             :          * allow_string - is_a default is no, is_subclass_of is yes.
    1111             :          *   if it's allowed, then the autoloader will be called if the class does not exist.
    1112             :          *   default behaviour is different, as 'is_a' used to be used to test mixed return values
    1113             :          *   and there is no easy way to deprecate this.
    1114             :          */
    1115             : 
    1116         576 :         if (allow_string && Z_TYPE_P(obj) == IS_STRING) {
    1117          92 :                 instance_ce = zend_lookup_class(Z_STR_P(obj));
    1118          92 :                 if (!instance_ce) {
    1119          48 :                         RETURN_FALSE;
    1120             :                 }
    1121         500 :         } else if (Z_TYPE_P(obj) == IS_OBJECT) {
    1122         100 :                 instance_ce = Z_OBJCE_P(obj);
    1123             :         } else {
    1124         150 :                 RETURN_FALSE;
    1125             :         }
    1126             : 
    1127         219 :         if (!only_subclass && EXPECTED(zend_string_equals(instance_ce->name, class_name))) {
    1128           9 :                 retval = 1;
    1129             :         } else {
    1130         135 :                 ce = zend_lookup_class_ex(class_name, NULL, 0);
    1131         135 :                 if (!ce) {
    1132          63 :                         retval = 0;
    1133             :                 } else {
    1134          87 :                         if (only_subclass && instance_ce == ce) {
    1135          15 :                                 retval = 0;
    1136             :                         } else {
    1137          57 :                                 retval = instanceof_function(instance_ce, ce);
    1138             :                         }
    1139             :                 }
    1140             :         }
    1141             : 
    1142         144 :         RETURN_BOOL(retval);
    1143             : }
    1144             : /* }}} */
    1145             : 
    1146             : /* {{{ proto bool is_subclass_of(mixed object_or_string, string class_name [, bool allow_string])
    1147             :    Returns true if the object has this class as one of its parents */
    1148         199 : ZEND_FUNCTION(is_subclass_of)
    1149             : {
    1150         199 :         is_a_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
    1151         199 : }
    1152             : /* }}} */
    1153             : 
    1154             : /* {{{ proto bool is_a(mixed object_or_string, string class_name [, bool allow_string])
    1155             :    Returns true if the first argument is an object and is this class or has this class as one of its parents, */
    1156         160 : ZEND_FUNCTION(is_a)
    1157             : {
    1158         160 :         is_a_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
    1159         160 : }
    1160             : /* }}} */
    1161             : 
    1162             : /* {{{ add_class_vars */
    1163          76 : static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, int statics, zval *return_value)
    1164             : {
    1165             :         zend_property_info *prop_info;
    1166             :         zval *prop, prop_copy;
    1167             :         zend_string *key;
    1168             : 
    1169         884 :         ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->properties_info, key, prop_info) {
    1170        1306 :                 if (((prop_info->flags & ZEND_ACC_SHADOW) &&
    1171          18 :                      prop_info->ce != scope) ||
    1172         388 :                     ((prop_info->flags & ZEND_ACC_PROTECTED) &&
    1173          80 :                      !zend_check_protected(prop_info->ce, scope)) ||
    1174         364 :                     ((prop_info->flags & ZEND_ACC_PRIVATE) &&
    1175             :                       ce != scope &&
    1176          52 :                           prop_info->ce != scope)) {
    1177          92 :                         continue;
    1178             :                 }
    1179         312 :                 prop = NULL;
    1180         350 :                 if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) {
    1181          38 :                         prop = &ce->default_static_members_table[prop_info->offset];
    1182         274 :                 } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) {
    1183         118 :                         prop = &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)];
    1184             :                 }
    1185         468 :                 if (!prop || Z_TYPE_P(prop) == IS_UNDEF) {
    1186         156 :                         continue;
    1187             :                 }
    1188             : 
    1189             :                 /* copy: enforce read only access */
    1190         156 :                 ZVAL_DEREF(prop);
    1191         156 :                 if (UNEXPECTED(Z_COPYABLE_P(prop))) {
    1192          35 :                         ZVAL_DUP(&prop_copy, prop);
    1193          35 :                         prop = &prop_copy;
    1194             :                 } else {
    1195         121 :                         Z_TRY_ADDREF_P(prop);
    1196             :                 }
    1197             : 
    1198             :                 /* this is necessary to make it able to work with default array
    1199             :                  * properties, returned to user */
    1200         156 :                 if (Z_OPT_CONSTANT_P(prop)) {
    1201           0 :                         if (UNEXPECTED(zval_update_constant_ex(prop, NULL) != SUCCESS)) {
    1202           0 :                                 return;
    1203             :                         }
    1204             :                 }
    1205             : 
    1206         156 :                 zend_hash_add_new(Z_ARRVAL_P(return_value), key, prop);
    1207             :         } ZEND_HASH_FOREACH_END();
    1208             : }
    1209             : /* }}} */
    1210             : 
    1211             : /* {{{ proto array get_class_vars(string class_name)
    1212             :    Returns an array of default properties of the class. */
    1213          65 : ZEND_FUNCTION(get_class_vars)
    1214             : {
    1215             :         zend_string *class_name;
    1216             :         zend_class_entry *ce, *scope;
    1217             : 
    1218          65 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &class_name) == FAILURE) {
    1219           7 :                 return;
    1220             :         }
    1221             : 
    1222          58 :         ce = zend_lookup_class(class_name);
    1223          58 :         if (!ce) {
    1224          20 :                 RETURN_FALSE;
    1225             :         } else {
    1226          38 :                 array_init(return_value);
    1227          38 :                 if (UNEXPECTED(!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) {
    1228           0 :                         if (UNEXPECTED(zend_update_class_constants(ce) != SUCCESS)) {
    1229           0 :                                 return;
    1230             :                         }
    1231             :                 }
    1232          38 :                 scope = zend_get_executed_scope();
    1233          38 :                 add_class_vars(scope, ce, 0, return_value);
    1234          38 :                 add_class_vars(scope, ce, 1, return_value);
    1235             :         }
    1236             : }
    1237             : /* }}} */
    1238             : 
    1239             : /* {{{ proto array get_object_vars(object obj)
    1240             :    Returns an array of object properties */
    1241          77 : ZEND_FUNCTION(get_object_vars)
    1242             : {
    1243             :         zval *obj;
    1244             :         zval *value;
    1245             :         HashTable *properties;
    1246             :         zend_string *key;
    1247             :         zend_object *zobj;
    1248             : 
    1249             : #ifndef FAST_ZPP
    1250             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
    1251             :                 return;
    1252             :         }
    1253             : #else
    1254          77 :         ZEND_PARSE_PARAMETERS_START(1, 1)
    1255         225 :                 Z_PARAM_OBJECT(obj)
    1256          77 :         ZEND_PARSE_PARAMETERS_END();
    1257             : #endif
    1258             : 
    1259          49 :         if (Z_OBJ_HT_P(obj)->get_properties == NULL) {
    1260           0 :                 RETURN_FALSE;
    1261             :         }
    1262             : 
    1263          49 :         properties = Z_OBJ_HT_P(obj)->get_properties(obj);
    1264             : 
    1265          49 :         if (properties == NULL) {
    1266           0 :                 RETURN_FALSE;
    1267             :         }
    1268             : 
    1269          49 :         zobj = Z_OBJ_P(obj);
    1270             : 
    1271          49 :         if (!zobj->ce->default_properties_count && properties == zobj->properties && !ZEND_HASH_GET_APPLY_COUNT(properties)) {
    1272             :                 /* fast copy */
    1273           7 :                 if (EXPECTED(zobj->handlers == &std_object_handlers)) {
    1274           7 :                         if (EXPECTED(!(GC_FLAGS(properties) & IS_ARRAY_IMMUTABLE))) {
    1275           7 :                                 GC_REFCOUNT(properties)++;
    1276             :                         }
    1277           7 :                         RETURN_ARR(properties);
    1278             :                 }
    1279           0 :                 RETURN_ARR(zend_array_dup(properties));
    1280             :         } else {
    1281          42 :                 array_init_size(return_value, zend_hash_num_elements(properties));
    1282             : 
    1283         660 :                 ZEND_HASH_FOREACH_STR_KEY_VAL_IND(properties, key, value) {
    1284         206 :                         if (key) {
    1285         203 :                                 if (zend_check_property_access(zobj, key) == SUCCESS) {
    1286         177 :                                         if (Z_ISREF_P(value) && Z_REFCOUNT_P(value) == 1) {
    1287           1 :                                                 value = Z_REFVAL_P(value);
    1288             :                                         }
    1289         175 :                                         if (Z_REFCOUNTED_P(value)) {
    1290             :                                                 Z_ADDREF_P(value);
    1291             :                                         }
    1292         175 :                                         if (ZSTR_VAL(key)[0] == 0) {
    1293             :                                                 const char *prop_name, *class_name;
    1294             :                                                 size_t prop_len;
    1295          39 :                                                 zend_unmangle_property_name_ex(key, &class_name, &prop_name, &prop_len);
    1296          39 :                                                 zend_hash_str_add_new(Z_ARRVAL_P(return_value), prop_name, prop_len, value);
    1297             :                                         } else {
    1298         136 :                                                 zend_hash_add_new(Z_ARRVAL_P(return_value), key, value);
    1299             :                                         }
    1300             :                                 }
    1301             :                         }
    1302             :                 } ZEND_HASH_FOREACH_END();
    1303             :         }
    1304             : }
    1305             : /* }}} */
    1306             : 
    1307          56 : static int same_name(zend_string *key, zend_string *name) /* {{{ */
    1308             : {
    1309             :         zend_string *lcname;
    1310             :         int ret;
    1311             : 
    1312          56 :         if (key == name) {
    1313          24 :                 return 1;
    1314             :         }
    1315          32 :         if (ZSTR_LEN(key) != ZSTR_LEN(name)) {
    1316           3 :                 return 0;
    1317             :         }
    1318          29 :         lcname = zend_string_tolower(name);
    1319          29 :         ret = memcmp(ZSTR_VAL(lcname), ZSTR_VAL(key), ZSTR_LEN(key)) == 0;
    1320             :         zend_string_release(lcname);
    1321          29 :         return ret;
    1322             : }
    1323             : /* }}} */
    1324             : 
    1325             : /* {{{ proto array get_class_methods(mixed class)
    1326             :    Returns an array of method names for class or class instance. */
    1327          74 : ZEND_FUNCTION(get_class_methods)
    1328             : {
    1329             :         zval *klass;
    1330             :         zval method_name;
    1331          74 :         zend_class_entry *ce = NULL;
    1332             :         zend_class_entry *scope;
    1333             :         zend_function *mptr;
    1334             :         zend_string *key;
    1335             : 
    1336          74 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &klass) == FAILURE) {
    1337           2 :                 return;
    1338             :         }
    1339             : 
    1340         144 :         if (Z_TYPE_P(klass) == IS_OBJECT) {
    1341          11 :                 ce = Z_OBJCE_P(klass);
    1342         122 :         } else if (Z_TYPE_P(klass) == IS_STRING) {
    1343          39 :             ce = zend_lookup_class(Z_STR_P(klass));
    1344             :         }
    1345             : 
    1346          72 :         if (!ce) {
    1347          27 :                 RETURN_NULL();
    1348             :         }
    1349             : 
    1350          45 :         array_init(return_value);
    1351          45 :         scope = zend_get_executed_scope();
    1352             : 
    1353         535 :         ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->function_table, key, mptr) {
    1354             : 
    1355         366 :                 if ((mptr->common.fn_flags & ZEND_ACC_PUBLIC)
    1356             :                  || (scope &&
    1357          46 :                      (((mptr->common.fn_flags & ZEND_ACC_PROTECTED) &&
    1358          22 :                        zend_check_protected(mptr->common.scope, scope))
    1359          29 :                    || ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) &&
    1360          24 :                        scope == mptr->common.scope)))) {
    1361         207 :                         size_t len = ZSTR_LEN(mptr->common.function_name);
    1362             : 
    1363             :                         /* Do not display old-style inherited constructors */
    1364         207 :                         if (!key) {
    1365           0 :                                 ZVAL_STR_COPY(&method_name, mptr->common.function_name);
    1366           0 :                                 zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
    1367         224 :                         } else if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
    1368          12 :                             mptr->common.scope == ce ||
    1369           5 :                             zend_binary_strcasecmp(ZSTR_VAL(key), ZSTR_LEN(key), ZSTR_VAL(mptr->common.function_name), len) == 0) {
    1370             : 
    1371         490 :                                 if (mptr->type == ZEND_USER_FUNCTION &&
    1372         226 :                                     (!mptr->op_array.refcount || *mptr->op_array.refcount > 1) &&
    1373          54 :                                  !same_name(key, mptr->common.function_name)) {
    1374           3 :                                         ZVAL_STR_COPY(&method_name, zend_find_alias_name(mptr->common.scope, key));
    1375           3 :                                         zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
    1376             :                                 } else {
    1377         204 :                                         ZVAL_STR_COPY(&method_name, mptr->common.function_name);
    1378         204 :                                         zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
    1379             :                                 }
    1380             :                         }
    1381             :                 }
    1382             :         } ZEND_HASH_FOREACH_END();
    1383             : }
    1384             : /* }}} */
    1385             : 
    1386             : /* {{{ proto bool method_exists(object object, string method)
    1387             :    Checks if the class method exists */
    1388         138 : ZEND_FUNCTION(method_exists)
    1389             : {
    1390             :         zval *klass;
    1391             :         zend_string *method_name;
    1392             :         zend_string *lcname;
    1393             :         zend_class_entry * ce;
    1394             : 
    1395             : #ifndef FAST_ZPP
    1396             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "zS", &klass, &method_name) == FAILURE) {
    1397             :                 return;
    1398             :         }
    1399             : #else
    1400         138 :         ZEND_PARSE_PARAMETERS_START(2, 2)
    1401         136 :                 Z_PARAM_ZVAL(klass)
    1402         408 :                 Z_PARAM_STR(method_name)
    1403         138 :         ZEND_PARSE_PARAMETERS_END();
    1404             : #endif
    1405         260 :         if (Z_TYPE_P(klass) == IS_OBJECT) {
    1406          74 :                 ce = Z_OBJCE_P(klass);
    1407         112 :         } else if (Z_TYPE_P(klass) == IS_STRING) {
    1408          34 :                 if ((ce = zend_lookup_class(Z_STR_P(klass))) == NULL) {
    1409           5 :                         RETURN_FALSE;
    1410             :                 }
    1411             :         } else {
    1412          22 :                 RETURN_FALSE;
    1413             :         }
    1414             : 
    1415         103 :         lcname = zend_string_tolower(method_name);
    1416         103 :         if (zend_hash_exists(&ce->function_table, lcname)) {
    1417             :                 zend_string_release(lcname);
    1418          69 :                 RETURN_TRUE;
    1419             :         } else {
    1420          34 :                 union _zend_function *func = NULL;
    1421             : 
    1422          94 :                 if (Z_TYPE_P(klass) == IS_OBJECT
    1423          64 :                 && Z_OBJ_HT_P(klass)->get_method != NULL
    1424          60 :                 && (func = Z_OBJ_HT_P(klass)->get_method(&Z_OBJ_P(klass), method_name, NULL)) != NULL
    1425             :                 ) {
    1426           3 :                         if (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
    1427             :                                 /* Returns true to the fake Closure's __invoke */
    1428           3 :                                 RETVAL_BOOL(func->common.scope == zend_ce_closure
    1429             :                                         && zend_string_equals_literal(method_name, ZEND_INVOKE_FUNC_NAME));
    1430             : 
    1431             :                                 zend_string_release(lcname);
    1432           3 :                                 zend_string_release(func->common.function_name);
    1433           3 :                                 zend_free_trampoline(func);
    1434           3 :                                 return;
    1435             :                         }
    1436             :                         zend_string_release(lcname);
    1437           0 :                         RETURN_TRUE;
    1438             :                 }
    1439             :         }
    1440             :         zend_string_release(lcname);
    1441          31 :         RETURN_FALSE;
    1442             : }
    1443             : /* }}} */
    1444             : 
    1445             : /* {{{ proto bool property_exists(mixed object_or_class, string property_name)
    1446             :    Checks if the object or class has a property */
    1447         128 : ZEND_FUNCTION(property_exists)
    1448             : {
    1449             :         zval *object;
    1450             :         zend_string *property;
    1451             :         zend_class_entry *ce;
    1452             :         zend_property_info *property_info;
    1453             :         zval property_z;
    1454             : 
    1455         128 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "zS", &object, &property) == FAILURE) {
    1456           4 :                 return;
    1457             :         }
    1458             : 
    1459         124 :         if (property == NULL) {
    1460           0 :                 RETURN_FALSE;
    1461             :         }
    1462             : 
    1463         248 :         if (Z_TYPE_P(object) == IS_STRING) {
    1464          68 :                 ce = zend_lookup_class(Z_STR_P(object));
    1465          68 :                 if (!ce) {
    1466           4 :                         RETURN_FALSE;
    1467             :                 }
    1468         112 :         } else if (Z_TYPE_P(object) == IS_OBJECT) {
    1469          50 :                 ce = Z_OBJCE_P(object);
    1470             :         } else {
    1471           6 :                 zend_error(E_WARNING, "First parameter must either be an object or the name of an existing class");
    1472           6 :                 RETURN_NULL();
    1473             :         }
    1474             : 
    1475         305 :         if ((property_info = zend_hash_find_ptr(&ce->properties_info, property)) != NULL
    1476          77 :                 && (property_info->flags & ZEND_ACC_SHADOW) == 0) {
    1477          70 :                 RETURN_TRUE;
    1478             :         }
    1479             : 
    1480          44 :         ZVAL_STR(&property_z, property);
    1481             : 
    1482         140 :         if (Z_TYPE_P(object) ==  IS_OBJECT &&
    1483          26 :                 Z_OBJ_HANDLER_P(object, has_property) &&
    1484          26 :                 Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2, NULL)) {
    1485          11 :                 RETURN_TRUE;
    1486             :         }
    1487          33 :         RETURN_FALSE;
    1488             : }
    1489             : /* }}} */
    1490             : 
    1491             : /* {{{ proto bool class_exists(string classname [, bool autoload])
    1492             :    Checks if the class exists */
    1493         543 : ZEND_FUNCTION(class_exists)
    1494             : {
    1495             :         zend_string *class_name;
    1496             :         zend_string *lc_name;
    1497             :         zend_class_entry *ce;
    1498         543 :         zend_bool autoload = 1;
    1499             : 
    1500             : #ifndef FAST_ZPP
    1501             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &class_name, &autoload) == FAILURE) {
    1502             :                 return;
    1503             :         }
    1504             : #else
    1505         543 :         ZEND_PARSE_PARAMETERS_START(1, 2)
    1506        1620 :                 Z_PARAM_STR(class_name)
    1507         532 :                 Z_PARAM_OPTIONAL
    1508         756 :                 Z_PARAM_BOOL(autoload)
    1509         543 :         ZEND_PARSE_PARAMETERS_END();
    1510             : #endif
    1511             : 
    1512         526 :         if (!autoload) {
    1513          58 :                 if (ZSTR_VAL(class_name)[0] == '\\') {
    1514             :                         /* Ignore leading "\" */
    1515           0 :                         lc_name = zend_string_alloc(ZSTR_LEN(class_name) - 1, 0);
    1516           0 :                         zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(class_name) + 1, ZSTR_LEN(class_name) - 1);
    1517             :                 } else {
    1518          58 :                         lc_name = zend_string_tolower(class_name);
    1519             :                 }
    1520             : 
    1521         116 :                 ce = zend_hash_find_ptr(EG(class_table), lc_name);
    1522             :                 zend_string_release(lc_name);
    1523             :         } else {
    1524         468 :                 ce = zend_lookup_class(class_name);
    1525             :         }
    1526             : 
    1527         526 :         if (ce) {
    1528         419 :                 RETURN_BOOL((ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT)) == 0);
    1529             :         } else {
    1530         107 :                 RETURN_FALSE;
    1531             :         }
    1532             : }
    1533             : /* }}} */
    1534             : 
    1535             : /* {{{ proto bool interface_exists(string classname [, bool autoload])
    1536             :    Checks if the class exists */
    1537         108 : ZEND_FUNCTION(interface_exists)
    1538             : {
    1539             :         zend_string *iface_name, *lc_name;
    1540             :         zend_class_entry *ce;
    1541         108 :         zend_bool autoload = 1;
    1542             : 
    1543             : #ifndef FAST_ZPP
    1544             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &iface_name, &autoload) == FAILURE) {
    1545             :                 return;
    1546             :         }
    1547             : #else
    1548         108 :         ZEND_PARSE_PARAMETERS_START(1, 2)
    1549         315 :                 Z_PARAM_STR(iface_name)
    1550          98 :                 Z_PARAM_OPTIONAL
    1551         214 :                 Z_PARAM_BOOL(autoload)
    1552         108 :         ZEND_PARSE_PARAMETERS_END();
    1553             : #endif
    1554             : 
    1555          92 :         if (!autoload) {
    1556          17 :                 if (ZSTR_VAL(iface_name)[0] == '\\') {
    1557             :                         /* Ignore leading "\" */
    1558           0 :                         lc_name = zend_string_alloc(ZSTR_LEN(iface_name) - 1, 0);
    1559           0 :                         zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(iface_name) + 1, ZSTR_LEN(iface_name) - 1);
    1560             :                 } else {
    1561          17 :                         lc_name = zend_string_tolower(iface_name);
    1562             :                 }
    1563          34 :                 ce = zend_hash_find_ptr(EG(class_table), lc_name);
    1564             :                 zend_string_release(lc_name);
    1565          17 :                 RETURN_BOOL(ce && ce->ce_flags & ZEND_ACC_INTERFACE);
    1566             :         }
    1567             : 
    1568          75 :         ce = zend_lookup_class(iface_name);
    1569          75 :         if (ce) {
    1570          36 :                 RETURN_BOOL((ce->ce_flags & ZEND_ACC_INTERFACE) > 0);
    1571             :         } else {
    1572          39 :                 RETURN_FALSE;
    1573             :         }
    1574             : }
    1575             : /* }}} */
    1576             : 
    1577             : /* {{{ proto bool trait_exists(string traitname [, bool autoload])
    1578             :  Checks if the trait exists */
    1579          73 : ZEND_FUNCTION(trait_exists)
    1580             : {
    1581             :         zend_string *trait_name, *lc_name;
    1582             :         zend_class_entry *ce;
    1583          73 :         zend_bool autoload = 1;
    1584             : 
    1585             : #ifndef FAST_ZPP
    1586             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &trait_name, &autoload) == FAILURE) {
    1587             :                 return;
    1588             :         }
    1589             : #else
    1590          73 :         ZEND_PARSE_PARAMETERS_START(1, 2)
    1591         213 :                 Z_PARAM_STR(trait_name)
    1592          64 :                 Z_PARAM_OPTIONAL
    1593         164 :                 Z_PARAM_BOOL(autoload)
    1594          73 :         ZEND_PARSE_PARAMETERS_END();
    1595             : #endif
    1596             : 
    1597          58 :         if (!autoload) {
    1598          11 :                 if (ZSTR_VAL(trait_name)[0] == '\\') {
    1599             :                         /* Ignore leading "\" */
    1600           0 :                         lc_name = zend_string_alloc(ZSTR_LEN(trait_name) - 1, 0);
    1601           0 :                         zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(trait_name) + 1, ZSTR_LEN(trait_name) - 1);
    1602             :                 } else {
    1603          11 :                         lc_name = zend_string_tolower(trait_name);
    1604             :                 }
    1605             : 
    1606          22 :                 ce = zend_hash_find_ptr(EG(class_table), lc_name);
    1607             :                 zend_string_release(lc_name);
    1608             :         } else {
    1609          47 :                 ce = zend_lookup_class(trait_name);
    1610             :         }
    1611             : 
    1612          58 :         if (ce) {
    1613          12 :                 RETURN_BOOL((ce->ce_flags & ZEND_ACC_TRAIT) != 0);
    1614             :         } else {
    1615          46 :                 RETURN_FALSE;
    1616             :         }
    1617             : }
    1618             : /* }}} */
    1619             : 
    1620             : /* {{{ proto bool function_exists(string function_name)
    1621             :    Checks if the function exists */
    1622        4670 : ZEND_FUNCTION(function_exists)
    1623             : {
    1624             :         zend_string *name;
    1625             :         zend_function *func;
    1626             :         zend_string *lcname;
    1627             : 
    1628             : #ifndef FAST_ZPP
    1629             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
    1630             :                 return;
    1631             :         }
    1632             : #else
    1633        4670 :         ZEND_PARSE_PARAMETERS_START(1, 1)
    1634       14004 :                 Z_PARAM_STR(name)
    1635        4670 :         ZEND_PARSE_PARAMETERS_END();
    1636             : #endif
    1637             : 
    1638        4664 :         if (ZSTR_VAL(name)[0] == '\\') {
    1639             :                 /* Ignore leading "\" */
    1640           2 :                 lcname = zend_string_alloc(ZSTR_LEN(name) - 1, 0);
    1641           1 :                 zend_str_tolower_copy(ZSTR_VAL(lcname), ZSTR_VAL(name) + 1, ZSTR_LEN(name) - 1);
    1642             :         } else {
    1643        4663 :                 lcname = zend_string_tolower(name);
    1644             :         }
    1645             : 
    1646        9328 :         func = zend_hash_find_ptr(EG(function_table), lcname);
    1647             :         zend_string_release(lcname);
    1648             : 
    1649             :         /*
    1650             :          * A bit of a hack, but not a bad one: we see if the handler of the function
    1651             :          * is actually one that displays "function is disabled" message.
    1652             :          */
    1653        4664 :         RETURN_BOOL(func && (func->type != ZEND_INTERNAL_FUNCTION ||
    1654             :                 func->internal_function.handler != zif_display_disabled_function));
    1655             : }
    1656             : /* }}} */
    1657             : 
    1658             : /* {{{ proto bool class_alias(string user_class_name , string alias_name [, bool autoload])
    1659             :    Creates an alias for user defined class */
    1660          33 : ZEND_FUNCTION(class_alias)
    1661             : {
    1662             :         zend_string *class_name;
    1663             :         char *alias_name;
    1664             :         zend_class_entry *ce;
    1665             :         size_t alias_name_len;
    1666          33 :         zend_bool autoload = 1;
    1667             : 
    1668          33 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ss|b", &class_name, &alias_name, &alias_name_len, &autoload) == FAILURE) {
    1669           0 :                 return;
    1670             :         }
    1671             : 
    1672          33 :         ce = zend_lookup_class_ex(class_name, NULL, autoload);
    1673             : 
    1674          33 :         if (ce) {
    1675          32 :                 if (ce->type == ZEND_USER_CLASS) {
    1676          31 :                         if (zend_register_class_alias_ex(alias_name, alias_name_len, ce) == SUCCESS) {
    1677          23 :                                 RETURN_TRUE;
    1678             :                         } else {
    1679           4 :                                 zend_error(E_WARNING, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), alias_name);
    1680           4 :                                 RETURN_FALSE;
    1681             :                         }
    1682             :                 } else {
    1683           1 :                         zend_error(E_WARNING, "First argument of class_alias() must be a name of user defined class");
    1684           1 :                         RETURN_FALSE;
    1685             :                 }
    1686             :         } else {
    1687           1 :                 zend_error(E_WARNING, "Class '%s' not found", ZSTR_VAL(class_name));
    1688           1 :                 RETURN_FALSE;
    1689             :         }
    1690             : }
    1691             : /* }}} */
    1692             : 
    1693             : #if ZEND_DEBUG
    1694             : /* {{{ proto void leak([int num_bytes])
    1695             :    Cause an intentional memory leak, for testing/debugging purposes */
    1696             : ZEND_FUNCTION(leak)
    1697             : {
    1698             :         zend_long leakbytes = 3;
    1699             : 
    1700             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &leakbytes) == FAILURE) {
    1701             :                 return;
    1702             :         }
    1703             : 
    1704             :         emalloc(leakbytes);
    1705             : }
    1706             : /* }}} */
    1707             : 
    1708             : /* {{{ proto void leak_variable(mixed variable [, bool leak_data])
    1709             :    Leak a variable that is a resource or an object */
    1710             : ZEND_FUNCTION(leak_variable)
    1711             : {
    1712             :         zval *zv;
    1713             :         zend_bool leak_data = 0;
    1714             : 
    1715             :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &zv, &leak_data) == FAILURE) {
    1716             :                 return;
    1717             :         }
    1718             : 
    1719             :         if (!leak_data) {
    1720             :                 Z_ADDREF_P(zv);
    1721             :         } else if (Z_TYPE_P(zv) == IS_RESOURCE) {
    1722             :                 Z_ADDREF_P(zv);
    1723             :         } else if (Z_TYPE_P(zv) == IS_OBJECT) {
    1724             :                 Z_ADDREF_P(zv);
    1725             :         } else {
    1726             :                 zend_error(E_WARNING, "Leaking non-zval data is only applicable to resources and objects");
    1727             :         }
    1728             : }
    1729             : /* }}} */
    1730             : 
    1731             : 
    1732             : #ifdef ZEND_TEST_EXCEPTIONS
    1733             : /* {{{ proto void crash(void)
    1734             :    Crash the script */
    1735             : ZEND_FUNCTION(crash)
    1736             : {
    1737             :         char *nowhere = NULL;
    1738             : 
    1739             :         if (zend_parse_parameters_none() == FAILURE) {
    1740             :                 return;
    1741             :         }
    1742             : 
    1743             :         memcpy(nowhere, "something", sizeof("something"));
    1744             : }
    1745             : /* }}} */
    1746             : #endif
    1747             : 
    1748             : #endif /* ZEND_DEBUG */
    1749             : 
    1750             : /* {{{ proto array get_included_files(void)
    1751             :    Returns an array with the file names that were include_once()'d */
    1752          39 : ZEND_FUNCTION(get_included_files)
    1753             : {
    1754             :         zend_string *entry;
    1755             : 
    1756          39 :         if (zend_parse_parameters_none() == FAILURE) {
    1757           3 :                 return;
    1758             :         }
    1759             : 
    1760          36 :         array_init(return_value);
    1761         178 :         ZEND_HASH_FOREACH_STR_KEY(&EG(included_files), entry) {
    1762          71 :                 if (entry) {
    1763          71 :                         add_next_index_str(return_value, zend_string_copy(entry));
    1764             :                 }
    1765             :         } ZEND_HASH_FOREACH_END();
    1766             : }
    1767             : /* }}} */
    1768             : 
    1769             : /* {{{ proto void trigger_error(string message [, int error_type])
    1770             :    Generates a user-level error/warning/notice message */
    1771          24 : ZEND_FUNCTION(trigger_error)
    1772             : {
    1773          24 :         zend_long error_type = E_USER_NOTICE;
    1774             :         char *message;
    1775             :         size_t message_len;
    1776             : 
    1777          24 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &message, &message_len, &error_type) == FAILURE) {
    1778           2 :                 return;
    1779             :         }
    1780             : 
    1781          22 :         switch (error_type) {
    1782             :                 case E_USER_ERROR:
    1783             :                 case E_USER_WARNING:
    1784             :                 case E_USER_NOTICE:
    1785             :                 case E_USER_DEPRECATED:
    1786          20 :                         break;
    1787             :                 default:
    1788           2 :                         zend_error(E_WARNING, "Invalid error type specified");
    1789           2 :                         RETURN_FALSE;
    1790             :                         break;
    1791             :         }
    1792             : 
    1793          20 :         zend_error((int)error_type, "%s", message);
    1794          19 :         RETURN_TRUE;
    1795             : }
    1796             : /* }}} */
    1797             : 
    1798             : /* {{{ proto string set_error_handler(callable error_handler [, int error_types])
    1799             :    Sets a user-defined error handler function.  Returns the previously defined error handler, or false on error */
    1800         258 : ZEND_FUNCTION(set_error_handler)
    1801             : {
    1802             :         zval *error_handler;
    1803         258 :         zend_string *error_handler_name = NULL;
    1804         258 :         zend_long error_type = E_ALL;
    1805             : 
    1806         258 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|l", &error_handler, &error_type) == FAILURE) {
    1807           0 :                 return;
    1808             :         }
    1809             : 
    1810         516 :         if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */
    1811         257 :                 if (!zend_is_callable(error_handler, 0, &error_handler_name)) {
    1812           0 :                         zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
    1813           0 :                                            get_active_function_name(), error_handler_name?ZSTR_VAL(error_handler_name):"unknown");
    1814           0 :                         zend_string_release(error_handler_name);
    1815           0 :                         return;
    1816             :                 }
    1817         257 :                 zend_string_release(error_handler_name);
    1818             :         }
    1819             : 
    1820         258 :         if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
    1821           6 :                 ZVAL_COPY(return_value, &EG(user_error_handler));
    1822             : 
    1823           6 :                 zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting));
    1824           6 :                 zend_stack_push(&EG(user_error_handlers), &EG(user_error_handler));
    1825             :         }
    1826             : 
    1827         516 :         if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler */
    1828           1 :                 ZVAL_UNDEF(&EG(user_error_handler));
    1829           1 :                 return;
    1830             :         }
    1831             : 
    1832         257 :         ZVAL_COPY(&EG(user_error_handler), error_handler);
    1833         257 :         EG(user_error_handler_error_reporting) = (int)error_type;
    1834             : }
    1835             : /* }}} */
    1836             : 
    1837             : /* {{{ proto void restore_error_handler(void)
    1838             :    Restores the previously defined error handler function */
    1839           4 : ZEND_FUNCTION(restore_error_handler)
    1840             : {
    1841           4 :         if (zend_parse_parameters_none() == FAILURE) {
    1842           0 :                 return;
    1843             :         }
    1844             : 
    1845           4 :         if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
    1846             :                 zval zeh;
    1847             : 
    1848           4 :                 ZVAL_COPY_VALUE(&zeh, &EG(user_error_handler));
    1849           4 :                 ZVAL_UNDEF(&EG(user_error_handler));
    1850           4 :                 zval_ptr_dtor(&zeh);
    1851             :         }
    1852             : 
    1853           4 :         if (zend_stack_is_empty(&EG(user_error_handlers))) {
    1854           4 :                 ZVAL_UNDEF(&EG(user_error_handler));
    1855             :         } else {
    1856             :                 zval *tmp;
    1857           0 :                 EG(user_error_handler_error_reporting) = zend_stack_int_top(&EG(user_error_handlers_error_reporting));
    1858           0 :                 zend_stack_del_top(&EG(user_error_handlers_error_reporting));
    1859           0 :                 tmp = zend_stack_top(&EG(user_error_handlers));
    1860           0 :                 ZVAL_COPY_VALUE(&EG(user_error_handler), tmp);
    1861           0 :                 zend_stack_del_top(&EG(user_error_handlers));
    1862             :         }
    1863           4 :         RETURN_TRUE;
    1864             : }
    1865             : /* }}} */
    1866             : 
    1867             : /* {{{ proto mixed set_exception_handler(callable exception_handler)
    1868             :    Sets a user-defined exception handler function. Returns the previously defined exception handler, or false on error */
    1869          19 : ZEND_FUNCTION(set_exception_handler)
    1870             : {
    1871             :         zval *exception_handler;
    1872          19 :         zend_string *exception_handler_name = NULL;
    1873             : 
    1874          19 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &exception_handler) == FAILURE) {
    1875           2 :                 return;
    1876             :         }
    1877             : 
    1878          34 :         if (Z_TYPE_P(exception_handler) != IS_NULL) { /* NULL == unset */
    1879          16 :                 if (!zend_is_callable(exception_handler, 0, &exception_handler_name)) {
    1880           4 :                         zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
    1881           4 :                                            get_active_function_name(), exception_handler_name?ZSTR_VAL(exception_handler_name):"unknown");
    1882           2 :                         zend_string_release(exception_handler_name);
    1883           2 :                         return;
    1884             :                 }
    1885          14 :                 zend_string_release(exception_handler_name);
    1886             :         }
    1887             : 
    1888          15 :         if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
    1889           3 :                 ZVAL_COPY(return_value, &EG(user_exception_handler));
    1890             : 
    1891           3 :                 zend_stack_push(&EG(user_exception_handlers), &EG(user_exception_handler));
    1892             :         }
    1893             : 
    1894          30 :         if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined handler */
    1895           1 :                 ZVAL_UNDEF(&EG(user_exception_handler));
    1896           1 :                 return;
    1897             :         }
    1898             : 
    1899          14 :         ZVAL_COPY(&EG(user_exception_handler), exception_handler);
    1900             : }
    1901             : /* }}} */
    1902             : 
    1903             : /* {{{ proto void restore_exception_handler(void)
    1904             :    Restores the previously defined exception handler function */
    1905           1 : ZEND_FUNCTION(restore_exception_handler)
    1906             : {
    1907           1 :         if (zend_parse_parameters_none() == FAILURE) {
    1908           0 :                 return;
    1909             :         }
    1910             : 
    1911           1 :         if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
    1912           1 :                 zval_ptr_dtor(&EG(user_exception_handler));
    1913             :         }
    1914           1 :         if (zend_stack_is_empty(&EG(user_exception_handlers))) {
    1915           0 :                 ZVAL_UNDEF(&EG(user_exception_handler));
    1916             :         } else {
    1917           1 :                 zval *tmp = zend_stack_top(&EG(user_exception_handlers));
    1918           1 :                 ZVAL_COPY_VALUE(&EG(user_exception_handler), tmp);
    1919           1 :                 zend_stack_del_top(&EG(user_exception_handlers));
    1920             :         }
    1921           1 :         RETURN_TRUE;
    1922             : }
    1923             : /* }}} */
    1924             : 
    1925        5468 : static int copy_class_or_interface_name(zval *el, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
    1926             : {
    1927        5468 :         zend_class_entry *ce = (zend_class_entry *)Z_PTR_P(el);
    1928        5468 :         zval *array = va_arg(args, zval *);
    1929        5468 :         uint32_t mask = va_arg(args, uint32_t);
    1930        5468 :         uint32_t comply = va_arg(args, uint32_t);
    1931        5468 :         uint32_t comply_mask = (comply)? mask:0;
    1932             : 
    1933       10932 :         if ((hash_key->key && ZSTR_VAL(hash_key->key)[0] != 0)
    1934        5464 :                 && (comply_mask == (ce->ce_flags & mask))) {
    1935        1923 :                 if (ce->refcount > 1 &&
    1936           2 :                     !same_name(hash_key->key, ce->name)) {
    1937           2 :                         add_next_index_str(array, zend_string_copy(hash_key->key));
    1938             :                 } else {
    1939        3838 :                         add_next_index_str(array, zend_string_copy(ce->name));
    1940             :                 }
    1941             :         }
    1942        5468 :         return ZEND_HASH_APPLY_KEEP;
    1943             : }
    1944             : /* }}} */
    1945             : 
    1946             : /* {{{ proto array get_declared_traits()
    1947             :    Returns an array of all declared traits. */
    1948          11 : ZEND_FUNCTION(get_declared_traits)
    1949             : {
    1950          11 :         uint32_t mask = ZEND_ACC_TRAIT;
    1951          11 :         uint32_t comply = 1;
    1952             : 
    1953          11 :         if (zend_parse_parameters_none() == FAILURE) {
    1954           1 :                 return;
    1955             :         }
    1956             : 
    1957          10 :         array_init(return_value);
    1958          10 :         zend_hash_apply_with_arguments(EG(class_table), copy_class_or_interface_name, 3, return_value, mask, comply);
    1959             : }
    1960             : /* }}} */
    1961             : 
    1962             : /* {{{ proto array get_declared_classes()
    1963             :    Returns an array of all declared classes. */
    1964          11 : ZEND_FUNCTION(get_declared_classes)
    1965             : {
    1966          11 :         uint32_t mask = ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT;
    1967          11 :         uint32_t comply = 0;
    1968             : 
    1969          11 :         if (zend_parse_parameters_none() == FAILURE) {
    1970           1 :                 return;
    1971             :         }
    1972             : 
    1973          10 :         array_init(return_value);
    1974          10 :         zend_hash_apply_with_arguments(EG(class_table), copy_class_or_interface_name, 3, return_value, mask, comply);
    1975             : }
    1976             : /* }}} */
    1977             : 
    1978             : /* {{{ proto array get_declared_interfaces()
    1979             :    Returns an array of all declared interfaces. */
    1980          10 : ZEND_FUNCTION(get_declared_interfaces)
    1981             : {
    1982          10 :         uint32_t mask = ZEND_ACC_INTERFACE;
    1983          10 :         uint32_t comply = 1;
    1984             : 
    1985          10 :         if (zend_parse_parameters_none() == FAILURE) {
    1986           2 :                 return;
    1987             :         }
    1988             : 
    1989           8 :         array_init(return_value);
    1990           8 :         zend_hash_apply_with_arguments(EG(class_table), copy_class_or_interface_name, 3, return_value, mask, comply);
    1991             : }
    1992             : /* }}} */
    1993             : 
    1994        8829 : static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
    1995             : {
    1996        8829 :         zend_function *func = Z_PTR_P(zv);
    1997        8829 :         zval *internal_ar = va_arg(args, zval *),
    1998        8829 :              *user_ar     = va_arg(args, zval *);
    1999             : 
    2000        8829 :         if (hash_key->key == NULL || ZSTR_VAL(hash_key->key)[0] == 0) {
    2001           0 :                 return 0;
    2002             :         }
    2003             : 
    2004        8829 :         if (func->type == ZEND_INTERNAL_FUNCTION) {
    2005       17640 :                 add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
    2006           9 :         } else if (func->type == ZEND_USER_FUNCTION) {
    2007          18 :                 add_next_index_str(user_ar, zend_string_copy(hash_key->key));
    2008             :         }
    2009             : 
    2010        8829 :         return 0;
    2011             : }
    2012             : /* }}} */
    2013             : 
    2014             : /* {{{ proto array get_defined_functions(void)
    2015             :    Returns an array of all defined functions */
    2016           6 : ZEND_FUNCTION(get_defined_functions)
    2017             : {
    2018             :         zval internal, user;
    2019             : 
    2020           6 :         if (zend_parse_parameters_none() == FAILURE) {
    2021           2 :                 return;
    2022             :         }
    2023             : 
    2024           4 :         array_init(&internal);
    2025           4 :         array_init(&user);
    2026           4 :         array_init(return_value);
    2027             : 
    2028           4 :         zend_hash_apply_with_arguments(EG(function_table), copy_function_name, 2, &internal, &user);
    2029             : 
    2030           4 :         zend_hash_str_add_new(Z_ARRVAL_P(return_value), "internal", sizeof("internal")-1, &internal);
    2031           4 :         zend_hash_str_add_new(Z_ARRVAL_P(return_value), "user", sizeof("user")-1, &user);
    2032             : }
    2033             : /* }}} */
    2034             : 
    2035             : /* {{{ proto array get_defined_vars(void)
    2036             :    Returns an associative array of names and values of all currently defined variable names (variables in the current scope) */
    2037          19 : ZEND_FUNCTION(get_defined_vars)
    2038             : {
    2039             :         zend_array *symbol_table;
    2040          19 :         if (zend_forbid_dynamic_call("get_defined_vars()") == FAILURE) {
    2041           2 :                 return;
    2042             :         }
    2043             : 
    2044          17 :         symbol_table = zend_rebuild_symbol_table();
    2045          17 :         if (UNEXPECTED(symbol_table == NULL)) {
    2046           0 :                 return;
    2047             :         }
    2048             : 
    2049          17 :         RETURN_ARR(zend_array_dup(symbol_table));
    2050             : }
    2051             : /* }}} */
    2052             : 
    2053             : #define LAMBDA_TEMP_FUNCNAME    "__lambda_func"
    2054             : /* {{{ proto string create_function(string args, string code)
    2055             :    Creates an anonymous function, and returns its name (funny, eh?) */
    2056          61 : ZEND_FUNCTION(create_function)
    2057             : {
    2058             :     zend_string *function_name;
    2059             :         char *eval_code, *function_args, *function_code;
    2060             :         size_t eval_code_length, function_args_len, function_code_len;
    2061             :         int retval;
    2062             :         char *eval_name;
    2063             : 
    2064          61 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &function_args, &function_args_len, &function_code, &function_code_len) == FAILURE) {
    2065           0 :                 return;
    2066             :         }
    2067             : 
    2068          61 :         eval_code = (char *) emalloc(sizeof("function " LAMBDA_TEMP_FUNCNAME)
    2069             :                         +function_args_len
    2070             :                         +2      /* for the args parentheses */
    2071             :                         +2      /* for the curly braces */
    2072             :                         +function_code_len);
    2073             : 
    2074          61 :         eval_code_length = sizeof("function " LAMBDA_TEMP_FUNCNAME "(") - 1;
    2075          61 :         memcpy(eval_code, "function " LAMBDA_TEMP_FUNCNAME "(", eval_code_length);
    2076             : 
    2077          61 :         memcpy(eval_code + eval_code_length, function_args, function_args_len);
    2078          61 :         eval_code_length += function_args_len;
    2079             : 
    2080          61 :         eval_code[eval_code_length++] = ')';
    2081          61 :         eval_code[eval_code_length++] = '{';
    2082             : 
    2083          61 :         memcpy(eval_code + eval_code_length, function_code, function_code_len);
    2084          61 :         eval_code_length += function_code_len;
    2085             : 
    2086          61 :         eval_code[eval_code_length++] = '}';
    2087          61 :         eval_code[eval_code_length] = '\0';
    2088             : 
    2089          61 :         eval_name = zend_make_compiled_string_description("runtime-created function");
    2090          61 :         retval = zend_eval_stringl(eval_code, eval_code_length, NULL, eval_name);
    2091          61 :         efree(eval_code);
    2092          61 :         efree(eval_name);
    2093             : 
    2094          61 :         if (retval==SUCCESS) {
    2095             :                 zend_op_array *func;
    2096             :                 HashTable *static_variables;
    2097             : 
    2098         118 :                 func = zend_hash_str_find_ptr(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1);
    2099          59 :                 if (!func) {
    2100           0 :                         zend_error_noreturn(E_CORE_ERROR, "Unexpected inconsistency in create_function()");
    2101             :                         RETURN_FALSE;
    2102             :                 }
    2103          59 :                 if (func->refcount) {
    2104          59 :                         (*func->refcount)++;
    2105             :                 }
    2106          59 :                 static_variables = func->static_variables;
    2107          59 :                 func->static_variables = NULL;
    2108          59 :                 zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1);
    2109          59 :                 func->static_variables = static_variables;
    2110             : 
    2111          59 :                 function_name = zend_string_alloc(sizeof("0lambda_")+MAX_LENGTH_OF_LONG, 0);
    2112          59 :                 ZSTR_VAL(function_name)[0] = '\0';
    2113             : 
    2114             :                 do {
    2115          59 :                         ZSTR_LEN(function_name) = snprintf(ZSTR_VAL(function_name) + 1, sizeof("lambda_")+MAX_LENGTH_OF_LONG, "lambda_%d", ++EG(lambda_count)) + 1;
    2116         118 :                 } while (zend_hash_add_ptr(EG(function_table), function_name, func) == NULL);
    2117          59 :                 RETURN_NEW_STR(function_name);
    2118             :         } else {
    2119           2 :                 zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1);
    2120           2 :                 RETURN_FALSE;
    2121             :         }
    2122             : }
    2123             : /* }}} */
    2124             : 
    2125             : #if ZEND_DEBUG
    2126             : ZEND_FUNCTION(zend_test_func)
    2127             : {
    2128             :         zval *arg1, *arg2;
    2129             : 
    2130             :         zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2);
    2131             : }
    2132             : 
    2133             : ZEND_FUNCTION(zend_test_func2)
    2134             : {
    2135             :         zval *arg1, *arg2;
    2136             : 
    2137             :         zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &arg1, &arg2);
    2138             : }
    2139             : 
    2140             : #ifdef ZTS
    2141             : ZEND_FUNCTION(zend_thread_id)
    2142             : {
    2143             :         RETURN_LONG((zend_long)tsrm_thread_id());
    2144             : }
    2145             : #endif
    2146             : #endif
    2147             : 
    2148             : /* {{{ proto string get_resource_type(resource res)
    2149             :    Get the resource type name for a given resource */
    2150          77 : ZEND_FUNCTION(get_resource_type)
    2151             : {
    2152             :         const char *resource_type;
    2153             :         zval *z_resource_type;
    2154             : 
    2155          77 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &z_resource_type) == FAILURE) {
    2156          12 :                 return;
    2157             :         }
    2158             : 
    2159          65 :         resource_type = zend_rsrc_list_get_rsrc_type(Z_RES_P(z_resource_type));
    2160          65 :         if (resource_type) {
    2161          80 :                 RETURN_STRING(resource_type);
    2162             :         } else {
    2163          50 :                 RETURN_STRING("Unknown");
    2164             :         }
    2165             : }
    2166             : /* }}} */
    2167             : 
    2168             : /* {{{ proto array get_resources([string resouce_type])
    2169             :    Get an array with all active resources */
    2170           7 : ZEND_FUNCTION(get_resources)
    2171             : {
    2172           7 :         zend_string *type = NULL;
    2173             :         zend_string *key;
    2174             :         zend_ulong index;
    2175             :         zval *val;
    2176             : 
    2177           7 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &type) == FAILURE) {
    2178           0 :                 return;
    2179             :         }
    2180             : 
    2181           7 :         if (!type) {
    2182           7 :                 array_init(return_value);
    2183         101 :                 ZEND_HASH_FOREACH_KEY_VAL(&EG(regular_list), index, key, val) {
    2184          32 :                         if (!key) {
    2185             :                                 Z_ADDREF_P(val);
    2186          32 :                                 zend_hash_index_add_new(Z_ARRVAL_P(return_value), index, val);
    2187             :                         }
    2188             :                 } ZEND_HASH_FOREACH_END();
    2189           0 :         } else if (zend_string_equals_literal(type, "Unknown")) {
    2190           0 :                 array_init(return_value);
    2191           0 :                 ZEND_HASH_FOREACH_KEY_VAL(&EG(regular_list), index, key, val) {
    2192           0 :                         if (!key && Z_RES_TYPE_P(val) <= 0) {
    2193             :                                 Z_ADDREF_P(val);
    2194           0 :                                 zend_hash_index_add_new(Z_ARRVAL_P(return_value), index, val);
    2195             :                         }
    2196             :                 } ZEND_HASH_FOREACH_END();
    2197             :         } else {
    2198           0 :                 int id = zend_fetch_list_dtor_id(ZSTR_VAL(type));
    2199             : 
    2200           0 :                 if (id <= 0) {
    2201           0 :                         zend_error(E_WARNING, "get_resources():  Unknown resource type '%s'", ZSTR_VAL(type));
    2202           0 :                         RETURN_FALSE;
    2203             :                 }
    2204             : 
    2205           0 :                 array_init(return_value);
    2206           0 :                 ZEND_HASH_FOREACH_KEY_VAL(&EG(regular_list), index, key, val) {
    2207           0 :                         if (!key && Z_RES_TYPE_P(val) == id) {
    2208             :                                 Z_ADDREF_P(val);
    2209           0 :                                 zend_hash_index_add_new(Z_ARRVAL_P(return_value), index, val);
    2210             :                         }
    2211             :                 } ZEND_HASH_FOREACH_END();
    2212             :         }
    2213             : }
    2214             : /* }}} */
    2215             : 
    2216         280 : static int add_extension_info(zval *item, void *arg) /* {{{ */
    2217             : {
    2218         280 :         zval *name_array = (zval *)arg;
    2219         280 :         zend_module_entry *module = (zend_module_entry*)Z_PTR_P(item);
    2220         280 :         add_next_index_string(name_array, module->name);
    2221         280 :         return 0;
    2222             : }
    2223             : /* }}} */
    2224             : 
    2225           2 : static int add_zendext_info(zend_extension *ext, void *arg) /* {{{ */
    2226             : {
    2227           2 :         zval *name_array = (zval *)arg;
    2228           2 :         add_next_index_string(name_array, ext->name);
    2229           2 :         return 0;
    2230             : }
    2231             : /* }}} */
    2232             : 
    2233       28416 : static int add_constant_info(zval *item, void *arg) /* {{{ */
    2234             : {
    2235       28416 :         zval *name_array = (zval *)arg;
    2236       28416 :         zend_constant *constant = (zend_constant*)Z_PTR_P(item);
    2237             :         zval const_val;
    2238             : 
    2239       28416 :         if (!constant->name) {
    2240             :                 /* skip special constants */
    2241           0 :                 return 0;
    2242             :         }
    2243             : 
    2244       28416 :         ZVAL_DUP(&const_val, &constant->value);
    2245       28416 :         zend_hash_add_new(Z_ARRVAL_P(name_array), constant->name, &const_val);
    2246       28416 :         return 0;
    2247             : }
    2248             : /* }}} */
    2249             : 
    2250             : /* {{{ proto array get_loaded_extensions([bool zend_extensions])
    2251             :    Return an array containing names of loaded extensions */
    2252           7 : ZEND_FUNCTION(get_loaded_extensions)
    2253             : {
    2254           7 :         zend_bool zendext = 0;
    2255             : 
    2256           7 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &zendext) == FAILURE) {
    2257           1 :                 return;
    2258             :         }
    2259             : 
    2260           6 :         array_init(return_value);
    2261             : 
    2262           6 :         if (zendext) {
    2263           2 :                 zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t)add_zendext_info, return_value);
    2264             :         } else {
    2265           4 :                 zend_hash_apply_with_argument(&module_registry, add_extension_info, return_value);
    2266             :         }
    2267             : }
    2268             : /* }}} */
    2269             : 
    2270             : /* {{{ proto array get_defined_constants([bool categorize])
    2271             :    Return an array containing the names and values of all defined constants */
    2272          38 : ZEND_FUNCTION(get_defined_constants)
    2273             : {
    2274          38 :         zend_bool categorize = 0;
    2275             : 
    2276          38 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &categorize) == FAILURE) {
    2277           2 :                 return;
    2278             :         }
    2279             : 
    2280          36 :         array_init(return_value);
    2281             : 
    2282          36 :         if (categorize) {
    2283             :                 zend_constant *val;
    2284             :                 int module_number;
    2285             :                 zval *modules, const_val;
    2286             :                 char **module_names;
    2287             :                 zend_module_entry *module;
    2288          25 :                 int i = 1;
    2289             : 
    2290          25 :                 modules = ecalloc(zend_hash_num_elements(&module_registry) + 2, sizeof(zval));
    2291          25 :                 module_names = emalloc((zend_hash_num_elements(&module_registry) + 2) * sizeof(char *));
    2292             : 
    2293          25 :                 module_names[0] = "internal";
    2294        3525 :                 ZEND_HASH_FOREACH_PTR(&module_registry, module) {
    2295        1750 :                         module_names[module->module_number] = (char *)module->name;
    2296        1750 :                         i++;
    2297             :                 } ZEND_HASH_FOREACH_END();
    2298          25 :                 module_names[i] = "user";
    2299             : 
    2300      129177 :                 ZEND_HASH_FOREACH_PTR(EG(zend_constants), val) {
    2301       64576 :                         if (!val->name) {
    2302             :                                 /* skip special constants */
    2303           0 :                                 continue;
    2304             :                         }
    2305             : 
    2306       64576 :                         if (val->module_number == PHP_USER_CONSTANT) {
    2307           1 :                                 module_number = i;
    2308       64575 :                         } else if (val->module_number > i || val->module_number < 0) {
    2309             :                                 /* should not happen */
    2310           0 :                                 continue;
    2311             :                         } else {
    2312       64575 :                                 module_number = val->module_number;
    2313             :                         }
    2314             : 
    2315      129152 :                         if (Z_TYPE(modules[module_number]) == IS_UNDEF) {
    2316        1076 :                                 array_init(&modules[module_number]);
    2317        1076 :                                 add_assoc_zval(return_value, module_names[module_number], &modules[module_number]);
    2318             :                         }
    2319             : 
    2320       64576 :                         ZVAL_DUP(&const_val, &val->value);
    2321       64576 :                         zend_hash_add_new(Z_ARRVAL(modules[module_number]), val->name, &const_val);
    2322             :                 } ZEND_HASH_FOREACH_END();
    2323             : 
    2324          25 :                 efree(module_names);
    2325          25 :                 efree(modules);
    2326             :         } else {
    2327          11 :                 zend_hash_apply_with_argument(EG(zend_constants), add_constant_info, return_value);
    2328             :         }
    2329             : }
    2330             : /* }}} */
    2331             : 
    2332        3783 : static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) /* {{{ */
    2333             : {
    2334        3783 :         uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
    2335             : 
    2336        3783 :         array_init_size(arg_array, num_args);
    2337        3783 :         if (num_args) {
    2338        2996 :                 uint32_t i = 0;
    2339        2996 :                 uint32_t n = 0;
    2340        2996 :                 zval *p = ZEND_CALL_ARG(call, 1);
    2341             : 
    2342        2996 :                 zend_hash_real_init(Z_ARRVAL_P(arg_array), 1);
    2343        2996 :                 ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(arg_array)) {
    2344        2996 :                         if (call->func->type == ZEND_USER_FUNCTION) {
    2345         887 :                                 uint32_t first_extra_arg = call->func->op_array.num_args;
    2346             : 
    2347         887 :                                 if (ZEND_CALL_NUM_ARGS(call) > first_extra_arg) {
    2348         220 :                                         while (i < first_extra_arg) {
    2349          88 :                                                 if (EXPECTED(Z_TYPE_INFO_P(p) != IS_UNDEF)) {
    2350          82 :                                                         if (Z_OPT_REFCOUNTED_P(p)) {
    2351             :                                                                 Z_ADDREF_P(p);
    2352             :                                                         }
    2353          82 :                                                         n++;
    2354             :                                                 }
    2355          88 :                                                 ZEND_HASH_FILL_ADD(p);
    2356          88 :                                                 p++;
    2357          88 :                                                 i++;
    2358             :                                         }
    2359          66 :                                         p = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var + call->func->op_array.T);
    2360             :                                 }
    2361             :                         }
    2362             : 
    2363       12145 :                         while (i < num_args) {
    2364        6153 :                                 if (EXPECTED(Z_TYPE_INFO_P(p) != IS_UNDEF)) {
    2365        6153 :                                         if (Z_OPT_REFCOUNTED_P(p)) {
    2366             :                                                 Z_ADDREF_P(p);
    2367             :                                         }
    2368        6153 :                                         n++;
    2369             :                                 }
    2370        6153 :                                 ZEND_HASH_FILL_ADD(p);
    2371        6153 :                                 p++;
    2372        6153 :                                 i++;
    2373             :                         }
    2374        2996 :                 } ZEND_HASH_FILL_END();
    2375        2996 :                 Z_ARRVAL_P(arg_array)->nNumOfElements = n;
    2376             :         }
    2377        3783 : }
    2378             : /* }}} */
    2379             : 
    2380          56 : void debug_print_backtrace_args(zval *arg_array) /* {{{ */
    2381             : {
    2382             :         zval *tmp;
    2383          56 :         int i = 0;
    2384             : 
    2385         162 :         ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(arg_array), tmp) {
    2386          53 :                 if (i++) {
    2387          29 :                         ZEND_PUTS(", ");
    2388             :                 }
    2389          53 :                 zend_print_flat_zval_r(tmp);
    2390             :         } ZEND_HASH_FOREACH_END();
    2391          56 : }
    2392             : /* }}} */
    2393             : 
    2394             : /* {{{ proto void debug_print_backtrace([int options[, int limit]]) */
    2395          35 : ZEND_FUNCTION(debug_print_backtrace)
    2396             : {
    2397             :         zend_execute_data *call, *ptr, *skip;
    2398             :         zend_object *object;
    2399          35 :         int lineno, frameno = 0;
    2400             :         zend_function *func;
    2401             :         const char *function_name;
    2402             :         const char *filename;
    2403          35 :         zend_string *class_name = NULL;
    2404             :         char *call_type;
    2405          35 :         const char *include_filename = NULL;
    2406             :         zval arg_array;
    2407          35 :         int indent = 0;
    2408          35 :         zend_long options = 0;
    2409          35 :         zend_long limit = 0;
    2410             : 
    2411          35 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &options, &limit) == FAILURE) {
    2412           0 :                 return;
    2413             :         }
    2414             : 
    2415          35 :         ZVAL_UNDEF(&arg_array);
    2416          35 :         ptr = EX(prev_execute_data);
    2417             : 
    2418             :         /* skip debug_backtrace() */
    2419          35 :         call = ptr;
    2420          35 :         ptr = ptr->prev_execute_data;
    2421             : 
    2422         143 :         while (ptr && (limit == 0 || frameno < limit)) {
    2423          73 :                 frameno++;
    2424          73 :                 class_name = NULL;
    2425          73 :                 call_type = NULL;
    2426          73 :                 ZVAL_UNDEF(&arg_array);
    2427             : 
    2428          73 :                 ptr = zend_generator_check_placeholder_frame(ptr);
    2429             : 
    2430          73 :                 skip = ptr;
    2431             :                 /* skip internal handler */
    2432         113 :                 if ((!skip->func || !ZEND_USER_CODE(skip->func->common.type)) &&
    2433           7 :                     skip->prev_execute_data &&
    2434           7 :                     skip->prev_execute_data->func &&
    2435           7 :                     ZEND_USER_CODE(skip->prev_execute_data->func->common.type) &&
    2436           7 :                     skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL &&
    2437           3 :                     skip->prev_execute_data->opline->opcode != ZEND_DO_ICALL &&
    2438           3 :                     skip->prev_execute_data->opline->opcode != ZEND_DO_UCALL &&
    2439           3 :                     skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL_BY_NAME &&
    2440           3 :                     skip->prev_execute_data->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
    2441           1 :                         skip = skip->prev_execute_data;
    2442             :                 }
    2443             : 
    2444         140 :                 if (skip->func && ZEND_USER_CODE(skip->func->common.type)) {
    2445          67 :                         filename = ZSTR_VAL(skip->func->op_array.filename);
    2446          67 :                         if (skip->opline->opcode == ZEND_HANDLE_EXCEPTION) {
    2447           0 :                                 if (EG(opline_before_exception)) {
    2448           0 :                                         lineno = EG(opline_before_exception)->lineno;
    2449             :                                 } else {
    2450           0 :                                         lineno = skip->func->op_array.line_end;
    2451             :                                 }
    2452             :                         } else {
    2453          67 :                                 lineno = skip->opline->lineno;
    2454             :                         }
    2455             :                 } else {
    2456           6 :                         filename = NULL;
    2457           6 :                         lineno = 0;
    2458             :                 }
    2459             : 
    2460             :                 /* $this may be passed into regular internal functions */
    2461         146 :                 object = (Z_TYPE(call->This) == IS_OBJECT) ? Z_OBJ(call->This) : NULL;
    2462             : 
    2463          73 :                 if (call->func) {
    2464          71 :                         func = call->func;
    2465         238 :                         function_name = (func->common.scope &&
    2466          35 :                                          func->common.scope->trait_aliases) ?
    2467           9 :                                 ZSTR_VAL(zend_resolve_method_name(
    2468             :                                         (object ? object->ce : func->common.scope), func)) :
    2469          62 :                                 (func->common.function_name ?
    2470          61 :                                         ZSTR_VAL(func->common.function_name) : NULL);
    2471             :                 } else {
    2472           2 :                         func = NULL;
    2473           2 :                         function_name = NULL;
    2474             :                 }
    2475             : 
    2476          73 :                 if (function_name) {
    2477          70 :                         if (object) {
    2478          21 :                                 if (func->common.scope) {
    2479          21 :                                         class_name = func->common.scope->name;
    2480           0 :                                 } else if (object->handlers->get_class_name == std_object_handlers.get_class_name) {
    2481           0 :                                         class_name = object->ce->name;
    2482             :                                 } else {
    2483           0 :                                         class_name = object->handlers->get_class_name(object);
    2484             :                                 }
    2485             : 
    2486          21 :                                 call_type = "->";
    2487          49 :                         } else if (func->common.scope) {
    2488          14 :                                 class_name = func->common.scope->name;
    2489          14 :                                 call_type = "::";
    2490             :                         } else {
    2491          35 :                                 class_name = NULL;
    2492          35 :                                 call_type = NULL;
    2493             :                         }
    2494          70 :                         if (func->type != ZEND_EVAL_CODE) {
    2495          70 :                                 if ((options & DEBUG_BACKTRACE_IGNORE_ARGS) == 0) {
    2496          56 :                                         debug_backtrace_get_args(call, &arg_array);
    2497             :                                 }
    2498             :                         }
    2499             :                 } else {
    2500             :                         /* i know this is kinda ugly, but i'm trying to avoid extra cycles in the main execution loop */
    2501           3 :                         zend_bool build_filename_arg = 1;
    2502             : 
    2503           3 :                         if (!ptr->func || !ZEND_USER_CODE(ptr->func->common.type) || ptr->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
    2504             :                                 /* can happen when calling eval from a custom sapi */
    2505           0 :                                 function_name = "unknown";
    2506           0 :                                 build_filename_arg = 0;
    2507             :                         } else
    2508           3 :                         switch (ptr->opline->extended_value) {
    2509             :                                 case ZEND_EVAL:
    2510           1 :                                         function_name = "eval";
    2511           1 :                                         build_filename_arg = 0;
    2512           1 :                                         break;
    2513             :                                 case ZEND_INCLUDE:
    2514           2 :                                         function_name = "include";
    2515           2 :                                         break;
    2516             :                                 case ZEND_REQUIRE:
    2517           0 :                                         function_name = "require";
    2518           0 :                                         break;
    2519             :                                 case ZEND_INCLUDE_ONCE:
    2520           0 :                                         function_name = "include_once";
    2521           0 :                                         break;
    2522             :                                 case ZEND_REQUIRE_ONCE:
    2523           0 :                                         function_name = "require_once";
    2524           0 :                                         break;
    2525             :                                 default:
    2526             :                                         /* this can actually happen if you use debug_backtrace() in your error_handler and
    2527             :                                          * you're in the top-scope */
    2528           0 :                                         function_name = "unknown";
    2529           0 :                                         build_filename_arg = 0;
    2530             :                                         break;
    2531             :                         }
    2532             : 
    2533           3 :                         if (build_filename_arg && include_filename) {
    2534           0 :                                 array_init(&arg_array);
    2535           0 :                                 add_next_index_string(&arg_array, (char*)include_filename);
    2536             :                         }
    2537           3 :                         call_type = NULL;
    2538             :                 }
    2539          73 :                 zend_printf("#%-2d ", indent);
    2540          73 :                 if (class_name) {
    2541          35 :                         ZEND_PUTS(ZSTR_VAL(class_name));
    2542          35 :                         ZEND_PUTS(call_type);
    2543          56 :                         if (object
    2544          21 :                           && !func->common.scope
    2545           0 :                           && object->handlers->get_class_name != std_object_handlers.get_class_name) {
    2546             :                                 zend_string_release(class_name);
    2547             :                         }
    2548             :                 }
    2549          73 :                 zend_printf("%s(", function_name);
    2550          73 :                 if (Z_TYPE(arg_array) != IS_UNDEF) {
    2551          56 :                         debug_print_backtrace_args(&arg_array);
    2552          56 :                         zval_ptr_dtor(&arg_array);
    2553             :                 }
    2554          73 :                 if (filename) {
    2555          67 :                         zend_printf(") called at [%s:%d]\n", filename, lineno);
    2556             :                 } else {
    2557           6 :                         zend_execute_data *prev_call = skip;
    2558           6 :                         zend_execute_data *prev = skip->prev_execute_data;
    2559             : 
    2560          12 :                         while (prev) {
    2561          16 :                                 if (prev_call &&
    2562           6 :                                     prev_call->func &&
    2563           4 :                                         !ZEND_USER_CODE(prev_call->func->common.type)) {
    2564           4 :                                         prev = NULL;
    2565           4 :                                         break;
    2566             :                                 }
    2567           2 :                                 if (prev->func && ZEND_USER_CODE(prev->func->common.type)) {
    2568           2 :                                         zend_printf(") called at [%s:%d]\n", ZSTR_VAL(prev->func->op_array.filename), prev->opline->lineno);
    2569           2 :                                         break;
    2570             :                                 }
    2571           0 :                                 prev_call = prev;
    2572           0 :                                 prev = prev->prev_execute_data;
    2573             :                         }
    2574           6 :                         if (!prev) {
    2575           4 :                                 ZEND_PUTS(")\n");
    2576             :                         }
    2577             :                 }
    2578          73 :                 include_filename = filename;
    2579          73 :                 call = skip;
    2580          73 :                 ptr = skip->prev_execute_data;
    2581          73 :                 ++indent;
    2582             :         }
    2583             : }
    2584             : 
    2585             : /* }}} */
    2586             : 
    2587        3258 : ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit) /* {{{ */
    2588             : {
    2589        3258 :         zend_execute_data *ptr, *skip, *call = NULL;
    2590             :         zend_object *object;
    2591        3258 :         int lineno, frameno = 0;
    2592             :         zend_function *func;
    2593             :         zend_string *function_name;
    2594             :         zend_string *filename;
    2595        3258 :         zend_string *include_filename = NULL;
    2596             :         zval stack_frame, tmp;
    2597             : 
    2598        3258 :         array_init(return_value);
    2599             : 
    2600        3258 :         if (!(ptr = EG(current_execute_data))) {
    2601           0 :                 return;
    2602             :         }
    2603             : 
    2604        3258 :         if (!ptr->func || !ZEND_USER_CODE(ptr->func->common.type)) {
    2605        1737 :                 call = ptr;
    2606        1737 :                 ptr = ptr->prev_execute_data;
    2607             :         }
    2608             : 
    2609        3258 :         if (ptr) {
    2610        3258 :                 if (skip_last) {
    2611             :                         /* skip debug_backtrace() */
    2612          51 :                         call = ptr;
    2613          51 :                         ptr = ptr->prev_execute_data;
    2614             :                 } else {
    2615             :                         /* skip "new Exception()" */
    2616        3207 :                         if (ptr->func && ZEND_USER_CODE(ptr->func->common.type) && (ptr->opline->opcode == ZEND_NEW)) {
    2617         583 :                                 call = ptr;
    2618         583 :                                 ptr = ptr->prev_execute_data;
    2619             :                         }
    2620             :                 }
    2621        3258 :                 if (!call) {
    2622         935 :                         call = ptr;
    2623         935 :                         ptr = ptr->prev_execute_data;
    2624             :                 }
    2625             :         }
    2626             : 
    2627       10385 :         while (ptr && (limit == 0 || frameno < limit)) {
    2628        3869 :                 frameno++;
    2629        3869 :                 array_init(&stack_frame);
    2630             : 
    2631        3869 :                 ptr = zend_generator_check_placeholder_frame(ptr);
    2632             : 
    2633        3869 :                 skip = ptr;
    2634             :                 /* skip internal handler */
    2635        7758 :                 if ((!skip->func || !ZEND_USER_CODE(skip->func->common.type)) &&
    2636         803 :                     skip->prev_execute_data &&
    2637         790 :                     skip->prev_execute_data->func &&
    2638         778 :                     ZEND_USER_CODE(skip->prev_execute_data->func->common.type) &&
    2639         762 :                     skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL &&
    2640         272 :                     skip->prev_execute_data->opline->opcode != ZEND_DO_ICALL &&
    2641         164 :                     skip->prev_execute_data->opline->opcode != ZEND_DO_UCALL &&
    2642         164 :                     skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL_BY_NAME &&
    2643         156 :                     skip->prev_execute_data->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
    2644         153 :                         skip = skip->prev_execute_data;
    2645             :                 }
    2646             : 
    2647        7088 :                 if (skip->func && ZEND_USER_CODE(skip->func->common.type)) {
    2648        3219 :                         filename = skip->func->op_array.filename;
    2649        3219 :                         if (skip->opline->opcode == ZEND_HANDLE_EXCEPTION) {
    2650           2 :                                 if (EG(opline_before_exception)) {
    2651           2 :                                         lineno = EG(opline_before_exception)->lineno;
    2652             :                                 } else {
    2653           0 :                                         lineno = skip->func->op_array.line_end;
    2654             :                                 }
    2655             :                         } else {
    2656        3217 :                                 lineno = skip->opline->lineno;
    2657             :                         }
    2658        3219 :                         ZVAL_STR_COPY(&tmp, filename);
    2659        3219 :                         zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_FILE], &tmp);
    2660        3219 :                         ZVAL_LONG(&tmp, lineno);
    2661        3219 :                         zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_LINE], &tmp);
    2662             : 
    2663             :                         /* try to fetch args only if an FCALL was just made - elsewise we're in the middle of a function
    2664             :                          * and debug_baktrace() might have been called by the error_handler. in this case we don't
    2665             :                          * want to pop anything of the argument-stack */
    2666             :                 } else {
    2667         650 :                         zend_execute_data *prev_call = skip;
    2668         650 :                         zend_execute_data *prev = skip->prev_execute_data;
    2669             : 
    2670        1300 :                         while (prev) {
    2671        2542 :                                 if (prev_call &&
    2672         637 :                                     prev_call->func &&
    2673         634 :                                         !ZEND_USER_CODE(prev_call->func->common.type) &&
    2674         634 :                                         !(prev_call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
    2675         632 :                                         break;
    2676             :                                 }
    2677           5 :                                 if (prev->func && ZEND_USER_CODE(prev->func->common.type)) {
    2678           5 :                                         ZVAL_STR_COPY(&tmp, prev->func->op_array.filename);
    2679           5 :                                         zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_FILE], &tmp);
    2680           5 :                                         ZVAL_LONG(&tmp, prev->opline->lineno);
    2681           5 :                                         zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_LINE], &tmp);
    2682           5 :                                         break;
    2683             :                                 }
    2684           0 :                                 prev_call = prev;
    2685           0 :                                 prev = prev->prev_execute_data;
    2686             :                         }
    2687         650 :                         filename = NULL;
    2688             :                 }
    2689             : 
    2690             :                 /* $this may be passed into regular internal functions */
    2691        7738 :                 object = (call && (Z_TYPE(call->This) == IS_OBJECT)) ? Z_OBJ(call->This) : NULL;
    2692             : 
    2693        7735 :                 if (call && call->func) {
    2694        3866 :                         func = call->func;
    2695        6323 :                         function_name = (func->common.scope &&
    2696        2455 :                                          func->common.scope->trait_aliases) ?
    2697           2 :                                 zend_resolve_method_name(
    2698             :                                         (object ? object->ce : func->common.scope), func) :
    2699             :                                 func->common.function_name;
    2700             :                 } else {
    2701           3 :                         func = NULL;
    2702           3 :                         function_name = NULL;
    2703             :                 }
    2704             : 
    2705        3869 :                 if (function_name) {
    2706        3739 :                         ZVAL_STR_COPY(&tmp, function_name);
    2707        3739 :                         zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_FUNCTION], &tmp);
    2708             : 
    2709        3739 :                         if (object) {
    2710        2238 :                                 if (func->common.scope) {
    2711        2238 :                                         ZVAL_STR_COPY(&tmp, func->common.scope->name);
    2712           0 :                                 } else if (object->handlers->get_class_name == std_object_handlers.get_class_name) {
    2713           0 :                                         ZVAL_STR_COPY(&tmp, object->ce->name);
    2714             :                                 } else {
    2715           0 :                                         ZVAL_STR(&tmp, object->handlers->get_class_name(object));
    2716             :                                 }
    2717        2238 :                                 zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_CLASS], &tmp);
    2718        2238 :                                 if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {
    2719          26 :                                         ZVAL_OBJ(&tmp, object);
    2720          26 :                                         zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_OBJECT], &tmp);
    2721             :                                         Z_ADDREF(tmp);
    2722             :                                 }
    2723             : 
    2724        2238 :                                 ZVAL_INTERNED_STR(&tmp, CG(known_strings)[ZEND_STR_OBJECT_OPERATOR]);
    2725        2238 :                                 zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_TYPE], &tmp);
    2726        1501 :                         } else if (func->common.scope) {
    2727         217 :                                 ZVAL_STR_COPY(&tmp, func->common.scope->name);
    2728         217 :                                 zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_CLASS], &tmp);
    2729         217 :                                 ZVAL_INTERNED_STR(&tmp, CG(known_strings)[ZEND_STR_PAAMAYIM_NEKUDOTAYIM]);
    2730         217 :                                 zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_TYPE], &tmp);
    2731             :                         }
    2732             : 
    2733        7466 :                         if ((options & DEBUG_BACKTRACE_IGNORE_ARGS) == 0 &&
    2734        3727 :                                 func->type != ZEND_EVAL_CODE) {
    2735             : 
    2736        3727 :                                 debug_backtrace_get_args(call, &tmp);
    2737        3727 :                                 zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_ARGS], &tmp);
    2738             :                         }
    2739             :                 } else {
    2740             :                         /* i know this is kinda ugly, but i'm trying to avoid extra cycles in the main execution loop */
    2741         130 :                         zend_bool build_filename_arg = 1;
    2742             :                         zend_string *pseudo_function_name;
    2743             : 
    2744         134 :                         if (!ptr->func || !ZEND_USER_CODE(ptr->func->common.type) || ptr->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
    2745             :                                 /* can happen when calling eval from a custom sapi */
    2746           4 :                                 pseudo_function_name = CG(known_strings)[ZEND_STR_UNKNOWN];
    2747           4 :                                 build_filename_arg = 0;
    2748             :                         } else
    2749         126 :                         switch (ptr->opline->extended_value) {
    2750             :                                 case ZEND_EVAL:
    2751          15 :                                         pseudo_function_name = CG(known_strings)[ZEND_STR_EVAL];
    2752          15 :                                         build_filename_arg = 0;
    2753          15 :                                         break;
    2754             :                                 case ZEND_INCLUDE:
    2755          97 :                                         pseudo_function_name = CG(known_strings)[ZEND_STR_INCLUDE];
    2756          97 :                                         break;
    2757             :                                 case ZEND_REQUIRE:
    2758          14 :                                         pseudo_function_name = CG(known_strings)[ZEND_STR_REQUIRE];
    2759          14 :                                         break;
    2760             :                                 case ZEND_INCLUDE_ONCE:
    2761           0 :                                         pseudo_function_name = CG(known_strings)[ZEND_STR_INCLUDE_ONCE];
    2762           0 :                                         break;
    2763             :                                 case ZEND_REQUIRE_ONCE:
    2764           0 :                                         pseudo_function_name = CG(known_strings)[ZEND_STR_REQUIRE_ONCE];
    2765           0 :                                         break;
    2766             :                                 default:
    2767             :                                         /* this can actually happen if you use debug_backtrace() in your error_handler and
    2768             :                                          * you're in the top-scope */
    2769           0 :                                         pseudo_function_name = CG(known_strings)[ZEND_STR_UNKNOWN];
    2770           0 :                                         build_filename_arg = 0;
    2771             :                                         break;
    2772             :                         }
    2773             : 
    2774         130 :                         if (build_filename_arg && include_filename) {
    2775             :                                 zval arg_array;
    2776             : 
    2777         107 :                                 array_init(&arg_array);
    2778             : 
    2779             :                                 /* include_filename always points to the last filename of the last last called-function.
    2780             :                                    if we have called include in the frame above - this is the file we have included.
    2781             :                                  */
    2782             : 
    2783         107 :                                 ZVAL_STR_COPY(&tmp, include_filename);
    2784         107 :                                 zend_hash_next_index_insert_new(Z_ARRVAL(arg_array), &tmp);
    2785         107 :                                 zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_ARGS], &arg_array);
    2786             :                         }
    2787             : 
    2788         130 :                         ZVAL_INTERNED_STR(&tmp, pseudo_function_name);
    2789         130 :                         zend_hash_add_new(Z_ARRVAL(stack_frame), CG(known_strings)[ZEND_STR_FUNCTION], &tmp);
    2790             :                 }
    2791             : 
    2792        3869 :                 zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &stack_frame);
    2793             : 
    2794        3869 :                 include_filename = filename;
    2795             : 
    2796        3869 :                 call = skip;
    2797        3869 :                 ptr = skip->prev_execute_data;
    2798             :         }
    2799             : }
    2800             : /* }}} */
    2801             : 
    2802             : /* {{{ proto array debug_backtrace([int options[, int limit]])
    2803             :    Return backtrace as array */
    2804          48 : ZEND_FUNCTION(debug_backtrace)
    2805             : {
    2806          48 :         zend_long options = DEBUG_BACKTRACE_PROVIDE_OBJECT;
    2807          48 :         zend_long limit = 0;
    2808             : 
    2809          48 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &options, &limit) == FAILURE) {
    2810           0 :                 return;
    2811             :         }
    2812             : 
    2813          48 :         zend_fetch_debug_backtrace(return_value, 1, options, limit);
    2814             : }
    2815             : /* }}} */
    2816             : 
    2817             : /* {{{ proto bool extension_loaded(string extension_name)
    2818             :    Returns true if the named extension is loaded */
    2819       21195 : ZEND_FUNCTION(extension_loaded)
    2820             : {
    2821             :         zend_string *extension_name;
    2822             :         zend_string *lcname;
    2823             : 
    2824       21195 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &extension_name) == FAILURE) {
    2825           0 :                 return;
    2826             :         }
    2827             : 
    2828       21195 :         lcname = zend_string_tolower(extension_name);
    2829       21195 :         if (zend_hash_exists(&module_registry, lcname)) {
    2830       21192 :                 RETVAL_TRUE;
    2831             :         } else {
    2832           3 :                 RETVAL_FALSE;
    2833             :         }
    2834             :         zend_string_release(lcname);
    2835             : }
    2836             : /* }}} */
    2837             : 
    2838             : /* {{{ proto array get_extension_funcs(string extension_name)
    2839             :    Returns an array with the names of functions belonging to the named extension */
    2840          34 : ZEND_FUNCTION(get_extension_funcs)
    2841             : {
    2842             :         zend_string *extension_name;
    2843             :         zend_string *lcname;
    2844             :         int array;
    2845             :         zend_module_entry *module;
    2846             :         zend_function *zif;
    2847             : 
    2848          34 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &extension_name) == FAILURE) {
    2849           7 :                 return;
    2850             :         }
    2851          27 :         if (strncasecmp(ZSTR_VAL(extension_name), "zend", sizeof("zend"))) {
    2852          25 :                 lcname = zend_string_tolower(extension_name);
    2853          25 :                 module = zend_hash_find_ptr(&module_registry, lcname);
    2854             :                 zend_string_release(lcname);
    2855             :         } else {
    2856           2 :                 module = zend_hash_str_find_ptr(&module_registry, "core", sizeof("core") - 1);
    2857             :         }
    2858             : 
    2859          27 :         if (!module) {
    2860          20 :                 RETURN_FALSE;
    2861             :         }
    2862             : 
    2863           7 :         if (module->functions) {
    2864             :                 /* avoid BC break, if functions list is empty, will return an empty array */
    2865           7 :                 array_init(return_value);
    2866           7 :                 array = 1;
    2867             :         } else {
    2868           0 :                 array = 0;
    2869             :         }
    2870             : 
    2871       30897 :         ZEND_HASH_FOREACH_PTR(CG(function_table), zif) {
    2872       30875 :                 if (zif->common.type == ZEND_INTERNAL_FUNCTION
    2873       30875 :                         && zif->internal_function.module == module) {
    2874        2398 :                         if (!array) {
    2875           0 :                                 array_init(return_value);
    2876           0 :                                 array = 1;
    2877             :                         }
    2878        4796 :                         add_next_index_str(return_value, zend_string_copy(zif->common.function_name));
    2879             :                 }
    2880             :         } ZEND_HASH_FOREACH_END();
    2881             : 
    2882           7 :         if (!array) {
    2883           0 :                 RETURN_FALSE;
    2884             :         }
    2885             : }
    2886             : /* }}} */
    2887             : 
    2888             : /*
    2889             :  * Local variables:
    2890             :  * tab-width: 4
    2891             :  * c-basic-offset: 4
    2892             :  * indent-tabs-mode: t
    2893             :  * End:
    2894             :  */

Generated by: LCOV version 1.10

Generated at Tue, 26 Jul 2016 17:07:30 +0000 (47 hours ago)

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