Back to index

php5  5.3.10
Defines | Functions | Variables
zend_builtin_functions.c File Reference
#include "zend.h"
#include "zend_API.h"
#include "zend_builtin_functions.h"
#include "zend_constants.h"
#include "zend_ini.h"
#include "zend_exceptions.h"
#include "zend_extensions.h"
#include "zend_closures.h"

Go to the source code of this file.

Defines

#define LAMBDA_TEMP_FUNCNAME   "__lambda_func"

Functions

static ZEND_FUNCTION (zend_version)
static ZEND_FUNCTION (func_num_args)
static ZEND_FUNCTION (func_get_arg)
static ZEND_FUNCTION (func_get_args)
static ZEND_FUNCTION (strlen)
static ZEND_FUNCTION (strcmp)
static ZEND_FUNCTION (strncmp)
static ZEND_FUNCTION (strcasecmp)
static ZEND_FUNCTION (strncasecmp)
static ZEND_FUNCTION (each)
static ZEND_FUNCTION (error_reporting)
static ZEND_FUNCTION (define)
static ZEND_FUNCTION (defined)
static ZEND_FUNCTION (get_class)
static ZEND_FUNCTION (get_called_class)
static ZEND_FUNCTION (get_parent_class)
static ZEND_FUNCTION (method_exists)
static ZEND_FUNCTION (property_exists)
static ZEND_FUNCTION (class_exists)
static ZEND_FUNCTION (interface_exists)
static ZEND_FUNCTION (function_exists)
static ZEND_FUNCTION (class_alias)
static ZEND_FUNCTION (get_included_files)
static ZEND_FUNCTION (is_subclass_of)
static ZEND_FUNCTION (is_a)
static ZEND_FUNCTION (get_class_vars)
static ZEND_FUNCTION (get_object_vars)
static ZEND_FUNCTION (get_class_methods)
static ZEND_FUNCTION (trigger_error)
static ZEND_FUNCTION (set_error_handler)
static ZEND_FUNCTION (restore_error_handler)
static ZEND_FUNCTION (set_exception_handler)
static ZEND_FUNCTION (restore_exception_handler)
static ZEND_FUNCTION (get_declared_classes)
static ZEND_FUNCTION (get_declared_interfaces)
static ZEND_FUNCTION (get_defined_functions)
static ZEND_FUNCTION (get_defined_vars)
static ZEND_FUNCTION (create_function)
static ZEND_FUNCTION (get_resource_type)
static ZEND_FUNCTION (get_loaded_extensions)
static ZEND_FUNCTION (extension_loaded)
static ZEND_FUNCTION (get_extension_funcs)
static ZEND_FUNCTION (get_defined_constants)
static ZEND_FUNCTION (debug_backtrace)
static ZEND_FUNCTION (debug_print_backtrace)
static ZEND_FUNCTION (gc_collect_cycles)
static ZEND_FUNCTION (gc_enabled)
static ZEND_FUNCTION (gc_enable)
static ZEND_FUNCTION (gc_disable)
 ZEND_MINIT_FUNCTION (core)
int zend_startup_builtin_functions (TSRMLS_D)
static void is_a_impl (INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass)
static void add_class_vars (zend_class_entry *ce, HashTable *properties, zval *return_value TSRMLS_DC)
static int copy_class_or_interface_name (zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
static int copy_function_name (zend_function *func TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
static int add_extension_info (zend_module_entry *module, void *arg TSRMLS_DC)
static int add_zendext_info (zend_extension *ext, void *arg TSRMLS_DC)
static int add_constant_info (zend_constant *constant, void *arg TSRMLS_DC)
static zval * debug_backtrace_get_args (void **curpos TSRMLS_DC)
void debug_print_backtrace_args (zval *arg_array TSRMLS_DC)
ZEND_API void zend_fetch_debug_backtrace (zval *return_value, int skip_last, int options TSRMLS_DC)

Variables

static const zend_function_entry builtin_functions []
zend_module_entry zend_builtin_module

Define Documentation

#define LAMBDA_TEMP_FUNCNAME   "__lambda_func"

Definition at line 1668 of file zend_builtin_functions.c.


Function Documentation

static void add_class_vars ( zend_class_entry *  ce,
HashTable properties,
zval *return_value  TSRMLS_DC 
) [static]

Definition at line 876 of file zend_builtin_functions.c.

{
       if (zend_hash_num_elements(properties) > 0) {
              HashPosition pos;
              zval **prop;

              zend_hash_internal_pointer_reset_ex(properties, &pos);
              while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) {
                     char *key, *class_name, *prop_name;
                     uint key_len;
                     ulong num_index;
                     int prop_name_len = 0;                    
                     zval *prop_copy;
                     zend_property_info *property_info;
                     zval zprop_name;

                     zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos);
                     zend_hash_move_forward_ex(properties, &pos);

                     zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name);
                     prop_name_len = strlen(prop_name);

                     ZVAL_STRINGL(&zprop_name, prop_name, prop_name_len, 0);
                     property_info = zend_get_property_info(ce, &zprop_name, 1 TSRMLS_CC);

                     if (!property_info || property_info == &EG(std_property_info)) {
                            continue;
                     }

                     /* copy: enforce read only access */
                     ALLOC_ZVAL(prop_copy);
                     *prop_copy = **prop;
                     zval_copy_ctor(prop_copy);
                     INIT_PZVAL(prop_copy);

                     /* this is necessary to make it able to work with default array 
                     * properties, returned to user */
                     if (Z_TYPE_P(prop_copy) == IS_CONSTANT_ARRAY || (Z_TYPE_P(prop_copy) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) {
                            zval_update_constant(&prop_copy, 0 TSRMLS_CC);
                     }

                     add_assoc_zval(return_value, prop_name, prop_copy);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int add_constant_info ( zend_constant constant,
void *arg  TSRMLS_DC 
) [static]

Definition at line 1786 of file zend_builtin_functions.c.

{
       zval *name_array = (zval *)arg;
       zval *const_val;

       MAKE_STD_ZVAL(const_val);
       *const_val = constant->value;
       zval_copy_ctor(const_val);
       INIT_PZVAL(const_val);
       add_assoc_zval_ex(name_array, constant->name, constant->name_len, const_val);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int add_extension_info ( zend_module_entry *  module,
void *arg  TSRMLS_DC 
) [static]

Definition at line 1772 of file zend_builtin_functions.c.

{
       zval *name_array = (zval *)arg;
       add_next_index_string(name_array, module->name, 1);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int add_zendext_info ( zend_extension *  ext,
void *arg  TSRMLS_DC 
) [static]

Definition at line 1779 of file zend_builtin_functions.c.

{
       zval *name_array = (zval *)arg;
       add_next_index_string(name_array, ext->name, 1);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int copy_class_or_interface_name ( zend_class_entry **pce  TSRMLS_DC,
int  num_args,
va_list  args,
zend_hash_key hash_key 
) [static]

Definition at line 1546 of file zend_builtin_functions.c.

{
       zval *array = va_arg(args, zval *);
       zend_uint mask = va_arg(args, zend_uint);
       zend_uint comply = va_arg(args, zend_uint);
       zend_uint comply_mask = (comply)? mask:0;
       zend_class_entry *ce  = *pce;

       if ((hash_key->nKeyLength==0 || hash_key->arKey[0]!=0)
              && (comply_mask == (ce->ce_flags & mask))) {
              add_next_index_stringl(array, ce->name, ce->name_length, 1);
       }
       return ZEND_HASH_APPLY_KEEP;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int copy_function_name ( zend_function *func  TSRMLS_DC,
int  num_args,
va_list  args,
zend_hash_key hash_key 
) [static]

Definition at line 1595 of file zend_builtin_functions.c.

{
       zval *internal_ar = va_arg(args, zval *),
            *user_ar     = va_arg(args, zval *);

       if (hash_key->nKeyLength == 0 || hash_key->arKey[0] == 0) {
              return 0;
       }

       if (func->type == ZEND_INTERNAL_FUNCTION) {
              add_next_index_stringl(internal_ar, hash_key->arKey, hash_key->nKeyLength-1, 1);
       } else if (func->type == ZEND_USER_FUNCTION) {
              add_next_index_stringl(user_ar, hash_key->arKey, hash_key->nKeyLength-1, 1);
       }

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static zval* debug_backtrace_get_args ( void **curpos  TSRMLS_DC) [static]

Definition at line 1891 of file zend_builtin_functions.c.

{
       void **p = curpos;
       zval *arg_array, **arg;
       int arg_count = (int)(zend_uintptr_t) *p;

       MAKE_STD_ZVAL(arg_array);
       array_init_size(arg_array, arg_count);
       p -= arg_count;

       while (--arg_count >= 0) {
              arg = (zval **) p++;
              if (*arg) {
                     if (Z_TYPE_PP(arg) != IS_OBJECT) {
                            SEPARATE_ZVAL_TO_MAKE_IS_REF(arg);
                     }
                     Z_ADDREF_PP(arg);
                     add_next_index_zval(arg_array, *arg);
              } else {
                     add_next_index_null(arg_array);
              }
       }

       return arg_array;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void debug_print_backtrace_args ( zval *arg_array  TSRMLS_DC)

Definition at line 1917 of file zend_builtin_functions.c.

{
       zval **tmp;
       HashPosition iterator;
       int i = 0;

       zend_hash_internal_pointer_reset_ex(arg_array->value.ht, &iterator);
       while (zend_hash_get_current_data_ex(arg_array->value.ht, (void **) &tmp, &iterator) == SUCCESS) {
              if (i++) {
                     ZEND_PUTS(", ");
              }
              zend_print_flat_zval_r(*tmp TSRMLS_CC);
              zend_hash_move_forward_ex(arg_array->value.ht, &iterator);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void is_a_impl ( INTERNAL_FUNCTION_PARAMETERS  ,
zend_bool  only_subclass 
) [static]

Definition at line 812 of file zend_builtin_functions.c.

{
       zval *obj;
       char *class_name;
       int class_name_len;
       zend_class_entry *instance_ce;
       zend_class_entry **ce;
       zend_bool allow_string = only_subclass;
       zend_bool retval;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|b", &obj, &class_name, &class_name_len, &allow_string) == FAILURE) {
              return;
       }
       /*
          allow_string - is_a default is no, is_subclass_of is yes. 
          if it's allowed, then the autoloader will be called if the class does not exist.
          default behaviour is different, as 'is_a' usage is normally to test mixed return values 
       */

       if (allow_string && Z_TYPE_P(obj) == IS_STRING) {
              zend_class_entry **the_ce;
              if (zend_lookup_class(Z_STRVAL_P(obj), Z_STRLEN_P(obj), &the_ce TSRMLS_CC) == FAILURE) {
                     RETURN_FALSE;
              }
              instance_ce = *the_ce;
       } else if (Z_TYPE_P(obj) == IS_OBJECT && HAS_CLASS_ENTRY(*obj)) {
              instance_ce = Z_OBJCE_P(obj);
       } else {
              RETURN_FALSE;
       }

       if (zend_lookup_class_ex(class_name, class_name_len, 0, &ce TSRMLS_CC) == FAILURE) {
              retval = 0;
       } else {
              if (only_subclass && instance_ce == *ce) {
                     retval = 0;
              } else {
                     retval = instanceof_function(instance_ce, *ce TSRMLS_CC);
              }
       }

       RETURN_BOOL(retval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void zend_fetch_debug_backtrace ( zval *  return_value,
int  skip_last,
int options  TSRMLS_DC 
)

Definition at line 2093 of file zend_builtin_functions.c.

{
       zend_execute_data *ptr, *skip;
       int lineno;
       char *function_name;
       char *filename;
       char *class_name;
       char *include_filename = NULL;
       zval *stack_frame;

       ptr = EG(current_execute_data);

       /* skip "new Exception()" */
       if (ptr && (skip_last == 0) && ptr->opline && (ptr->opline->opcode == ZEND_NEW)) {
              ptr = ptr->prev_execute_data;
       }

       /* skip debug_backtrace() */
       if (skip_last-- && ptr) {
              ptr = ptr->prev_execute_data;
       }

       array_init(return_value);

       while (ptr) {
              MAKE_STD_ZVAL(stack_frame);
              array_init(stack_frame);

              skip = ptr;
              /* skip internal handler */
              if (!skip->op_array &&
                  skip->prev_execute_data &&
                  skip->prev_execute_data->opline &&
                  skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL &&
                  skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL_BY_NAME &&
                  skip->prev_execute_data->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
                     skip = skip->prev_execute_data;
              }

              if (skip->op_array) {
                     filename = skip->op_array->filename;
                     lineno = skip->opline->lineno;
                     add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1);
                     add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno);

                     /* try to fetch args only if an FCALL was just made - elsewise we're in the middle of a function
                      * and debug_baktrace() might have been called by the error_handler. in this case we don't 
                      * want to pop anything of the argument-stack */
              } else {
                     zend_execute_data *prev = skip->prev_execute_data;

                     while (prev) {
                            if (prev->function_state.function &&
                                   prev->function_state.function->common.type != ZEND_USER_FUNCTION &&
                                   !(prev->function_state.function->common.type == ZEND_INTERNAL_FUNCTION &&
                                          (prev->function_state.function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER))) {
                                   break;
                            }                               
                            if (prev->op_array) {
                                   add_assoc_string_ex(stack_frame, "file", sizeof("file"), prev->op_array->filename, 1);
                                   add_assoc_long_ex(stack_frame, "line", sizeof("line"), prev->opline->lineno);
                                   break;
                            }
                            prev = prev->prev_execute_data;
                     }
                     filename = NULL;
              }

              function_name = ptr->function_state.function->common.function_name;

              if (function_name) {
                     add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1);

                     if (ptr->object && Z_TYPE_P(ptr->object) == IS_OBJECT) {
                            if (ptr->function_state.function->common.scope) {
                                   add_assoc_string_ex(stack_frame, "class", sizeof("class"), ptr->function_state.function->common.scope->name, 1);
                            } else {
                                   zend_uint class_name_len;
                                   int dup;

                                   dup = zend_get_object_classname(ptr->object, &class_name, &class_name_len TSRMLS_CC);
                                   add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, dup);
                                   
                            }
                            if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) {
                                   add_assoc_zval_ex(stack_frame, "object", sizeof("object"), ptr->object);
                                   Z_ADDREF_P(ptr->object);
                            }

                            add_assoc_string_ex(stack_frame, "type", sizeof("type"), "->", 1);
                     } else if (ptr->function_state.function->common.scope) {
                            add_assoc_string_ex(stack_frame, "class", sizeof("class"), ptr->function_state.function->common.scope->name, 1);
                            add_assoc_string_ex(stack_frame, "type", sizeof("type"), "::", 1);
                     }

                     if ((options & DEBUG_BACKTRACE_IGNORE_ARGS) == 0 && 
                            ((! ptr->opline) || ((ptr->opline->opcode == ZEND_DO_FCALL_BY_NAME) || (ptr->opline->opcode == ZEND_DO_FCALL)))) {
                            if (ptr->function_state.arguments) {
                                   add_assoc_zval_ex(stack_frame, "args", sizeof("args"), debug_backtrace_get_args(ptr->function_state.arguments TSRMLS_CC));
                            }
                     }
              } else {
                     /* i know this is kinda ugly, but i'm trying to avoid extra cycles in the main execution loop */
                     zend_bool build_filename_arg = 1;

                     if (!ptr->opline || ptr->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
                            /* can happen when calling eval from a custom sapi */
                            function_name = "unknown";
                            build_filename_arg = 0;
                     } else
                     switch (ptr->opline->op2.u.constant.value.lval) {
                            case ZEND_EVAL:
                                   function_name = "eval";
                                   build_filename_arg = 0;
                                   break;
                            case ZEND_INCLUDE:
                                   function_name = "include";
                                   break;
                            case ZEND_REQUIRE:
                                   function_name = "require";
                                   break;
                            case ZEND_INCLUDE_ONCE:
                                   function_name = "include_once";
                                   break;
                            case ZEND_REQUIRE_ONCE:
                                   function_name = "require_once";
                                   break;
                            default:
                                   /* this can actually happen if you use debug_backtrace() in your error_handler and 
                                    * you're in the top-scope */
                                   function_name = "unknown"; 
                                   build_filename_arg = 0;
                                   break;
                     }

                     if (build_filename_arg && include_filename) {
                            zval *arg_array;

                            MAKE_STD_ZVAL(arg_array);
                            array_init(arg_array);

                            /* include_filename always points to the last filename of the last last called-fuction.
                               if we have called include in the frame above - this is the file we have included.
                             */

                            add_next_index_string(arg_array, include_filename, 1);
                            add_assoc_zval_ex(stack_frame, "args", sizeof("args"), arg_array);
                     }

                     add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1);
              }

              add_next_index_zval(return_value, stack_frame);

              include_filename = filename; 

              ptr = skip->prev_execute_data;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_FUNCTION ( zend_version  ) [static]

Definition at line 326 of file zend_builtin_functions.c.

ZEND_FUNCTION ( func_num_args  ) [static]

Definition at line 367 of file zend_builtin_functions.c.

{
       zend_execute_data *ex = EG(current_execute_data)->prev_execute_data;

       if (ex && ex->function_state.arguments) {
              RETURN_LONG((long)(zend_uintptr_t)*(ex->function_state.arguments));
       } else {
              zend_error(E_WARNING, "func_num_args():  Called from the global scope - no function context");
              RETURN_LONG(-1);
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( func_get_arg  ) [static]

Definition at line 383 of file zend_builtin_functions.c.

{
       void **p;
       int arg_count;
       zval *arg;
       long requested_offset;
       zend_execute_data *ex = EG(current_execute_data)->prev_execute_data;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &requested_offset) == FAILURE) {
              return;
       }

       if (requested_offset < 0) {
              zend_error(E_WARNING, "func_get_arg():  The argument number should be >= 0");
              RETURN_FALSE;
       }

       if (!ex || !ex->function_state.arguments) {
              zend_error(E_WARNING, "func_get_arg():  Called from the global scope - no function context");
              RETURN_FALSE;
       }

       p = ex->function_state.arguments;
       arg_count = (int)(zend_uintptr_t) *p;            /* this is the amount of arguments passed to func_get_arg(); */

       if (requested_offset >= arg_count) {
              zend_error(E_WARNING, "func_get_arg():  Argument %ld not passed to function", requested_offset);
              RETURN_FALSE;
       }

       arg = *(p-(arg_count-requested_offset));
       *return_value = *arg;
       zval_copy_ctor(return_value);
       INIT_PZVAL(return_value);
}

Here is the call graph for this function:

ZEND_FUNCTION ( func_get_args  ) [static]

Definition at line 423 of file zend_builtin_functions.c.

{
       void **p;
       int arg_count;
       int i;
       zend_execute_data *ex = EG(current_execute_data)->prev_execute_data;

       if (!ex || !ex->function_state.arguments) {
              zend_error(E_WARNING, "func_get_args():  Called from the global scope - no function context");
              RETURN_FALSE;
       }

       p = ex->function_state.arguments;
       arg_count = (int)(zend_uintptr_t) *p;            /* this is the amount of arguments passed to func_get_args(); */

       array_init_size(return_value, arg_count);
       for (i=0; i<arg_count; i++) {
              zval *element;

              ALLOC_ZVAL(element);
              *element = **((zval **) (p-(arg_count-i)));
              zval_copy_ctor(element);
              INIT_PZVAL(element);
              zend_hash_next_index_insert(return_value->value.ht, &element, sizeof(zval *), NULL);
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( strlen  ) [static]

Definition at line 454 of file zend_builtin_functions.c.

{
       char *s1;
       int s1_len;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s1, &s1_len) == FAILURE) {
              return;
       }

       RETVAL_LONG(s1_len);
}

Here is the call graph for this function:

ZEND_FUNCTION ( strcmp  ) [static]

Definition at line 470 of file zend_builtin_functions.c.

{
       char *s1, *s2;
       int s1_len, s2_len;
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1_len, &s2, &s2_len) == FAILURE) {
              return;
       }

       RETURN_LONG(zend_binary_strcmp(s1, s1_len, s2, s2_len));
}

Here is the call graph for this function:

ZEND_FUNCTION ( strncmp  ) [static]

Definition at line 486 of file zend_builtin_functions.c.

{
       char *s1, *s2;
       int s1_len, s2_len;
       long len;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) {
              return;
       }

       if (len < 0) {
              zend_error(E_WARNING, "Length must be greater than or equal to 0");
              RETURN_FALSE;
       }

       RETURN_LONG(zend_binary_strncmp(s1, s1_len, s2, s2_len, len));
}

Here is the call graph for this function:

ZEND_FUNCTION ( strcasecmp  ) [static]

Definition at line 508 of file zend_builtin_functions.c.

{
       char *s1, *s2;
       int s1_len, s2_len;
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &s1, &s1_len, &s2, &s2_len) == FAILURE) {
              return;
       }

       RETURN_LONG(zend_binary_strcasecmp(s1, s1_len, s2, s2_len));
}

Here is the call graph for this function:

ZEND_FUNCTION ( strncasecmp  ) [static]

Definition at line 524 of file zend_builtin_functions.c.

{
       char *s1, *s2;
       int s1_len, s2_len;
       long len;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) {
              return;
       }

       if (len < 0) {
              zend_error(E_WARNING, "Length must be greater than or equal to 0");
              RETURN_FALSE;
       }

       RETURN_LONG(zend_binary_strncasecmp(s1, s1_len, s2, s2_len, len));
}

Here is the call graph for this function:

ZEND_FUNCTION ( each  ) [static]

Definition at line 546 of file zend_builtin_functions.c.

{
       zval *array, *entry, **entry_ptr, *tmp;
       char *string_key;
       uint string_key_len;
       ulong num_key;
       zval **inserted_pointer;
       HashTable *target_hash;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &array) == FAILURE) {
              return;
       }

       target_hash = HASH_OF(array);
       if (!target_hash) {
              zend_error(E_WARNING,"Variable passed to each() is not an array or object");
              return;
       }
       if (zend_hash_get_current_data(target_hash, (void **) &entry_ptr)==FAILURE) {
              RETURN_FALSE;
       }
       array_init(return_value);
       entry = *entry_ptr;

       /* add value elements */
       if (Z_ISREF_P(entry)) {
              ALLOC_ZVAL(tmp);
              *tmp = *entry;
              zval_copy_ctor(tmp);
              Z_UNSET_ISREF_P(tmp);
              Z_SET_REFCOUNT_P(tmp, 0);
              entry=tmp;
       }
       zend_hash_index_update(return_value->value.ht, 1, &entry, sizeof(zval *), NULL);
       Z_ADDREF_P(entry);
       zend_hash_update(return_value->value.ht, "value", sizeof("value"), &entry, sizeof(zval *), NULL);
       Z_ADDREF_P(entry);

       /* add the key elements */
       switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_key_len, &num_key, 1, NULL)) {
              case HASH_KEY_IS_STRING:
                     add_get_index_stringl(return_value, 0, string_key, string_key_len-1, (void **) &inserted_pointer, 0);
                     break;
              case HASH_KEY_IS_LONG:
                     add_get_index_long(return_value, 0, num_key, (void **) &inserted_pointer);
                     break;
       }
       zend_hash_update(return_value->value.ht, "key", sizeof("key"), inserted_pointer, sizeof(zval *), NULL);
       Z_ADDREF_PP(inserted_pointer);
       zend_hash_move_forward(target_hash);
}

Here is the call graph for this function:

ZEND_FUNCTION ( error_reporting  ) [static]

Definition at line 602 of file zend_builtin_functions.c.

{
       char *err;
       int err_len;
       int old_error_reporting;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &err, &err_len) == FAILURE) {
              return;
       }

       old_error_reporting = EG(error_reporting);
       if(ZEND_NUM_ARGS() != 0) {
              zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), err, err_len, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
       }

       RETVAL_LONG(old_error_reporting);
}

Here is the call graph for this function:

ZEND_FUNCTION ( define  ) [static]

Definition at line 624 of file zend_builtin_functions.c.

{
       char *name;
       int name_len;
       zval *val;
       zval *val_free = NULL;
       zend_bool non_cs = 0;
       int case_sensitive = CONST_CS;
       zend_constant c;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|b", &name, &name_len, &val, &non_cs) == FAILURE) {
              return;
       }

       if(non_cs) {
              case_sensitive = 0;
       }

       /* class constant, check if there is name and make sure class is valid & exists */
       if (zend_memnstr(name, "::", sizeof("::") - 1, name + name_len)) {
              zend_error(E_WARNING, "Class constants cannot be defined or redefined");
              RETURN_FALSE;
       }

repeat:
       switch (Z_TYPE_P(val)) {
              case IS_LONG:
              case IS_DOUBLE:
              case IS_STRING:
              case IS_BOOL:
              case IS_RESOURCE:
              case IS_NULL:
                     break;
              case IS_OBJECT:
                     if (!val_free) {
                            if (Z_OBJ_HT_P(val)->get) {
                                   val_free = val = Z_OBJ_HT_P(val)->get(val TSRMLS_CC);
                                   goto repeat;
                            } else if (Z_OBJ_HT_P(val)->cast_object) {
                                   ALLOC_INIT_ZVAL(val_free);
                                   if (Z_OBJ_HT_P(val)->cast_object(val, val_free, IS_STRING TSRMLS_CC) == SUCCESS) {
                                          val = val_free;
                                          break;
                                   }
                            }
                     }
                     /* no break */
              default:
                     zend_error(E_WARNING,"Constants may only evaluate to scalar values");
                     if (val_free) {
                            zval_ptr_dtor(&val_free);
                     }
                     RETURN_FALSE;
       }
       
       c.value = *val;
       zval_copy_ctor(&c.value);
       if (val_free) {
              zval_ptr_dtor(&val_free);
       }
       c.flags = case_sensitive; /* non persistent */
       c.name = zend_strndup(name, name_len);
       c.name_len = name_len+1;
       c.module_number = PHP_USER_CONSTANT;
       if (zend_register_constant(&c TSRMLS_CC) == SUCCESS) {
              RETURN_TRUE;
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( defined  ) [static]

Definition at line 699 of file zend_builtin_functions.c.

{
       char *name;
       int name_len;
       zval c;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
              return;
       }
       
       if (zend_get_constant_ex(name, name_len, &c, NULL, ZEND_FETCH_CLASS_SILENT TSRMLS_CC)) {
              zval_dtor(&c);
              RETURN_TRUE;
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_class  ) [static]

Definition at line 721 of file zend_builtin_functions.c.

{
       zval *obj = NULL;
       char *name = "";
       zend_uint name_len = 0;
       int dup;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|o!", &obj) == FAILURE) {
              RETURN_FALSE;
       }

       if (!obj) {
              if (EG(scope)) {
                     RETURN_STRINGL(EG(scope)->name, EG(scope)->name_length, 1);
              } else {
                     zend_error(E_WARNING, "get_class() called without object from outside a class");
                     RETURN_FALSE;
              }
       }

       dup = zend_get_object_classname(obj, &name, &name_len TSRMLS_CC);

       RETURN_STRINGL(name, name_len, dup);
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_called_class  ) [static]

Definition at line 750 of file zend_builtin_functions.c.

{
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       if (EG(called_scope)) {
              RETURN_STRINGL(EG(called_scope)->name, EG(called_scope)->name_length, 1);
       } else if (!EG(scope))  {
              zend_error(E_WARNING, "get_called_class() called from outside a class");
       }
       RETURN_FALSE;
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_parent_class  ) [static]

Definition at line 768 of file zend_builtin_functions.c.

{
       zval *arg;
       zend_class_entry *ce = NULL;
       char *name;
       zend_uint name_length;
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &arg) == FAILURE) {
              return;
       }

       if (!ZEND_NUM_ARGS()) {
              ce = EG(scope);
              if (ce && ce->parent) {
                     RETURN_STRINGL(ce->parent->name, ce->parent->name_length, 1);
              } else {
                     RETURN_FALSE;
              }
       }

       if (Z_TYPE_P(arg) == IS_OBJECT) {
              if (Z_OBJ_HT_P(arg)->get_class_name
                     && Z_OBJ_HT_P(arg)->get_class_name(arg, &name, &name_length, 1 TSRMLS_CC) == SUCCESS) {
                     RETURN_STRINGL(name, name_length, 0);
              } else {
                     ce = zend_get_class_entry(arg TSRMLS_CC);
              }
       } else if (Z_TYPE_P(arg) == IS_STRING) {
              zend_class_entry **pce;
              
              if (zend_lookup_class(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &pce TSRMLS_CC) == SUCCESS) {
                     ce = *pce;
              }
       }

       if (ce && ce->parent) {
              RETURN_STRINGL(ce->parent->name, ce->parent->name_length, 1);
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( method_exists  ) [static]

Definition at line 1060 of file zend_builtin_functions.c.

{
       zval *klass; 
       char *method_name;
       int method_len;
       char *lcname;
       zend_class_entry * ce, **pce;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &klass, &method_name, &method_len) == FAILURE) {
              return;
       }
       if (Z_TYPE_P(klass) == IS_OBJECT) {
              ce = Z_OBJCE_P(klass);
       } else if (Z_TYPE_P(klass) == IS_STRING) {
              if (zend_lookup_class(Z_STRVAL_P(klass), Z_STRLEN_P(klass), &pce TSRMLS_CC) == FAILURE) {
                     RETURN_FALSE;
              }
              ce = *pce;
       } else {
              RETURN_FALSE;
       }

       lcname = zend_str_tolower_dup(method_name, method_len);
       if (zend_hash_exists(&ce->function_table, lcname, method_len+1)) {
              efree(lcname);
              RETURN_TRUE;
       } else {
              union _zend_function *func = NULL;

              if (Z_TYPE_P(klass) == IS_OBJECT 
              && Z_OBJ_HT_P(klass)->get_method != NULL
              && (func = Z_OBJ_HT_P(klass)->get_method(&klass, method_name, method_len TSRMLS_CC)) != NULL
              ) {
                     if (func->type == ZEND_INTERNAL_FUNCTION 
                     && (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0
                     ) {
                            /* Returns true to the fake Closure's __invoke */
                            RETVAL_BOOL((func->common.scope == zend_ce_closure
                                   && (method_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
                                   && memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0) ? 1 : 0);

                            efree(lcname);
                            efree(((zend_internal_function*)func)->function_name);
                            efree(func);
                            return;
                     }
                     efree(lcname);
                     RETURN_TRUE;
              }
       }
       efree(lcname);
       RETURN_FALSE;
}

Here is the call graph for this function:

ZEND_FUNCTION ( property_exists  ) [static]

Definition at line 1117 of file zend_builtin_functions.c.

{
       zval *object;
       char *property;
       int property_len;
       zend_class_entry *ce, **pce;
       zend_property_info *property_info;
       zval property_z;
       ulong h;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &object, &property, &property_len) == FAILURE) {
              return;
       }

       if (property_len == 0) {
              RETURN_FALSE;
       }

       if (Z_TYPE_P(object) == IS_STRING) {
              if (zend_lookup_class(Z_STRVAL_P(object), Z_STRLEN_P(object), &pce TSRMLS_CC) == FAILURE) {
                     RETURN_FALSE;
              }
              ce = *pce;
       } else if (Z_TYPE_P(object) == IS_OBJECT) {
              ce = Z_OBJCE_P(object);
       } else {
              zend_error(E_WARNING, "First parameter must either be an object or the name of an existing class");
              RETURN_NULL();
       }

       h = zend_get_hash_value(property, property_len+1);
       if (zend_hash_quick_find(&ce->properties_info, property, property_len+1, h, (void **) &property_info) == SUCCESS
              && (property_info->flags & ZEND_ACC_SHADOW) == 0) {
              RETURN_TRUE;
       }

       ZVAL_STRINGL(&property_z, property, property_len, 0);

       if (Z_TYPE_P(object) ==  IS_OBJECT &&
              Z_OBJ_HANDLER_P(object, has_property) && 
              Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2 TSRMLS_CC)) {
              RETURN_TRUE;
       }
       RETURN_FALSE;
}

Here is the call graph for this function:

ZEND_FUNCTION ( class_exists  ) [static]

Definition at line 1167 of file zend_builtin_functions.c.

{
       char *class_name, *lc_name;
       zend_class_entry **ce;
       int class_name_len;
       int found;
       zend_bool autoload = 1;
       ALLOCA_FLAG(use_heap)

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &class_name, &class_name_len, &autoload) == FAILURE) {
              return;
       }

       if (!autoload) {
              char *name;
              int len;

              lc_name = do_alloca(class_name_len + 1, use_heap);
              zend_str_tolower_copy(lc_name, class_name, class_name_len);

              /* Ignore leading "\" */
              name = lc_name;
              len = class_name_len;
              if (lc_name[0] == '\\') {
                     name = &lc_name[1];
                     len--;
              }
       
              found = zend_hash_find(EG(class_table), name, len+1, (void **) &ce);
              free_alloca(lc_name, use_heap);
              RETURN_BOOL(found == SUCCESS && !((*ce)->ce_flags & ZEND_ACC_INTERFACE));
       }

       if (zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC) == SUCCESS) {
              RETURN_BOOL(((*ce)->ce_flags & ZEND_ACC_INTERFACE) == 0);
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( interface_exists  ) [static]

Definition at line 1210 of file zend_builtin_functions.c.

{
       char *iface_name, *lc_name;
       zend_class_entry **ce;
       int iface_name_len;
       int found;
       zend_bool autoload = 1;
       ALLOCA_FLAG(use_heap)

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &iface_name, &iface_name_len, &autoload) == FAILURE) {
              return;
       }

       if (!autoload) {
              char *name;
              int len;
              
              lc_name = do_alloca(iface_name_len + 1, use_heap);
              zend_str_tolower_copy(lc_name, iface_name, iface_name_len);
       
              /* Ignore leading "\" */
              name = lc_name;
              len = iface_name_len;
              if (lc_name[0] == '\\') {
                     name = &lc_name[1];
                     len--;
              }

              found = zend_hash_find(EG(class_table), name, len+1, (void **) &ce);
              free_alloca(lc_name, use_heap);
              RETURN_BOOL(found == SUCCESS && (*ce)->ce_flags & ZEND_ACC_INTERFACE);
       }

       if (zend_lookup_class(iface_name, iface_name_len, &ce TSRMLS_CC) == SUCCESS) {
              RETURN_BOOL(((*ce)->ce_flags & ZEND_ACC_INTERFACE) > 0);
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( function_exists  ) [static]

Definition at line 1254 of file zend_builtin_functions.c.

{
       char *name;
       int name_len;
       zend_function *func;
       char *lcname;
       zend_bool retval;
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
              return;
       }

       lcname = zend_str_tolower_dup(name, name_len);
       
       /* Ignore leading "\" */
       name = lcname;
       if (lcname[0] == '\\') {
              name = &lcname[1];
              name_len--;
       }

       retval = (zend_hash_find(EG(function_table), name, name_len+1, (void **)&func) == SUCCESS);
       
       efree(lcname);

       /*
        * A bit of a hack, but not a bad one: we see if the handler of the function
        * is actually one that displays "function is disabled" message.
        */
       if (retval && func->type == ZEND_INTERNAL_FUNCTION &&
              func->internal_function.handler == zif_display_disabled_function) {
              retval = 0;
       }

       RETURN_BOOL(retval);
}

Here is the call graph for this function:

ZEND_FUNCTION ( class_alias  ) [static]

Definition at line 1294 of file zend_builtin_functions.c.

{
       char *class_name, *lc_name, *alias_name;
       zend_class_entry **ce;
       int class_name_len, alias_name_len;
       int found;
       zend_bool autoload = 1;
       ALLOCA_FLAG(use_heap)

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &class_name, &class_name_len, &alias_name, &alias_name_len, &autoload) == FAILURE) {
              return;
       }

       if (!autoload) {
              lc_name = do_alloca(class_name_len + 1, use_heap);
              zend_str_tolower_copy(lc_name, class_name, class_name_len);
       
              found = zend_hash_find(EG(class_table), lc_name, class_name_len+1, (void **) &ce);
              free_alloca(lc_name, use_heap);
       } else {
              found = zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC);
       }
       if (found == SUCCESS) {
              if ((*ce)->type == ZEND_USER_CLASS) { 
                     if (zend_register_class_alias_ex(alias_name, alias_name_len, *ce TSRMLS_CC) == SUCCESS) {
                            RETURN_TRUE;
                     } else {
                            zend_error(E_WARNING, "Cannot redeclare class %s", alias_name);
                            RETURN_FALSE;
                     }
              } else {
                     zend_error(E_WARNING, "First argument of class_alias() must be a name of user defined class");
                     RETURN_FALSE;
              }
       } else {
              zend_error(E_WARNING, "Class '%s' not found", class_name);
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_included_files  ) [static]

Definition at line 1364 of file zend_builtin_functions.c.

{
       char *entry;
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       array_init(return_value);
       zend_hash_internal_pointer_reset(&EG(included_files));
       while (zend_hash_get_current_key(&EG(included_files), &entry, NULL, 1) == HASH_KEY_IS_STRING) {
              add_next_index_string(return_value, entry, 0);
              zend_hash_move_forward(&EG(included_files));
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( is_subclass_of  ) [static]

Definition at line 859 of file zend_builtin_functions.c.

Here is the call graph for this function:

ZEND_FUNCTION ( is_a  ) [static]

Definition at line 868 of file zend_builtin_functions.c.

Here is the call graph for this function:

ZEND_FUNCTION ( get_class_vars  ) [static]

Definition at line 926 of file zend_builtin_functions.c.

{
       char *class_name;
       int class_name_len;
       zend_class_entry **pce;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &class_name, &class_name_len) == FAILURE) {
              return;
       }

       if (zend_lookup_class(class_name, class_name_len, &pce TSRMLS_CC) == FAILURE) {
              RETURN_FALSE;
       } else {
              array_init(return_value);
              zend_update_class_constants(*pce TSRMLS_CC);
              add_class_vars(*pce, &(*pce)->default_properties, return_value TSRMLS_CC);
              add_class_vars(*pce, CE_STATIC_MEMBERS(*pce), return_value TSRMLS_CC);
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_object_vars  ) [static]

Definition at line 950 of file zend_builtin_functions.c.

{
       zval *obj;
       zval **value;
       HashTable *properties;
       HashPosition pos;
       char *key, *prop_name, *class_name;
       uint key_len;
       ulong num_index;
       zend_object *zobj;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
              return;
       }

       if (Z_OBJ_HT_P(obj)->get_properties == NULL) {
              RETURN_FALSE;
       }

       properties = Z_OBJ_HT_P(obj)->get_properties(obj TSRMLS_CC);

       if (properties == NULL) {
              RETURN_FALSE;
       }

       zobj = zend_objects_get_address(obj TSRMLS_CC);

       array_init(return_value);

       zend_hash_internal_pointer_reset_ex(properties, &pos);

       while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) {
              if (zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) {
                     if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) {
                            zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name);
                            /* Not separating references */
                            Z_ADDREF_PP(value);
                            add_assoc_zval_ex(return_value, prop_name, strlen(prop_name)+1, *value);
                     }
              }
              zend_hash_move_forward_ex(properties, &pos);
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_class_methods  ) [static]

Definition at line 998 of file zend_builtin_functions.c.

{
       zval *klass;
       zval *method_name;
       zend_class_entry *ce = NULL, **pce;
       HashPosition pos;
       zend_function *mptr;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &klass) == FAILURE) {
              return;
       }

       if (Z_TYPE_P(klass) == IS_OBJECT) {
              /* TBI!! new object handlers */
              if (!HAS_CLASS_ENTRY(*klass)) {
                     RETURN_FALSE;
              }
              ce = Z_OBJCE_P(klass);
       } else if (Z_TYPE_P(klass) == IS_STRING) {
              if (zend_lookup_class(Z_STRVAL_P(klass), Z_STRLEN_P(klass), &pce TSRMLS_CC) == SUCCESS) {
                     ce = *pce;
              }
       }

       if (!ce) {
              RETURN_NULL();
       }

       array_init(return_value);
       zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);

       while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
              if ((mptr->common.fn_flags & ZEND_ACC_PUBLIC) 
               || (EG(scope) &&
                   (((mptr->common.fn_flags & ZEND_ACC_PROTECTED) &&
                     zend_check_protected(mptr->common.scope, EG(scope)))
                 || ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) &&
                     EG(scope) == mptr->common.scope)))) {
                     char *key;
                     uint key_len;
                     ulong num_index;
                     uint len = strlen(mptr->common.function_name);

                     /* Do not display old-style inherited constructors */
                     if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
                         mptr->common.scope == ce ||
                         zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING ||
                         zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0) {

                            MAKE_STD_ZVAL(method_name);
                            ZVAL_STRINGL(method_name, mptr->common.function_name, len, 1);
                            zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL);
                     }
              }
              zend_hash_move_forward_ex(&ce->function_table, &pos);
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( trigger_error  ) [static]

Definition at line 1383 of file zend_builtin_functions.c.

{
       long error_type = E_USER_NOTICE;
       char *message;
       int message_len;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &message, &message_len, &error_type) == FAILURE) {
              return;
       }

       switch (error_type) {
              case E_USER_ERROR:
              case E_USER_WARNING:
              case E_USER_NOTICE:
              case E_USER_DEPRECATED:
                     break;
              default:
                     zend_error(E_WARNING, "Invalid error type specified");
                     RETURN_FALSE;
                     break;
       }

       zend_error((int)error_type, "%s", message);
       RETURN_TRUE;
}

Here is the call graph for this function:

ZEND_FUNCTION ( set_error_handler  ) [static]

Definition at line 1413 of file zend_builtin_functions.c.

{
       zval *error_handler;
       zend_bool had_orig_error_handler=0;
       char *error_handler_name = NULL;
       long error_type = E_ALL | E_STRICT;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) {
              return;
       }

       if (!zend_is_callable(error_handler, 0, &error_handler_name TSRMLS_CC)) {
              zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
                               get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name:"unknown");
              efree(error_handler_name);
              return;
       }
       efree(error_handler_name);

       if (EG(user_error_handler)) {
              had_orig_error_handler = 1;
              *return_value = *EG(user_error_handler);
              zval_copy_ctor(return_value);
              INIT_PZVAL(return_value);
              zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting)));
              zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler));
       }
       ALLOC_ZVAL(EG(user_error_handler));

       if (!zend_is_true(error_handler)) { /* unset user-defined handler */
              FREE_ZVAL(EG(user_error_handler));
              EG(user_error_handler) = NULL;
              RETURN_TRUE;
       }

       EG(user_error_handler_error_reporting) = (int)error_type;
       *EG(user_error_handler) = *error_handler;
       zval_copy_ctor(EG(user_error_handler));
       INIT_PZVAL(EG(user_error_handler));

       if (!had_orig_error_handler) {
              RETURN_NULL();
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( restore_error_handler  ) [static]

Definition at line 1462 of file zend_builtin_functions.c.

{
       if (EG(user_error_handler)) {
              zval *zeh = EG(user_error_handler);

              EG(user_error_handler) = NULL;
              zval_ptr_dtor(&zeh);
       }

       if (zend_ptr_stack_num_elements(&EG(user_error_handlers))==0) {
              EG(user_error_handler) = NULL;
       } else {
              EG(user_error_handler_error_reporting) = zend_stack_int_top(&EG(user_error_handlers_error_reporting));
              zend_stack_del_top(&EG(user_error_handlers_error_reporting));
              EG(user_error_handler) = zend_ptr_stack_pop(&EG(user_error_handlers));
       }
       RETURN_TRUE;
}

Here is the call graph for this function:

ZEND_FUNCTION ( set_exception_handler  ) [static]

Definition at line 1485 of file zend_builtin_functions.c.

{
       zval *exception_handler;
       char *exception_handler_name = NULL;
       zend_bool had_orig_exception_handler=0;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &exception_handler) == FAILURE) {
              return;
       }

       if (Z_TYPE_P(exception_handler) != IS_NULL) { /* NULL == unset */
              if (!zend_is_callable(exception_handler, 0, &exception_handler_name TSRMLS_CC)) {
                     zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
                                      get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name:"unknown");
                     efree(exception_handler_name);
                     return;
              }
              efree(exception_handler_name);
       }

       if (EG(user_exception_handler)) {
              had_orig_exception_handler = 1;
              *return_value = *EG(user_exception_handler);
              zval_copy_ctor(return_value);
              zend_ptr_stack_push(&EG(user_exception_handlers), EG(user_exception_handler));
       }
       ALLOC_ZVAL(EG(user_exception_handler));

       if (Z_TYPE_P(exception_handler) == IS_NULL) { /* unset user-defined handler */
              FREE_ZVAL(EG(user_exception_handler));
              EG(user_exception_handler) = NULL;
              RETURN_TRUE;
       }

       *EG(user_exception_handler) = *exception_handler;
       zval_copy_ctor(EG(user_exception_handler));

       if (!had_orig_exception_handler) {
              RETURN_NULL();
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( restore_exception_handler  ) [static]

Definition at line 1531 of file zend_builtin_functions.c.

{
       if (EG(user_exception_handler)) {
              zval_ptr_dtor(&EG(user_exception_handler));
       }
       if (zend_ptr_stack_num_elements(&EG(user_exception_handlers))==0) {
              EG(user_exception_handler) = NULL;
       } else {
              EG(user_exception_handler) = zend_ptr_stack_pop(&EG(user_exception_handlers));
       }
       RETURN_TRUE;
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_declared_classes  ) [static]

Definition at line 1564 of file zend_builtin_functions.c.

{
       zend_uint mask = ZEND_ACC_INTERFACE;
       zend_uint comply = 0;

       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       array_init(return_value);
       zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 3, return_value, mask, comply);
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_declared_interfaces  ) [static]

Definition at line 1580 of file zend_builtin_functions.c.

{
       zend_uint mask = ZEND_ACC_INTERFACE;
       zend_uint comply = 1;

       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       array_init(return_value);
       zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 3, return_value, mask, comply);
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_defined_functions  ) [static]

Definition at line 1616 of file zend_builtin_functions.c.

{
       zval *internal;
       zval *user;

       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       MAKE_STD_ZVAL(internal);
       MAKE_STD_ZVAL(user);

       array_init(internal);
       array_init(user);
       array_init(return_value);

       zend_hash_apply_with_arguments(EG(function_table) TSRMLS_CC, (apply_func_args_t) copy_function_name, 2, internal, user);

       if (zend_hash_add(Z_ARRVAL_P(return_value), "internal", sizeof("internal"), (void **)&internal, sizeof(zval *), NULL) == FAILURE) {
              zval_ptr_dtor(&internal);
              zval_ptr_dtor(&user);
              zval_dtor(return_value);
              zend_error(E_WARNING, "Cannot add internal functions to return value from get_defined_functions()");
              RETURN_FALSE;
       }

       if (zend_hash_add(Z_ARRVAL_P(return_value), "user", sizeof("user"), (void **)&user, sizeof(zval *), NULL) == FAILURE) {
              zval_ptr_dtor(&user);
              zval_dtor(return_value);
              zend_error(E_WARNING, "Cannot add user functions to return value from get_defined_functions()");
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_defined_vars  ) [static]

Definition at line 1654 of file zend_builtin_functions.c.

{
       if (!EG(active_symbol_table)) {
              zend_rebuild_symbol_table(TSRMLS_C);
       }

       array_init_size(return_value, zend_hash_num_elements(EG(active_symbol_table)));

       zend_hash_copy(Z_ARRVAL_P(return_value), EG(active_symbol_table),
                                   (copy_ctor_func_t)zval_add_ref, NULL, sizeof(zval *));
}

Here is the call graph for this function:

ZEND_FUNCTION ( create_function  ) [static]

Definition at line 1671 of file zend_builtin_functions.c.

{
       char *eval_code, *function_name, *function_args, *function_code;
       int eval_code_length, function_name_length, function_args_len, function_code_len;
       int retval;
       char *eval_name;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &function_args, &function_args_len, &function_code, &function_code_len) == FAILURE) {
              return;
       }

       eval_code = (char *) emalloc(sizeof("function " LAMBDA_TEMP_FUNCNAME)
                     +function_args_len
                     +2     /* for the args parentheses */
                     +2     /* for the curly braces */
                     +function_code_len);

       eval_code_length = sizeof("function " LAMBDA_TEMP_FUNCNAME "(") - 1;
       memcpy(eval_code, "function " LAMBDA_TEMP_FUNCNAME "(", eval_code_length);

       memcpy(eval_code + eval_code_length, function_args, function_args_len);
       eval_code_length += function_args_len;

       eval_code[eval_code_length++] = ')';
       eval_code[eval_code_length++] = '{';

       memcpy(eval_code + eval_code_length, function_code, function_code_len);
       eval_code_length += function_code_len;

       eval_code[eval_code_length++] = '}';
       eval_code[eval_code_length] = '\0';

       eval_name = zend_make_compiled_string_description("runtime-created function" TSRMLS_CC);
       retval = zend_eval_stringl(eval_code, eval_code_length, NULL, eval_name TSRMLS_CC);
       efree(eval_code);
       efree(eval_name);

       if (retval==SUCCESS) {
              zend_function new_function, *func;

              if (zend_hash_find(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME), (void **) &func)==FAILURE) {
                     zend_error(E_ERROR, "Unexpected inconsistency in create_function()");
                     RETURN_FALSE;
              }
              new_function = *func;
              function_add_ref(&new_function);

              function_name = (char *) emalloc(sizeof("0lambda_")+MAX_LENGTH_OF_LONG);
              function_name[0] = '\0';

              do {
                     function_name_length = 1 + snprintf(function_name + 1, sizeof("lambda_")+MAX_LENGTH_OF_LONG, "lambda_%d", ++EG(lambda_count));
              } while (zend_hash_add(EG(function_table), function_name, function_name_length+1, &new_function, sizeof(zend_function), NULL)==FAILURE);
              zend_hash_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME));
              RETURN_STRINGL(function_name, function_name_length, 0);
       } else {
              zend_hash_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME));
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_resource_type  ) [static]

Definition at line 1753 of file zend_builtin_functions.c.

{
       char *resource_type;
       zval *z_resource_type;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_resource_type) == FAILURE) {
              return;
       }

       resource_type = zend_rsrc_list_get_rsrc_type(Z_LVAL_P(z_resource_type) TSRMLS_CC);
       if (resource_type) {
              RETURN_STRING(resource_type, 1);
       } else {
              RETURN_STRING("Unknown", 1);
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_loaded_extensions  ) [static]

Definition at line 1802 of file zend_builtin_functions.c.

Here is the call graph for this function:

ZEND_FUNCTION ( extension_loaded  ) [static]

Definition at line 2271 of file zend_builtin_functions.c.

{
       char *extension_name;
       int extension_name_len;
       char *lcname;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &extension_name, &extension_name_len) == FAILURE) {
              return;
       }

       lcname = zend_str_tolower_dup(extension_name, extension_name_len);
       if (zend_hash_exists(&module_registry, lcname, extension_name_len+1)) {
              RETVAL_TRUE;
       } else {
              RETVAL_FALSE;
       }
       efree(lcname);
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_extension_funcs  ) [static]

Definition at line 2294 of file zend_builtin_functions.c.

{
       char *extension_name;
       int extension_name_len;
       zend_module_entry *module;
       const zend_function_entry *func;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &extension_name, &extension_name_len) == FAILURE) {
              return;
       }

       if (strncasecmp(extension_name, "zend", sizeof("zend"))) {
              char *lcname = zend_str_tolower_dup(extension_name, extension_name_len);
              if (zend_hash_find(&module_registry, lcname,
                     extension_name_len+1, (void**)&module) == FAILURE) {
                     efree(lcname);
                     RETURN_FALSE;
              }
              efree(lcname);

              if (!(func = module->functions)) {
                     RETURN_FALSE;
              }
       } else {
              func = builtin_functions;
       }

       array_init(return_value);

       while (func->fname) {
              add_next_index_string(return_value, func->fname, 1);
              func++;
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( get_defined_constants  ) [static]

Definition at line 1823 of file zend_builtin_functions.c.

{
       zend_bool categorize = 0;
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &categorize) == FAILURE) {
              return;
       }

       array_init(return_value);

       if (categorize) {
              HashPosition pos;
              zend_constant *val;
              int module_number;
              zval **modules;
              char **module_names;
              zend_module_entry *module;
              int i = 1;

              modules = ecalloc(zend_hash_num_elements(&module_registry) + 2, sizeof(zval *));
              module_names = emalloc((zend_hash_num_elements(&module_registry) + 2) * sizeof(char *));

              module_names[0] = "internal";
              zend_hash_internal_pointer_reset_ex(&module_registry, &pos);
              while (zend_hash_get_current_data_ex(&module_registry, (void *) &module, &pos) != FAILURE) {
                     module_names[module->module_number] = (char *)module->name;
                     i++;
                     zend_hash_move_forward_ex(&module_registry, &pos);
              }
              module_names[i] = "user";

              zend_hash_internal_pointer_reset_ex(EG(zend_constants), &pos);
              while (zend_hash_get_current_data_ex(EG(zend_constants), (void **) &val, &pos) != FAILURE) {
                     zval *const_val;

                     if (val->module_number == PHP_USER_CONSTANT) {
                            module_number = i;
                     } else if (val->module_number > i || val->module_number < 0) {
                            /* should not happen */
                            goto bad_module_id;
                     } else {
                            module_number = val->module_number;
                     }

                     if (!modules[module_number]) {
                            MAKE_STD_ZVAL(modules[module_number]);
                            array_init(modules[module_number]);
                            add_assoc_zval(return_value, module_names[module_number], modules[module_number]);
                     }

                     MAKE_STD_ZVAL(const_val);
                     *const_val = val->value;
                     zval_copy_ctor(const_val);
                     INIT_PZVAL(const_val);

                     add_assoc_zval_ex(modules[module_number], val->name, val->name_len, const_val);
bad_module_id:
                     zend_hash_move_forward_ex(EG(zend_constants), &pos);
              }
              efree(module_names);
              efree(modules);
       } else {
              zend_hash_apply_with_argument(EG(zend_constants), (apply_func_arg_t) add_constant_info, return_value TSRMLS_CC);
       }
}

Here is the call graph for this function:

ZEND_FUNCTION ( debug_backtrace  ) [static]

Definition at line 2257 of file zend_builtin_functions.c.

{
       long options = DEBUG_BACKTRACE_PROVIDE_OBJECT;
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &options) == FAILURE) {
              return;
       }

       zend_fetch_debug_backtrace(return_value, 1, options TSRMLS_CC);
}

Here is the call graph for this function:

ZEND_FUNCTION ( debug_print_backtrace  ) [static]

Definition at line 1934 of file zend_builtin_functions.c.

{
       zend_execute_data *ptr, *skip;
       int lineno;
       char *function_name;
       char *filename;
       char *class_name = NULL;
       char *call_type;
       char *include_filename = NULL;
       zval *arg_array = NULL;
       int indent = 0;
       long options = 0;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &options) == FAILURE) {
              return;
       }

       ptr = EG(current_execute_data);

       /* skip debug_backtrace() */
       ptr = ptr->prev_execute_data;

       while (ptr) {
              char *free_class_name = NULL;

              class_name = call_type = NULL;   
              arg_array = NULL;

              skip = ptr;
              /* skip internal handler */
              if (!skip->op_array &&
                  skip->prev_execute_data &&
                  skip->prev_execute_data->opline &&
                  skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL &&
                  skip->prev_execute_data->opline->opcode != ZEND_DO_FCALL_BY_NAME &&
                  skip->prev_execute_data->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
                     skip = skip->prev_execute_data;
              }

              if (skip->op_array) {
                     filename = skip->op_array->filename;
                     lineno = skip->opline->lineno;
              } else {
                     filename = NULL;
                     lineno = 0;
              }

              function_name = ptr->function_state.function->common.function_name;

              if (function_name) {
                     if (ptr->object) {
                            if (ptr->function_state.function->common.scope) {
                                   class_name = ptr->function_state.function->common.scope->name;
                            } else {
                                   zend_uint class_name_len;
                                   int dup;

                                   dup = zend_get_object_classname(ptr->object, &class_name, &class_name_len TSRMLS_CC);
                                   if(!dup) {
                                          free_class_name = class_name;
                                   }
                            }

                            call_type = "->";
                     } else if (ptr->function_state.function->common.scope) {
                            class_name = ptr->function_state.function->common.scope->name;
                            call_type = "::";
                     } else {
                            class_name = NULL;
                            call_type = NULL;
                     }
                     if ((! ptr->opline) || ((ptr->opline->opcode == ZEND_DO_FCALL_BY_NAME) || (ptr->opline->opcode == ZEND_DO_FCALL))) {
                            if (ptr->function_state.arguments && (options & DEBUG_BACKTRACE_IGNORE_ARGS) == 0) {
                                   arg_array = debug_backtrace_get_args(ptr->function_state.arguments TSRMLS_CC);
                            }
                     }
              } else {
                     /* i know this is kinda ugly, but i'm trying to avoid extra cycles in the main execution loop */
                     zend_bool build_filename_arg = 1;

                     if (!ptr->opline || ptr->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
                            /* can happen when calling eval from a custom sapi */
                            function_name = "unknown";
                            build_filename_arg = 0;
                     } else
                     switch (Z_LVAL(ptr->opline->op2.u.constant)) {
                            case ZEND_EVAL:
                                   function_name = "eval";
                                   build_filename_arg = 0;
                                   break;
                            case ZEND_INCLUDE:
                                   function_name = "include";
                                   break;
                            case ZEND_REQUIRE:
                                   function_name = "require";
                                   break;
                            case ZEND_INCLUDE_ONCE:
                                   function_name = "include_once";
                                   break;
                            case ZEND_REQUIRE_ONCE:
                                   function_name = "require_once";
                                   break;
                            default:
                                   /* this can actually happen if you use debug_backtrace() in your error_handler and 
                                    * you're in the top-scope */
                                   function_name = "unknown"; 
                                   build_filename_arg = 0;
                                   break;
                     }

                     if (build_filename_arg && include_filename) {
                            MAKE_STD_ZVAL(arg_array);
                            array_init(arg_array);
                            add_next_index_string(arg_array, include_filename, 1);
                     }
                     call_type = NULL;
              }
              zend_printf("#%-2d ", indent);
              if (class_name) {
                     ZEND_PUTS(class_name);
                     ZEND_PUTS(call_type);
              }
              zend_printf("%s(", function_name);
              if (arg_array) {
                     debug_print_backtrace_args(arg_array TSRMLS_CC);
                     zval_ptr_dtor(&arg_array);
              }
              if (filename) {
                     zend_printf(") called at [%s:%d]\n", filename, lineno);
              } else {
                     zend_execute_data *prev = skip->prev_execute_data;

                     while (prev) {
                            if (prev->function_state.function &&
                                   prev->function_state.function->common.type != ZEND_USER_FUNCTION) {
                                   prev = NULL;
                                   break;
                            }                               
                            if (prev->op_array) {
                                   zend_printf(") called at [%s:%d]\n", prev->op_array->filename, prev->opline->lineno);
                                   break;
                            }
                            prev = prev->prev_execute_data;
                     }
                     if (!prev) {
                            ZEND_PUTS(")\n");
                     }
              }
              include_filename = filename;
              ptr = skip->prev_execute_data;
              ++indent;
              if (free_class_name) {
                     efree(free_class_name);
              }
       }
}

Here is the call graph for this function:

Definition at line 335 of file zend_builtin_functions.c.

Here is the call graph for this function:

ZEND_FUNCTION ( gc_enabled  ) [static]

Definition at line 343 of file zend_builtin_functions.c.

{
       RETURN_BOOL(GC_G(gc_enabled));
}
ZEND_FUNCTION ( gc_enable  ) [static]

Definition at line 351 of file zend_builtin_functions.c.

{
       zend_alter_ini_entry("zend.enable_gc", sizeof("zend.enable_gc"), "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
}

Here is the call graph for this function:

ZEND_FUNCTION ( gc_disable  ) [static]

Definition at line 359 of file zend_builtin_functions.c.

{
       zend_alter_ini_entry("zend.enable_gc", sizeof("zend.enable_gc"), "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
}

Here is the call graph for this function:

ZEND_MINIT_FUNCTION ( core  )

Definition at line 290 of file zend_builtin_functions.c.

                          { /* {{{ */
       zend_class_entry class_entry;

       INIT_CLASS_ENTRY(class_entry, "stdClass", NULL);
       zend_standard_class_def = zend_register_internal_class(&class_entry TSRMLS_CC);

       zend_register_default_classes(TSRMLS_C);

       return SUCCESS;
}

Here is the call graph for this function:

Definition at line 316 of file zend_builtin_functions.c.

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 222 of file zend_builtin_functions.c.

zend_module_entry zend_builtin_module