com php-src: Merge branch 'PHP-5.3' into PHP-5.4: README.inpu t_filter ext/dba/libflatfile/flatfile.c ext/dba/libinif ile/inifile.c
ext/enchant/enchant.c ext/filter/filter .c ext/mysqlnd/mysqlnd.h ext/phar/phar.c ext/posix/ posix.c ext/reflection/php_reflection.c ext/simplexml
/simplexml.c ext/sysvmsg/sysvmsg.c sapi/continuity/capi .c sapi/nsapi/nsapi.c
| From: | David Soria Parra | Date: | Tue, 20 Mar 2012 16:58:58 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.3' into PHP-5.4: README.inpu t_filter ext/dba/libflatfile/flatfile.c ext/dba/libinif ile/inifile.c ext/enchant/enchant.c ext/filter/filter .c ext/mysqlnd/mysqlnd.h ext/phar/phar.c ext/posix/ posix.c ext/reflection/php_reflection.c ext/simplexml /simplexml.c ext/sysvmsg/sysvmsg.c sapi/continuity/capi .c sapi/nsapi/nsapi.c |
||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-68075@lists.php.net to get a copy of this message | ||
Commit: c918ca57a7233206ec78ac00438eeb6830e3680b
Author: David Soria Parra <dsp@php.net> Tue, 20 Mar 2012 17:58:58 +0100
Parents: 71d894cd421d96517618e9d33dfea640499c8ffd f7b10abae939412e8b5cab69cd579e071deb446b
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c918ca57a7233206ec78ac00438eeb6830e3680b
Log:
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3:
Replace $Revision$ with $Id$ in keyword expansion enable files
Enable $Id$ expansion for files with the $Revision$ keyword
Conflicts:
ext/mysqlnd/mysqlnd.h
Changed paths:
MM README.input_filter
MM ext/dba/libflatfile/flatfile.c
MM ext/dba/libinifile/inifile.c
MM ext/enchant/enchant.c
MM ext/filter/filter.c
MM ext/mysqlnd/mysqlnd.h
MM ext/phar/phar.c
MM ext/posix/posix.c
MM ext/reflection/php_reflection.c
MM ext/simplexml/simplexml.c
MM ext/sysvmsg/sysvmsg.c
MM sapi/continuity/capi.c
MM sapi/nsapi/nsapi.c
c918ca57a7233206ec78ac00438eeb6830e3680b diff --combined README.input_filter index 4b83b9d,488ca82..e2941d0 --- a/README.input_filter +++ b/README.input_filter @@@ -19,7 -19,9 +19,7 @@@ A simple implementation might look lik original raw user data and adds a my_get_raw() function while the normal $_POST, $_GET and $_COOKIE arrays are only populated with stripped data. In this simple example all I am doing is calling strip_tags() on -the data. If register_globals is turned on, the default globals that -are created will be stripped ($foo) while a $RAW_foo is created with the -original user input. +the data. ZEND_BEGIN_MODULE_GLOBALS(my_input_filter) zval *post_array; @@@ -86,7 -88,7 +86,7 @@@ PHP_MINFO_FUNCTION(my_input_filter { php_info_print_table_start(); php_info_print_table_row( 2, "My Input Filter Support", "enabled" ); - php_info_print_table_row( 2, "Revision", "$Revision$"); + php_info_print_table_row( 2, "Revision", "$Id$"); php_info_print_table_end(); } @@@ -153,6 -155,8 +153,6 @@@ PHP_FUNCTION(my_get_raw int var_len; zval **tmp; zval *array_ptr = NULL; - HashTable *hash_ptr; - char *raw_var; if(zend_parse_parameters(2 TSRMLS_CC, "ls", &arg, &var, &var_len) == FAILURE) { return; @@@ -170,15 -174,23 +170,15 @@@ break; } - if(!array_ptr) RETURN_FALSE; - - /* - * I'm changing the variable name here because when running with register_globals on, - * the variable will end up in the global symbol table - */ - raw_var = emalloc(var_len+5); /* RAW_ and a \0 */ - strcpy(raw_var, "RAW_"); - strlcat(raw_var,var,var_len+5); - hash_ptr = HASH_OF(array_ptr); + if(!array_ptr) { + RETURN_FALSE; + } - if(zend_hash_find(hash_ptr, raw_var, var_len+5, (void **)&tmp) == SUCCESS) { + if(zend_hash_find(HASH_OF(array_ptr), var, var_len+5, (void **)&tmp) == SUCCESS) { *return_value = **tmp; zval_copy_ctor(return_value); } else { RETVAL_FALSE; } - efree(raw_var); } diff --combined ext/dba/libflatfile/flatfile.c index e81b8ea,081af74..bf85184 --- a/ext/dba/libflatfile/flatfile.c +++ b/ext/dba/libflatfile/flatfile.c @@@ -27,6 -27,7 +27,6 @@@ #include "php.h" #include "php_globals.h" -#include "safe_mode.h" #include <stdlib.h> #include <string.h> @@@ -306,7 -307,7 +306,7 @@@ datum flatfile_nextkey(flatfile *dba TS /* {{{ flatfile_version */ char *flatfile_version() { - return "1.0, $Revision$"; + return "1.0, $Id$"; } /* }}} */ diff --combined ext/dba/libinifile/inifile.c index 4c85087,f7157ed..35930d1 --- a/ext/dba/libinifile/inifile.c +++ b/ext/dba/libinifile/inifile.c @@@ -24,6 -24,7 +24,6 @@@ #include "php.h" #include "php_globals.h" -#include "safe_mode.h" #include <stdlib.h> #include <string.h> @@@ -42,7 -43,7 +42,7 @@@ /* {{{ inifile_version */ char *inifile_version() { - return "1.0, $Revision$"; + return "1.0, $Id$"; } /* }}} */ diff --combined ext/enchant/enchant.c index c85c22c,0126d9e..2d784eb --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@@ -124,7 -124,7 +124,7 @@@ ZEND_END_ARG_INFO( * * Every user visible function must have an entry in enchant_functions[]. */ -function_entry enchant_functions[] = { +zend_function_entry enchant_functions[] = { PHP_FE(enchant_broker_init, arginfo_enchant_broker_init) PHP_FE(enchant_broker_free, arginfo_enchant_broker_free) PHP_FE(enchant_broker_get_error, arginfo_enchant_broker_free) @@@ -244,8 -244,8 +244,8 @@@ static void php_enchant_broker_free(zen if (broker->pbroker) { if (broker->dictcnt && broker->dict) { if (broker->dict) { - int total, tofree; - tofree = total = broker->dictcnt-1; + int total; + total = broker->dictcnt-1; do { zend_list_delete(broker->dict[total]->rsrc_id); efree(broker->dict[total]); @@@ -326,7 -326,7 +326,7 @@@ PHP_MINFO_FUNCTION(enchant #elif defined(HAVE_ENCHANT_BROKER_SET_PARAM) php_info_print_table_row(2, "Libenchant Version", "1.5.0 or later"); #endif - php_info_print_table_row(2, "Revision", "$Revision$"); + php_info_print_table_row(2, "Revision", "$Id$"); php_info_print_table_end(); php_info_print_table_start(); @@@ -357,8 -357,8 +357,8 @@@ PHP_FUNCTION(enchant_broker_init enchant_broker *broker; EnchantBroker *pbroker; - if (ZEND_NUM_ARGS()) { - ZEND_WRONG_PARAM_COUNT(); + if (zend_parse_parameters_none() == FAILURE) { + return; } pbroker = enchant_broker_init(); @@@ -542,11 -542,6 +542,11 @@@ PHP_FUNCTION(enchant_broker_request_dic } PHP_ENCHANT_GET_BROKER; + + if (taglen == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tag cannot be empty"); + RETURN_FALSE; + } d = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag); if (d) { @@@ -591,7 -586,11 +591,7 @@@ PHP_FUNCTION(enchant_broker_request_pwl int pwllen; int pos; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &pwl, &pwllen) == FAILURE) { - RETURN_FALSE; - } - - if (strlen(pwl) != pwllen) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &broker, &pwl, &pwllen) == FAILURE) { RETURN_FALSE; } diff --combined ext/filter/filter.c index f2aae47,2b8c730..e523cdc --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@@ -276,7 -276,7 +276,7 @@@ PHP_MINIT_FUNCTION(filter REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_RES_RANGE", FILTER_FLAG_NO_RES_RANGE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_PRIV_RANGE", FILTER_FLAG_NO_PRIV_RANGE, CONST_CS | CONST_PERSISTENT); - sapi_register_input_filter(php_sapi_filter, php_sapi_filter_init); + sapi_register_input_filter(php_sapi_filter, php_sapi_filter_init TSRMLS_CC); return SUCCESS; } @@@ -318,7 -318,7 +318,7 @@@ PHP_MINFO_FUNCTION(filter { php_info_print_table_start(); php_info_print_table_row( 2, "Input Validation and Filtering", "enabled" ); - php_info_print_table_row( 2, "Revision", "$Revision$"); + php_info_print_table_row( 2, "Revision", "$Id$"); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); @@@ -406,6 -406,7 +406,6 @@@ static unsigned int php_sapi_filter(in { zval new_var, raw_var; zval *array_ptr = NULL, *orig_array_ptr = NULL; - char *orig_var = NULL; int retval = 0; assert(*val != NULL); @@@ -446,7 -447,13 +446,7 @@@ } if (array_ptr) { - /* Make a copy of the variable name, as php_register_variable_ex seems to - * modify it */ - orig_var = estrdup(var); - /* Store the RAW variable internally */ - /* FIXME: Should not use php_register_variable_ex as that also registers - * globals when register_globals is turned on */ Z_STRLEN(raw_var) = val_len; Z_STRVAL(raw_var) = estrndup(*val, val_len); Z_TYPE(raw_var) = IS_STRING; @@@ -456,6 -463,8 +456,6 @@@ if (val_len) { /* Register mangled variable */ - /* FIXME: Should not use php_register_variable_ex as that also registers - * globals when register_globals is turned on */ Z_STRLEN(new_var) = val_len; Z_TYPE(new_var) = IS_STRING; @@@ -464,6 -473,8 +464,6 @@@ Z_STRVAL(new_var) = estrndup(*val, val_len); INIT_PZVAL(tmp_new_var); php_zval_filter(&tmp_new_var, IF_G(default_filter), IF_G(default_filter_flags), NULL, NULL/*charset*/, 0 TSRMLS_CC); - } else if (PG(magic_quotes_gpc) && !retval) { /* for PARSE_STRING php_register_variable_safe() will do the addslashes() */ - Z_STRVAL(new_var) = php_addslashes(*val, Z_STRLEN(new_var), &Z_STRLEN(new_var), 0 TSRMLS_CC); } else { Z_STRVAL(new_var) = estrndup(*val, val_len); } @@@ -472,7 -483,10 +472,7 @@@ } if (orig_array_ptr) { - php_register_variable_ex(orig_var, &new_var, orig_array_ptr TSRMLS_CC); - } - if (array_ptr) { - efree(orig_var); + php_register_variable_ex(var, &new_var, orig_array_ptr TSRMLS_CC); } if (retval) { @@@ -525,6 -539,7 +525,6 @@@ static zval *php_filter_get_storage(lon { zval *array_ptr = NULL; - zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays)); switch (arg) { case PARSE_GET: @@@ -537,13 -552,13 +537,13 @@@ array_ptr = IF_G(cookie_array); break; case PARSE_SERVER: - if (jit_initialization) { + if (PG(auto_globals_jit)) { zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); } array_ptr = IF_G(server_array); break; case PARSE_ENV: - if (jit_initialization) { + if (PG(auto_globals_jit)) { zend_is_auto_global("_ENV", sizeof("_ENV")-1 TSRMLS_CC); } array_ptr = IF_G(env_array) ? IF_G(env_array) : PG(http_globals)[TRACK_VARS_ENV]; diff --combined ext/mysqlnd/mysqlnd.h index 11aea7a,65fe78e..b0b3b15 --- a/ext/mysqlnd/mysqlnd.h +++ b/ext/mysqlnd/mysqlnd.h @@@ -12,9 -12,9 +12,9 @@@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter <georg@mysql.com> | - | Andrey Hristov <andrey@mysql.com> | + | Authors: Andrey Hristov <andrey@mysql.com> | | Ulf Wendel <uwendel@mysql.com> | + | Georg Richter <georg@mysql.com> | +----------------------------------------------------------------------+ */ /* $Id$ */ @@@ -22,10 -22,12 +22,10 @@@ #ifndef MYSQLND_H #define MYSQLND_H - #define MYSQLND_VERSION "mysqlnd 5.0.10 - 20111026 - $Revision$" -#define MYSQLND_VERSION "mysqlnd 5.0.8-dev - 20102224 - $Id$" -#define MYSQLND_VERSION_ID 50008 ++#define MYSQLND_VERSION "mysqlnd 5.0.10 - 20111026 - $Id$" +#define MYSQLND_VERSION_ID 50010 -/* This forces inlining of some accessor functions */ -#define MYSQLND_USE_OPTIMISATIONS 0 -#define AUTOCOMMIT_TX_COMMIT_ROLLBACK +#define MYSQLND_PLUGIN_API_VERSION 1 #define MYSQLND_STRING_TO_INT_CONVERSION /* @@@ -67,16 -69,29 +67,16 @@@ PHPAPI void mysqlnd_library_init(TSRMLS PHPAPI void mysqlnd_library_end(TSRMLS_D); PHPAPI unsigned int mysqlnd_plugin_register(); +PHPAPI unsigned int mysqlnd_plugin_register_ex(struct st_mysqlnd_plugin_header * plugin TSRMLS_DC); PHPAPI unsigned int mysqlnd_plugin_count(); -PHPAPI void ** _mysqlnd_plugin_get_plugin_connection_data(const MYSQLND * conn, unsigned int plugin_id TSRMLS_DC); -#define mysqlnd_plugin_get_plugin_connection_data(c, p_id) _mysqlnd_plugin_get_plugin_connection_data((c), (p_id) TSRMLS_CC) +PHPAPI void * _mysqlnd_plugin_find(const char * const name TSRMLS_DC); +#define mysqlnd_plugin_find(name) _mysqlnd_plugin_find((name) TSRMLS_CC); -PHPAPI void ** _mysqlnd_plugin_get_plugin_result_data(const MYSQLND_RES * result, unsigned int plugin_id TSRMLS_DC); -#define mysqlnd_plugin_get_plugin_result_data(r, p_id) _mysqlnd_plugin_get_plugin_result_data((r), (p_id) TSRMLS_CC) +PHPAPI void _mysqlnd_plugin_apply_with_argument(apply_func_arg_t apply_func, void * argument TSRMLS_DC); +#define mysqlnd_plugin_apply_with_argument(func, argument) _mysqlnd_plugin_apply_with_argument((func), (argument) TSRMLS_CC); -PHPAPI void ** _mysqlnd_plugin_get_plugin_stmt_data(const MYSQLND_STMT * stmt, unsigned int plugin_id TSRMLS_DC); -#define mysqlnd_plugin_get_plugin_stmt_data(s, p_id) _mysqlnd_plugin_get_plugin_stmt_data((s), (p_id) TSRMLS_CC) - -PHPAPI void ** _mysqlnd_plugin_get_plugin_protocol_data(const MYSQLND_PROTOCOL * protocol, unsigned int plugin_id TSRMLS_DC); -#define mysqlnd_plugin_get_plugin_protocol_data(p, p_id) _mysqlnd_plugin_get_plugin_protocol_data((p), (p_id) TSRMLS_CC) - - -PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods(); -PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods); - -PHPAPI struct st_mysqlnd_stmt_methods * mysqlnd_stmt_get_methods(); -PHPAPI void mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods *methods); - - -#define mysqlnd_restart_psession(conn) (conn)->m->restart_psession((conn) TSRMLS_CC) -#define mysqlnd_end_psession(conn) (conn)->m->end_psession((conn) TSRMLS_CC) +#define mysqlnd_restart_psession(conn) ((conn)->data)->m->restart_psession((conn)->data TSRMLS_CC) +#define mysqlnd_end_psession(conn) ((conn)->data)->m->end_psession((conn)->data TSRMLS_CC) PHPAPI void mysqlnd_minfo_print_hash(zval *values); #define mysqlnd_thread_safe() TRUE @@@ -87,17 -102,16 +87,17 @@@ PHPAPI const MYSQLND_CHARSET * mysqlnd_ /* Connect */ #define mysqlnd_init(persistent) _mysqlnd_init((persistent) TSRMLS_CC) PHPAPI MYSQLND * _mysqlnd_init(zend_bool persistent TSRMLS_DC); -PHPAPI MYSQLND * mysqlnd_connect(MYSQLND *conn, - const char *host, const char *user, - const char *passwd, unsigned int passwd_len, - const char *db, unsigned int db_len, +PHPAPI MYSQLND * mysqlnd_connect(MYSQLND * conn, + const char * host, const char * user, + const char * passwd, unsigned int passwd_len, + const char * db, unsigned int db_len, unsigned int port, - const char *socket_or_pipe, + const char * socket_or_pipe, unsigned int mysql_flags TSRMLS_DC); -#define mysqlnd_change_user(conn, user, passwd, db, silent) (conn)->m->change_user((conn), (user), (passwd), (db), (silent) TSRMLS_CC) +#define mysqlnd_change_user(conn, user, passwd, db, silent) ((conn)->data)->m->change_user((conn)->data, (user), (passwd), (db), (silent), strlen((passwd)) TSRMLS_CC) +#define mysqlnd_change_user_ex(conn, user, passwd, db, silent, passwd_len) ((conn)->data)->m->change_user((conn)->data, (user), (passwd), (db), (silent), (passwd_len) TSRMLS_CC) #define mysqlnd_debug(x) _mysqlnd_debug((x) TSRMLS_CC) PHPAPI void _mysqlnd_debug(const char *mode TSRMLS_DC); @@@ -107,45 -121,43 +107,45 @@@ #define mysqlnd_fetch_row_c(result) (result)->m.fetch_row_c((result) TSRMLS_CC) #define mysqlnd_fetch_all(result, flags, return_value) (result)->m.fetch_all((result), (flags), (return_value) TSRMLS_CC ZEND_FILE_LINE_CC) #define mysqlnd_result_fetch_field_data(res,offset,ret) (res)->m.fetch_field_data((res), (offset), (ret) TSRMLS_CC) -#define mysqlnd_get_connection_stats(conn, values) (conn)->m->get_statistics((conn), (values) TSRMLS_CC ZEND_FILE_LINE_CC) +#define mysqlnd_get_connection_stats(conn, values) ((conn)->data)->m->get_statistics((conn)->data, (values) TSRMLS_CC ZEND_FILE_LINE_CC) #define mysqlnd_get_client_stats(values) _mysqlnd_get_client_stats((values) TSRMLS_CC ZEND_FILE_LINE_CC) #define mysqlnd_close(conn,is_forced) (conn)->m->close((conn), (is_forced) TSRMLS_CC) -#define mysqlnd_query(conn, query_str, query_len) (conn)->m->query((conn), (query_str), (query_len) TSRMLS_CC) -#define mysqlnd_async_query(conn, query_str, query_len) (conn)->m->send_query((conn), (query_str), (query_len) TSRMLS_CC) +#define mysqlnd_query(conn, query_str, query_len) ((conn)->data)->m->query((conn)->data, (query_str), (query_len) TSRMLS_CC) +#define mysqlnd_async_query(conn, query_str, query_len) ((conn)->data)->m->send_query((conn)->data, (query_str), (query_len) TSRMLS_CC) #define mysqlnd_poll(r, err, d_pull,sec,usec,desc_num) _mysqlnd_poll((r), (err), (d_pull), (sec), (usec), (desc_num) TSRMLS_CC) -#define mysqlnd_reap_async_query(conn) (conn)->m->reap_query((conn) TSRMLS_CC) +#define mysqlnd_reap_async_query(conn) ((conn)->data)->m->reap_query((conn)->data TSRMLS_CC) #define mysqlnd_unbuffered_skip_result(result) (result)->m.skip_result((result) TSRMLS_CC) PHPAPI enum_func_status _mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQLND ***dont_poll, long sec, long usec, uint * desc_num TSRMLS_DC); -#define mysqlnd_use_result(conn) (conn)->m->use_result((conn) TSRMLS_CC) -#define mysqlnd_store_result(conn) (conn)->m->store_result((conn) TSRMLS_CC) -#define mysqlnd_next_result(conn) (conn)->m->next_result((conn) TSRMLS_CC) -#define mysqlnd_more_results(conn) (conn)->m->more_results((conn) TSRMLS_CC) +#define mysqlnd_use_result(conn) ((conn)->data)->m->use_result((conn)->data TSRMLS_CC) +#define mysqlnd_store_result(conn) ((conn)->data)->m->store_result((conn)->data TSRMLS_CC) +#define mysqlnd_next_result(conn) ((conn)->data)->m->next_result((conn)->data TSRMLS_CC) +#define mysqlnd_more_results(conn) ((conn)->data)->m->more_results((conn)->data TSRMLS_CC) #define mysqlnd_free_result(r,e_or_i) ((MYSQLND_RES*)r)->m.free_result(((MYSQLND_RES*)(r)), (e_or_i) TSRMLS_CC) #define mysqlnd_data_seek(result, row) (result)->m.seek_data((result), (row) TSRMLS_CC) /* Errors */ -#define mysqlnd_errno(conn) (conn)->m->get_error_no((conn) TSRMLS_CC) -#define mysqlnd_error(conn) (conn)->m->get_error_str((conn) TSRMLS_CC) -#define mysqlnd_sqlstate(conn) (conn)->m->get_sqlstate((conn) TSRMLS_CC) +#define mysqlnd_errno(conn) ((conn)->data)->m->get_error_no((conn)->data TSRMLS_CC) +#define mysqlnd_error(conn) ((conn)->data)->m->get_error_str((conn)->data TSRMLS_CC) +#define mysqlnd_sqlstate(conn) ((conn)->data)->m->get_sqlstate((conn)->data TSRMLS_CC) /* Charset */ -#define mysqlnd_character_set_name(conn) (conn)->m->charset_name((conn) TSRMLS_CC) +#define mysqlnd_character_set_name(conn) ((conn)->data)->m->charset_name((conn)->data TSRMLS_CC) /* Simple metadata */ -#define mysqlnd_field_count(conn) (conn)->m->get_field_count((conn) TSRMLS_CC) -#define mysqlnd_insert_id(conn) (conn)->m->get_last_insert_id((conn) TSRMLS_CC) -#define mysqlnd_affected_rows(conn) (conn)->m->get_affected_rows((conn) TSRMLS_CC) -#define mysqlnd_warning_count(conn) (conn)->m->get_warning_count((conn) TSRMLS_CC) -#define mysqlnd_info(conn) (conn)->m->get_last_message((conn) TSRMLS_CC) -#define mysqlnd_get_server_info(conn) (conn)->m->get_server_information((conn) TSRMLS_CC) -#define mysqlnd_get_host_info(conn) (conn)->m->get_host_information((conn) TSRMLS_CC) -#define mysqlnd_get_proto_info(conn) (conn)->m->get_protocol_information((conn) TSRMLS_CC) -#define mysqlnd_thread_id(conn) (conn)->m->get_thread_id((conn) TSRMLS_CC) +#define mysqlnd_field_count(conn) ((conn)->data)->m->get_field_count((conn)->data TSRMLS_CC) +#define mysqlnd_insert_id(conn) ((conn)->data)->m->get_last_insert_id((conn)->data TSRMLS_CC) +#define mysqlnd_affected_rows(conn) ((conn)->data)->m->get_affected_rows((conn)->data TSRMLS_CC) +#define mysqlnd_warning_count(conn) ((conn)->data)->m->get_warning_count((conn)->data TSRMLS_CC) +#define mysqlnd_info(conn) ((conn)->data)->m->get_last_message((conn)->data TSRMLS_CC) +#define mysqlnd_get_server_info(conn) ((conn)->data)->m->get_server_information((conn)->data TSRMLS_CC) +#define mysqlnd_get_server_version(conn) ((conn)->data)->m->get_server_version((conn)->data TSRMLS_CC) +#define mysqlnd_get_host_info(conn) ((conn)->data)->m->get_host_information((conn)->data TSRMLS_CC) +#define mysqlnd_get_proto_info(conn) ((conn)->data)->m->get_protocol_information((conn)->data TSRMLS_CC) +#define mysqlnd_thread_id(conn) ((conn)->data)->m->get_thread_id((conn)->data TSRMLS_CC) +#define mysqlnd_get_server_status(conn) ((conn)->data)->m->get_server_status((conn)->data TSRMLS_CC) #define mysqlnd_num_rows(result) (result)->m.num_rows((result) TSRMLS_CC) #define mysqlnd_num_fields(result) (result)->m.num_fields((result) TSRMLS_CC) @@@ -163,7 -175,7 +163,7 @@@ PHPAPI unsigned long * _mysqlnd_fetch_l PHPAPI const char * mysqlnd_get_client_info(); PHPAPI unsigned int mysqlnd_get_client_version(); -#define mysqlnd_ssl_set(conn, key, cert, ca, capath, cipher) (conn)->m->ssl_set((conn), (key), (cert), (ca), (capath), (cipher) TSRMLS_CC) +#define mysqlnd_ssl_set(conn, key, cert, ca, capath, cipher) ((conn)->data)->m->ssl_set((conn)->data, (key), (cert), (ca), (capath), (cipher) TSRMLS_CC) /* PS */ #define mysqlnd_stmt_insert_id(stmt) (stmt)->m->get_last_insert_id((stmt) TSRMLS_CC) @@@ -187,39 -199,46 +187,39 @@@ PHPAPI void mysqlnd_free_result_bind_dt PHPAPI const char * mysqlnd_field_type_name(enum mysqlnd_field_types field_type); /* LOAD DATA LOCAL */ -PHPAPI void mysqlnd_local_infile_default(MYSQLND *conn); -PHPAPI void mysqlnd_set_local_infile_handler(MYSQLND * const conn, const char * const funcname); +PHPAPI void mysqlnd_local_infile_default(MYSQLND_CONN_DATA * conn); +PHPAPI void mysqlnd_set_local_infile_handler(MYSQLND_CONN_DATA * const conn, const char * const funcname); /* Simple commands */ -#ifdef AUTOCOMMIT_TX_COMMIT_ROLLBACK -#define mysqlnd_autocommit(conn, mode) (conn)->m->set_autocommit((conn), (mode) TSRMLS_CC) -#define mysqlnd_commit(conn) (conn)->m->tx_commit((conn) TSRMLS_CC) -#define mysqlnd_rollback(conn) (conn)->m->tx_rollback((conn) TSRMLS_CC) -#else -#define mysqlnd_autocommit(conn, mode) (conn)->m->query((conn),(mode) ? "SET AUTOCOMMIT=1":"SET AUTOCOMMIT=0", 16 TSRMLS_CC) -#define mysqlnd_commit(conn) (conn)->m->query((conn), "COMMIT", sizeof("COMMIT")-1 TSRMLS_CC) -#define mysqlnd_rollback(conn) (conn)->m->query((conn), "ROLLBACK", sizeof("ROLLBACK")-1 TSRMLS_CC) -#endif -#define mysqlnd_list_dbs(conn, wild) (conn)->m->list_method((conn), wild? "SHOW DATABASES LIKE %s":"SHOW DATABASES", (wild), NULL TSRMLS_CC) -#define mysqlnd_list_fields(conn, tab,wild) (conn)->m->list_fields((conn), (tab), (wild) TSRMLS_CC) -#define mysqlnd_list_processes(conn) (conn)->m->list_method((conn), "SHOW PROCESSLIST", NULL, NULL TSRMLS_CC) -#define mysqlnd_list_tables(conn, wild) (conn)->m->list_method((conn), wild? "SHOW TABLES LIKE %s":"SHOW TABLES", (wild), NULL TSRMLS_CC) -#define mysqlnd_dump_debug_info(conn) (conn)->m->server_dump_debug_information((conn) TSRMLS_CC) -#define mysqlnd_select_db(conn, db, db_len) (conn)->m->select_db((conn), (db), (db_len) TSRMLS_CC) -#define mysqlnd_ping(conn) (conn)->m->ping((conn) TSRMLS_CC) -#define mysqlnd_kill(conn, pid) (conn)->m->kill_connection((conn), (pid) TSRMLS_CC) -#define mysqlnd_refresh(conn, options) (conn)->m->refresh_server((conn), (options) TSRMLS_CC) -#define mysqlnd_shutdown(conn, level) (conn)->m->shutdown_server((conn), (level) TSRMLS_CC) -#define mysqlnd_get_server_version(conn) (conn)->m->get_server_version((conn) TSRMLS_CC) -#define mysqlnd_set_character_set(conn, cs) (conn)->m->set_charset((conn), (cs) TSRMLS_CC) -#define mysqlnd_stat(conn, msg, msg_len) (conn)->m->get_server_statistics((conn), (msg), (msg_len) TSRMLS_CC) -#define mysqlnd_options(conn, opt, value) (conn)->m->set_client_option((conn), (opt), (value) TSRMLS_CC) -#define mysqlnd_set_server_option(conn, op) (conn)->m->set_server_option((conn), (op) TSRMLS_CC) +#define mysqlnd_autocommit(conn, mode) ((conn)->data)->m->set_autocommit((conn)->data, (mode) TSRMLS_CC) +#define mysqlnd_commit(conn) ((conn)->data)->m->tx_commit((conn)->data TSRMLS_CC) +#define mysqlnd_rollback(conn) ((conn)->data)->m->tx_rollback((conn)->data TSRMLS_CC) +#define mysqlnd_list_dbs(conn, wild) ((conn)->data)->m->list_method((conn)->data, wild? "SHOW DATABASES LIKE %s":"SHOW DATABASES", (wild), NULL TSRMLS_CC) +#define mysqlnd_list_fields(conn, tab,wild) ((conn)->data)->m->list_fields((conn)->data, (tab), (wild) TSRMLS_CC) +#define mysqlnd_list_processes(conn) ((conn)->data)->m->list_method((conn)->data, "SHOW PROCESSLIST", NULL, NULL TSRMLS_CC) +#define mysqlnd_list_tables(conn, wild) ((conn)->data)->m->list_method((conn)->data, wild? "SHOW TABLES LIKE %s":"SHOW TABLES", (wild), NULL TSRMLS_CC) +#define mysqlnd_dump_debug_info(conn) ((conn)->data)->m->server_dump_debug_information((conn)->data TSRMLS_CC) +#define mysqlnd_select_db(conn, db, db_len) ((conn)->data)->m->select_db((conn)->data, (db), (db_len) TSRMLS_CC) +#define mysqlnd_ping(conn) ((conn)->data)->m->ping((conn)->data TSRMLS_CC) +#define mysqlnd_kill(conn, pid) ((conn)->data)->m->kill_connection((conn)->data, (pid) TSRMLS_CC) +#define mysqlnd_refresh(conn, options) ((conn)->data)->m->refresh_server((conn)->data, (options) TSRMLS_CC) +#define mysqlnd_shutdown(conn, level) ((conn)->data)->m->shutdown_server((conn)->data, (level) TSRMLS_CC) +#define mysqlnd_set_character_set(conn, cs) ((conn)->data)->m->set_charset((conn)->data, (cs) TSRMLS_CC) +#define mysqlnd_stat(conn, msg, msg_len) ((conn)->data)->m->get_server_statistics(((conn)->data), (msg), (msg_len) TSRMLS_CC) +#define mysqlnd_options(conn, opt, value) ((conn)->data)->m->set_client_option((conn)->data, (opt), (value) TSRMLS_CC) +#define mysqlnd_set_server_option(conn, op) ((conn)->data)->m->set_server_option((conn)->data, (op) TSRMLS_CC) /* Escaping */ #define mysqlnd_real_escape_string(conn, newstr, escapestr, escapestr_len) \ - (conn)->m->escape_string((conn), (newstr), (escapestr), (escapestr_len) TSRMLS_CC) + ((conn)->data)->m->escape_string((conn)->data, (newstr), (escapestr), (escapestr_len) TSRMLS_CC) #define mysqlnd_escape_string(newstr, escapestr, escapestr_len) \ mysqlnd_old_escape_string((newstr), (escapestr), (escapestr_len) TSRMLS_CC) -PHPAPI ulong mysqlnd_old_escape_string(char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC); +PHPAPI ulong mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC); /* PS */ -#define mysqlnd_stmt_init(conn) (conn)->m->stmt_init((conn) TSRMLS_CC) +#define mysqlnd_stmt_init(conn) ((conn)->data)->m->stmt_init(((conn)->data) TSRMLS_CC) #define mysqlnd_stmt_store_result(stmt) (!mysqlnd_stmt_field_count((stmt)) ? PASS:((stmt)->m->store_result((stmt) TSRMLS_CC)? PASS:FAIL)) #define mysqlnd_stmt_get_result(stmt) (stmt)->m->get_result((stmt) TSRMLS_CC) #define mysqlnd_stmt_more_results(stmt) (stmt)->m->more_results((stmt) TSRMLS_CC) @@@ -243,7 -262,6 +243,7 @@@ #define mysqlnd_stmt_free_result(stmt) (stmt)->m->free_result((stmt) TSRMLS_CC) #define mysqlnd_stmt_close(stmt, implicit) (stmt)->m->dtor((stmt), (implicit) TSRMLS_CC) #define mysqlnd_stmt_reset(stmt) (stmt)->m->reset((stmt) TSRMLS_CC) +#define mysqlnd_stmt_flush(stmt) (stmt)->m->flush((stmt) TSRMLS_CC) #define mysqlnd_stmt_attr_get(stmt, attr, value) (stmt)->m->get_attribute((stmt), (attr), (value) TSRMLS_CC) diff --combined ext/phar/phar.c index d9d9b08,d8eaad1..2a47d3d --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@@ -1738,30 -1738,31 +1738,30 @@@ static int phar_open_from_fp(php_stream static int phar_analyze_path(const char *fname, const char *ext, int ext_len, int for_create TSRMLS_DC) /* {{{ */ { php_stream_statbuf ssb; - char *realpath, old, *a = (char *)(ext + ext_len); + char *realpath; + char *filename = estrndup(fname, (ext - fname) + ext_len); - old = *a; - *a = '\0'; - - if ((realpath = expand_filepath(fname, NULL TSRMLS_CC))) { + if ((realpath = expand_filepath(filename, NULL TSRMLS_CC))) { #ifdef PHP_WIN32 phar_unixify_path_separators(realpath, strlen(realpath)); #endif if (zend_hash_exists(&(PHAR_GLOBALS->phar_fname_map), realpath, strlen(realpath))) { - *a = old; efree(realpath); + efree(filename); return SUCCESS; } if (PHAR_G(manifest_cached) && zend_hash_exists(&cached_phars, realpath, strlen(realpath))) { - *a = old; efree(realpath); + efree(filename); return SUCCESS; } efree(realpath); } - if (SUCCESS == php_stream_stat_path((char *) fname, &ssb)) { - *a = old; + if (SUCCESS == php_stream_stat_path((char *) filename, &ssb)) { + + efree(filename); if (ssb.sb.st_mode & S_IFDIR) { return FAILURE; @@@ -1776,56 -1777,57 +1776,56 @@@ char *slash; if (!for_create) { - *a = old; + efree(filename); return FAILURE; } - slash = (char *) strrchr(fname, '/'); - *a = old; + slash = (char *) strrchr(filename, '/'); if (slash) { *slash = '\0'; } - if (SUCCESS != php_stream_stat_path((char *) fname, &ssb)) { - if (slash) { - *slash = old; - } else { - if (!(realpath = expand_filepath(fname, NULL TSRMLS_CC))) { + if (SUCCESS != php_stream_stat_path((char *) filename, &ssb)) { + if (!slash) { + if (!(realpath = expand_filepath(filename, NULL TSRMLS_CC))) { + efree(filename); return FAILURE; } #ifdef PHP_WIN32 phar_unixify_path_separators(realpath, strlen(realpath)); #endif - a = strstr(realpath, fname) + ((ext - fname) + ext_len); - *a = '\0'; + slash = strstr(realpath, filename) + ((ext - fname) + ext_len); + *slash = '\0'; slash = strrchr(realpath, '/'); if (slash) { *slash = '\0'; } else { efree(realpath); + efree(filename); return FAILURE; } if (SUCCESS != php_stream_stat_path(realpath, &ssb)) { efree(realpath); + efree(filename); return FAILURE; } efree(realpath); if (ssb.sb.st_mode & S_IFDIR) { + efree(filename); return SUCCESS; } } + efree(filename); return FAILURE; } - if (slash) { - *slash = old; - } + efree(filename); if (ssb.sb.st_mode & S_IFDIR) { return SUCCESS; @@@ -2333,7 -2335,7 +2333,7 @@@ int phar_open_executed_filename(char *a *error = NULL; } - fname = zend_get_executed_filename(TSRMLS_C); + fname = (char*)zend_get_executed_filename(TSRMLS_C); fname_len = strlen(fname); if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, 0, REPORT_ERRORS, NULL, 0 TSRMLS_CC) == SUCCESS) { @@@ -3338,7 -3340,7 +3338,7 @@@ static zend_op_array *phar_compile_file return phar_orig_compile_file(file_handle, type TSRMLS_CC); } if (strstr(file_handle->filename, ".phar") && !strstr(file_handle->filename, "://")) { - if (SUCCESS == phar_open_from_filename(file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL TSRMLS_CC)) { + if (SUCCESS == phar_open_from_filename((char*)file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL TSRMLS_CC)) { if (phar->is_zip || phar->is_tar) { zend_file_handle f = *file_handle; @@@ -3419,7 -3421,7 +3419,7 @@@ int phar_zend_open(const char *filename char *fname; int fname_len; - fname = zend_get_executed_filename(TSRMLS_C); + fname = (char*)zend_get_executed_filename(TSRMLS_C); fname_len = strlen(fname); if (fname_len > 7 && !strncasecmp(fname, "phar://", 7)) { @@@ -3667,7 -3669,7 +3667,7 @@@ PHP_MINFO_FUNCTION(phar) /* {{{ * php_info_print_table_header(2, "Phar: PHP Archive support", "enabled"); php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION); php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION); - php_info_print_table_row(2, "SVN revision", "$Revision$"); + php_info_print_table_row(2, "SVN revision", "$Id$"); php_info_print_table_row(2, "Phar-based phar archives", "enabled"); php_info_print_table_row(2, "Tar-based phar archives", "enabled"); php_info_print_table_row(2, "ZIP-based phar archives", "enabled"); diff --combined ext/posix/posix.c index 8e49c52,c00b746..967584c --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@@ -310,7 -310,7 +310,7 @@@ const zend_function_entry posix_functio static PHP_MINFO_FUNCTION(posix) { php_info_print_table_start(); - php_info_print_table_row(2, "Revision", "$Revision$"); + php_info_print_table_row(2, "Revision", "$Id$"); php_info_print_table_end(); } /* }}} */ @@@ -838,11 -838,16 +838,11 @@@ PHP_FUNCTION(posix_mkfifo long mode; int result; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &path, &path_len, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pl", &path, &path_len, &mode) == FAILURE) { RETURN_FALSE; } - if (strlen(path) != path_len) { - RETURN_FALSE; - } - - if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) || - (PG(safe_mode) && (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_DIR)))) { + if (php_check_open_basedir_ex(path, 0 TSRMLS_CC)) { RETURN_FALSE; } @@@ -871,12 -876,17 +871,12 @@@ PHP_FUNCTION(posix_mknod php_dev = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|ll", &path, &path_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pl|ll", &path, &path_len, &mode, &major, &minor) == FAILURE) { RETURN_FALSE; } - if (strlen(path) != path_len) { - RETURN_FALSE; - } - - if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) || - (PG(safe_mode) && (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_DIR)))) { + if (php_check_open_basedir_ex(path, 0 TSRMLS_CC)) { RETURN_FALSE; } @@@ -951,7 -961,11 +951,7 @@@ PHP_FUNCTION(posix_access int filename_len, ret; char *filename, *path; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, &filename_len, &mode) == FAILURE) { - RETURN_FALSE; - } - - if (strlen(filename) != filename_len) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &filename, &filename_len, &mode) == FAILURE) { RETURN_FALSE; } @@@ -961,7 -975,8 +961,7 @@@ RETURN_FALSE; } - if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) || - (PG(safe_mode) && (!php_checkuid_ex(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR, CHECKUID_NO_ERRORS)))) { + if (php_check_open_basedir_ex(path, 0 TSRMLS_CC)) { efree(path); POSIX_G(last_error) = EPERM; RETURN_FALSE; diff --combined ext/reflection/php_reflection.c index 28184e1,522fef1..1cf65ce --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@@ -39,16 -39,11 +39,16 @@@ #include "zend_ini.h" #include "zend_interfaces.h" #include "zend_closures.h" +#include "zend_extensions.h" -/* Undefine "getParameters" macro defined in "main/php3_compat.h" */ -#ifdef getParameters -# undef getParameters -#endif +#define reflection_update_property(object, name, value) do { \ + zval *member; \ + MAKE_STD_ZVAL(member); \ + ZVAL_STRINGL(member, name, sizeof(name)-1, 1); \ + zend_std_write_property(object, member, value, NULL TSRMLS_CC); \ + Z_DELREF_P(value); \ + zval_ptr_dtor(&member); \ + } while (0) /* Class entry pointers */ PHPAPI zend_class_entry *reflector_ptr; @@@ -62,7 -57,6 +62,7 @@@ PHPAPI zend_class_entry *reflection_obj PHPAPI zend_class_entry *reflection_method_ptr; PHPAPI zend_class_entry *reflection_property_ptr; PHPAPI zend_class_entry *reflection_extension_ptr; +PHPAPI zend_class_entry *reflection_zend_extension_ptr; #if MBO_0 ZEND_BEGIN_MODULE_GLOBALS(reflection) @@@ -125,7 -119,7 +125,7 @@@ static void string_init(string *str str->alloced = 1024; *str->string = '\0'; } - + static string *string_printf(string *str, const char *format, ...) { int len; @@@ -178,8 -172,6 +178,8 @@@ static void string_free(string *str } /* }}} */ +/* {{{ Object structure */ + /* Struct for properties */ typedef struct _property_reference { zend_class_entry *ce; @@@ -212,11 -204,9 +212,11 @@@ typedef struct unsigned int ignore_visibility:1; } reflection_object; +/* }}} */ + static zend_object_handlers reflection_object_handlers; -static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) +static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) /* {{{ */ { zval **value; @@@ -226,7 -216,6 +226,7 @@@ MAKE_COPY_ZVAL(value, return_value); } +/* }}} */ #ifdef ilia_0 static void _default_lookup_entry(zval *object, char *name, int name_len, zval **return_value TSRMLS_DC) /* {{{ */ @@@ -242,14 -231,13 +242,14 @@@ /* }}} */ #endif -static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) +static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) /* {{{ */ { zend_uint num_interfaces = ++class_entry->num_interfaces; class_entry->interfaces = (zend_class_entry **) realloc(class_entry->interfaces, sizeof(zend_class_entry *) * num_interfaces); class_entry->interfaces[num_interfaces - 1] = interface_entry; } +/* }}} */ static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */ { @@@ -275,13 -263,13 +275,13 @@@ static void _free_function(zend_functio && fptr->type == ZEND_INTERNAL_FUNCTION && (fptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) { - efree(fptr->internal_function.function_name); + efree((char*)fptr->internal_function.function_name); efree(fptr); } } /* }}} */ -static void reflection_free_objects_storage(void *object TSRMLS_DC) +static void reflection_free_objects_storage(void *object TSRMLS_DC) /* {{{ */ { reflection_object *intern = (reflection_object *) object; parameter_reference *reference; @@@ -302,7 -290,7 +302,7 @@@ break; case REF_TYPE_DYNAMIC_PROPERTY: prop_reference = (property_reference*)intern->ptr; - efree(prop_reference->prop.name); + efree((char*)prop_reference->prop.name); efree(intern->ptr); break; case REF_TYPE_OTHER: @@@ -315,10 -303,10 +315,10 @@@ } zend_objects_free_object_storage(object TSRMLS_CC); } +/* }}} */ -static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) +static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { - zval tmp; zend_object_value retval; reflection_object *intern; @@@ -326,14 -314,13 +326,14 @@@ intern->zo.ce = class_type; zend_object_std_init(&intern->zo, class_type TSRMLS_CC); - zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + object_properties_init(&intern->zo, class_type); retval.handle = zend_objects_store_put(intern, NULL, reflection_free_objects_storage, NULL TSRMLS_CC); retval.handlers = &reflection_object_handlers; return retval; } +/* }}} */ -static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) +static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) /* {{{ */ { if (!object) { ALLOC_ZVAL(object); @@@ -344,44 -331,36 +344,44 @@@ Z_SET_ISREF_P(object); return object; } +/* }}} */ static void _const_string(string *str, char *name, zval *value, char *indent TSRMLS_DC); -static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char *indent TSRMLS_DC); +static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char* indent TSRMLS_DC); static void _property_string(string *str, zend_property_info *prop, char *prop_name, char* indent TSRMLS_DC); static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *indent TSRMLS_DC); static void _extension_string(string *str, zend_module_entry *module, char *indent TSRMLS_DC); +static void _zend_extension_string(string *str, zend_extension *extension, char *indent TSRMLS_DC); /* {{{ _class_string */ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *indent TSRMLS_DC) { int count, count_static_props = 0, count_static_funcs = 0, count_shadow_props = 0; string sub_indent; - + string_init(&sub_indent); string_printf(&sub_indent, "%s ", indent); /* TBD: Repair indenting of doc comment (or is this to be done in the parser?) */ - if (ce->type == ZEND_USER_CLASS && ce->doc_comment) { - string_printf(str, "%s%s", indent, ce->doc_comment); + if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) { + string_printf(str, "%s%s", indent, ce->info.user.doc_comment); string_write(str, "\n", 1); } if (obj) { string_printf(str, "%sObject of class [ ", indent); } else { - string_printf(str, "%s%s [ ", indent, (ce->ce_flags & ZEND_ACC_INTERFACE) ? "Interface" : "Class"); + char *kind = "Class"; + if (ce->ce_flags & ZEND_ACC_INTERFACE) { + kind = "Interface"; + } else if ((ce->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { + kind = "Trait"; + } + string_printf(str, "%s%s [ ", indent, kind); } string_printf(str, (ce->type == ZEND_USER_CLASS) ? "<user" : "<internal"); - if (ce->module) { - string_printf(str, ":%s", ce->module->name); + if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module) { + string_printf(str, ":%s", ce->info.internal.module->name); } string_printf(str, "> "); if (ce->get_iterator != NULL) { @@@ -389,15 -368,13 +389,15 @@@ } if (ce->ce_flags & ZEND_ACC_INTERFACE) { string_printf(str, "interface "); + } else if ((ce->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { + string_printf(str, "trait "); } else { if (ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { string_printf(str, "abstract "); } if (ce->ce_flags & ZEND_ACC_FINAL_CLASS) { string_printf(str, "final "); - } + } string_printf(str, "class "); } string_printf(str, "%s", ce->name); @@@ -421,8 -398,8 +421,8 @@@ /* The information where a class is declared is only available for user classes */ if (ce->type == ZEND_USER_CLASS) { - string_printf(str, "%s @@ %s %d-%d\n", indent, ce->filename, - ce->line_start, ce->line_end); + string_printf(str, "%s @@ %s %d-%d\n", indent, ce->info.user.filename, + ce->info.user.line_start, ce->info.user.line_end); } /* Constants */ @@@ -452,7 -429,7 +452,7 @@@ /* Static properties */ if (&ce->properties_info) { - /* counting static properties */ + /* counting static properties */ count = zend_hash_num_elements(&ce->properties_info); if (count > 0) { HashPosition pos; @@@ -470,7 -447,7 +470,7 @@@ } } - /* static properties */ + /* static properties */ string_printf(str, "\n%s - Static properties [%d] {\n", indent, count_static_props); if (count_static_props > 0) { HashPosition pos; @@@ -488,10 -465,10 +488,10 @@@ } string_printf(str, "%s }\n", indent); } - + /* Static methods */ if (&ce->function_table) { - /* counting static methods */ + /* counting static methods */ count = zend_hash_num_elements(&ce->function_table); if (count > 0) { HashPosition pos; @@@ -509,7 -486,7 +509,7 @@@ } } - /* static methods */ + /* static methods */ string_printf(str, "\n%s - Static methods [%d] {", indent, count_static_funcs); if (count_static_funcs > 0) { HashPosition pos; @@@ -573,7 -550,7 +573,7 @@@ if (prop_name_size && prop_name[0]) { /* skip all private and protected properties */ if (!zend_hash_quick_exists(&ce->properties_info, prop_name, prop_name_size, zend_get_hash_value(prop_name, prop_name_size))) { count++; - _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC); + _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC); } } efree(prop_name); @@@ -644,7 -621,7 +644,7 @@@ } string_printf(str, "%s }\n", indent); } - + string_printf(str, "%s}\n", indent); string_free(&sub_indent); } @@@ -682,7 -659,7 +682,7 @@@ static zend_op* _get_recv_op(zend_op_ar ++offset; while (op < end) { if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT) - && op->op1.u.constant.value.lval == (long)offset) + && op->op1.num == (long)offset) { return op; } @@@ -706,8 -683,8 +706,8 @@@ static void _parameter_string(string *s if (arg_info->allow_null) { string_printf(str, "or NULL "); } - } else if (arg_info->array_type_hint) { - string_printf(str, "array "); + } else if (arg_info->type_hint) { + string_printf(str, "%s ", zend_get_type_by_const(arg_info->type_hint)); if (arg_info->allow_null) { string_printf(str, "or NULL "); } @@@ -722,12 -699,12 +722,12 @@@ } if (fptr->type == ZEND_USER_FUNCTION && offset >= required) { zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset); - if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2.op_type != IS_UNUSED) { + if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) { zval *zv, zv_copy; int use_copy; string_write(str, " = ", sizeof(" = ")-1); ALLOC_ZVAL(zv); - *zv = precv->op2.u.constant; + *zv = *precv->op2.zv; zval_copy_ctor(zv); INIT_PZVAL(zv); zval_update_constant_ex(&zv, (void*)1, fptr->common.scope TSRMLS_CC); @@@ -746,8 -723,6 +746,8 @@@ string_write(str, "...", sizeof("...")-1); } string_write(str, "'", sizeof("'")-1); + } else if (Z_TYPE_P(zv) == IS_ARRAY) { + string_write(str, "Array", sizeof("Array")-1); } else { zend_make_printable_zval(zv, &zv_copy, &use_copy); string_write(str, Z_STRVAL(zv_copy), Z_STRLEN(zv_copy)); @@@ -827,7 -802,7 +827,7 @@@ static void _function_string(string *st unsigned int lc_name_len; /* TBD: Repair indenting of doc comment (or is this to be done in the parser?) - * What's "wrong" is that any whitespace before the doc comment start is + * What's "wrong" is that any whitespace before the doc comment start is * swallowed, leading to an unaligned comment. */ if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) { @@@ -900,13 -875,13 +900,13 @@@ string_printf(str, "function "); } - if (fptr->op_array.return_reference) { + if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) { string_printf(str, "&"); } string_printf(str, "%s ] {\n", fptr->common.function_name); /* The information where a function is declared is only available for user classes */ if (fptr->type == ZEND_USER_FUNCTION) { - string_printf(str, "%s @@ %s %d - %d\n", indent, + string_printf(str, "%s @@ %s %d - %d\n", indent, fptr->op_array.filename, fptr->op_array.line_start, fptr->op_array.line_end); @@@ -925,7 -900,7 +925,7 @@@ /* {{{ _property_string */ static void _property_string(string *str, zend_property_info *prop, char *prop_name, char* indent TSRMLS_DC) { - char *class_name; + const char *class_name; string_printf(str, "%sProperty [ ", indent); if (!prop) { @@@ -938,7 -913,7 +938,7 @@@ string_write(str, "<default> ", sizeof("<default> ") - 1); } } - + /* These are mutually exclusive */ switch (prop->flags & ZEND_ACC_PPP_MASK) { case ZEND_ACC_PUBLIC: @@@ -955,7 -930,7 +955,7 @@@ string_printf(str, "static "); } - zend_unmangle_property_name(prop->name, prop->name_length, &class_name, &prop_name); + zend_unmangle_property_name(prop->name, prop->name_length, &class_name, (const char**)&prop_name); string_printf(str, "$%s", prop_name); } @@@ -963,7 -938,7 +963,7 @@@ } /* }}} */ -static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@@ -997,25 -972,23 +997,25 @@@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ -static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*); int *num_classes = va_arg(args, int*); - if ((*pce)->module && !strcasecmp((*pce)->module->name, module->name)) { + if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) { string_printf(str, "\n"); _class_string(str, *pce, NULL, indent TSRMLS_CC); (*num_classes)++; } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ -static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@@ -1028,7 -1001,6 +1028,7 @@@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ /* {{{ _extension_string */ static void _extension_string(string *str, zend_module_entry *module, char *indent TSRMLS_DC) @@@ -1051,7 -1023,7 +1051,7 @@@ while(dep->name) { string_printf(str, "%s Dependency [ %s (", indent, dep->name); - + switch(dep->type) { case MODULE_DEP_REQUIRED: string_write(str, "Required", sizeof("Required") - 1); @@@ -1067,10 -1039,10 +1067,10 @@@ break; } - if (dep->rel) { + if (dep->rel) { string_printf(str, " %s", dep->rel); } - if (dep->version) { + if (dep->version) { string_printf(str, " %s", dep->version); } string_write(str, ") ]\n", sizeof(") ]\n") - 1); @@@ -1094,7 -1066,7 +1094,7 @@@ { string str_constants; int num_constants = 0; - + string_init(&str_constants); zend_hash_apply_with_arguments(EG(zend_constants) TSRMLS_CC, (apply_func_args_t) _extension_const_string, 4, &str_constants, indent, module, &num_constants); if (num_constants) { @@@ -1115,26 -1087,26 +1115,26 @@@ while (func->fname) { int fname_len = strlen(func->fname); char *lc_name = zend_str_tolower_dup(func->fname, fname_len); - - if (zend_hash_find(EG(function_table), lc_name, fname_len+1, (void**) &fptr) == FAILURE) { + + if (zend_hash_find(EG(function_table), lc_name, fname_len + 1, (void**) &fptr) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal error: Cannot find extension function %s in global function table", func->fname); func++; efree(lc_name); continue; } - + _function_string(str, fptr, NULL, " " TSRMLS_CC); efree(lc_name); func++; } string_printf(str, "%s }\n", indent); } - + { string str_classes; string sub_indent; int num_classes = 0; - + string_init(&sub_indent); string_printf(&sub_indent, "%s ", indent); string_init(&str_classes); @@@ -1152,27 -1124,6 +1152,27 @@@ } /* }}} */ +static void _zend_extension_string(string *str, zend_extension *extension, char *indent TSRMLS_DC) /* {{{ */ +{ + string_printf(str, "%sZend Extension [ %s ", indent, extension->name); + + if (extension->version) { + string_printf(str, "%s ", extension->version); + } + if (extension->copyright) { + string_printf(str, "%s ", extension->copyright); + } + if (extension->author) { + string_printf(str, "by %s ", extension->author); + } + if (extension->URL) { + string_printf(str, "<%s> ", extension->URL); + } + + string_printf(str, "]\n"); +} +/* }}} */ + /* {{{ _function_check_flag */ static void _function_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) { @@@ -1200,7 -1151,7 +1200,7 @@@ PHPAPI void zend_reflection_class_facto intern->ptr = ce; intern->ref_type = REF_TYPE_OTHER; intern->ce = ce; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); } /* }}} */ @@@ -1229,7 -1180,7 +1229,7 @@@ static void reflection_extension_factor intern->ptr = module; intern->ref_type = REF_TYPE_OTHER; intern->ce = NULL; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); } /* }}} */ @@@ -1260,7 -1211,7 +1260,7 @@@ static void reflection_parameter_factor intern->ref_type = REF_TYPE_PARAMETER; intern->ce = fptr->common.scope; intern->obj = closure_object; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); } /* }}} */ @@@ -1282,7 -1233,7 +1282,7 @@@ static void reflection_function_factory intern->ref_type = REF_TYPE_FUNCTION; intern->ce = NULL; intern->obj = closure_object; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); } /* }}} */ @@@ -1306,8 -1257,8 +1306,8 @@@ static void reflection_method_factory(z intern->ref_type = REF_TYPE_FUNCTION; intern->ce = ce; intern->obj = closure_object; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); - zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); + reflection_update_property(object, "class", classname); } /* }}} */ @@@ -1318,7 -1269,7 +1318,7 @@@ static void reflection_property_factory zval *name; zval *classname; property_reference *reference; - char *class_name, *prop_name; + const char *class_name, *prop_name; zend_unmangle_property_name(prop->name, prop->name_length, &class_name, &prop_name); @@@ -1353,8 -1304,8 +1353,8 @@@ intern->ref_type = REF_TYPE_PROPERTY; intern->ce = ce; intern->ignore_visibility = 0; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); - zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); + reflection_update_property(object, "class", classname); } /* }}} */ @@@ -1410,7 -1361,7 +1410,7 @@@ static void _reflection_export(INTERNAL fcc.object_ptr = reflector_ptr; result = zend_call_function(&fci, &fcc TSRMLS_CC); - + if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } @@@ -1585,10 -1536,10 +1585,10 @@@ ZEND_METHOD(reflection_function, __cons nsname = &lcname[1]; name_len--; } - + if (zend_hash_find(EG(function_table), nsname, name_len + 1, (void **)&fptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Function %s() does not exist", name_str); return; } @@@ -1599,7 -1550,7 +1599,7 @@@ MAKE_STD_ZVAL(name); ZVAL_STRING(name, fptr->common.function_name, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); intern->ptr = fptr; intern->ref_type = REF_TYPE_FUNCTION; intern->obj = closure; @@@ -1651,65 -1602,6 +1651,65 @@@ ZEND_METHOD(reflection_function, isClos } /* }}} */ +/* {{{ proto public bool ReflectionFunction::getClosureThis() + Returns this pointer bound to closure */ +ZEND_METHOD(reflection_function, getClosureThis) +{ + reflection_object *intern; + zend_function *fptr; + zval* closure_this; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(fptr); + if (intern->obj) { + closure_this = zend_get_closure_this_ptr(intern->obj TSRMLS_CC); + if (closure_this) { + RETURN_ZVAL(closure_this, 1, 0); + } + } +} +/* }}} */ + +/* {{{ proto public ReflectionClass ReflectionFunction::getClosureScopeClass() + Returns the scope associated to the closure */ +ZEND_METHOD(reflection_function, getClosureScopeClass) +{ + reflection_object *intern; + zend_function *fptr; + const zend_function *closure_func; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(fptr); + if (intern->obj) { + closure_func = zend_get_closure_method_def(intern->obj TSRMLS_CC); + if (closure_func && closure_func->common.scope) { + zend_reflection_class_factory(closure_func->common.scope, return_value TSRMLS_CC); + } + } +} +/* }}} */ + +/* {{{ proto public mixed ReflectionFunction::getClosure() + Returns a dynamically created closure for the function */ +ZEND_METHOD(reflection_function, getClosure) +{ + reflection_object *intern; + zend_function *fptr; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(fptr); + + zend_create_closure(return_value, fptr, NULL, NULL TSRMLS_CC); +} +/* }}} */ + + /* {{{ proto public bool ReflectionFunction::isInternal() Returns whether this is an internal function */ ZEND_METHOD(reflection_function, isInternal) @@@ -1832,7 -1724,7 +1832,7 @@@ ZEND_METHOD(reflection_function, getSta zval *tmp_copy; reflection_object *intern; zend_function *fptr; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -1858,7 -1750,7 +1858,7 @@@ ZEND_METHOD(reflection_function, invoke zend_fcall_info_cache fcc; reflection_object *intern; zend_function *fptr; - + METHOD_NOTSTATIC(reflection_function_ptr); GET_REFLECTION_OBJECT_PTR(fptr); @@@ -1889,7 -1781,7 +1889,7 @@@ } if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of function %s() failed", fptr->common.function_name); return; } @@@ -1919,7 -1811,7 +1919,7 @@@ ZEND_METHOD(reflection_function, invoke reflection_object *intern; zend_function *fptr; zval *param_array; - + METHOD_NOTSTATIC(reflection_function_ptr); GET_REFLECTION_OBJECT_PTR(fptr); @@@ -1928,9 -1820,9 +1928,9 @@@ } argc = zend_hash_num_elements(Z_ARRVAL_P(param_array)); - + params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); params -= argc; fci.size = sizeof(fci); @@@ -1954,7 -1846,7 +1954,7 @@@ efree(params); if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of function %s() failed", fptr->common.function_name); return; } @@@ -1975,7 -1867,7 +1975,7 @@@ ZEND_METHOD(reflection_function, return METHOD_NOTSTATIC(reflection_function_abstract_ptr); GET_REFLECTION_OBJECT_PTR(fptr); - RETURN_BOOL(fptr->op_array.return_reference); + RETURN_BOOL((fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0); } /* }}} */ @@@ -2023,7 -1915,7 +2023,7 @@@ ZEND_METHOD(reflection_function, getPar array_init(return_value); for (i = 0; i < fptr->common.num_args; i++) { - zval *parameter; + zval *parameter; ALLOC_ZVAL(parameter); reflection_parameter_factory(_copy_function(fptr TSRMLS_CC), intern->obj, arg_info, i, fptr->common.required_num_args, parameter TSRMLS_CC); @@@ -2114,7 -2006,7 +2114,7 @@@ ZEND_METHOD(reflection_parameter, __con if (intern == NULL) { return; } - + /* First, find the function */ switch (Z_TYPE_P(reference)) { case IS_STRING: { @@@ -2125,7 -2017,7 +2125,7 @@@ lcname = zend_str_tolower_dup(Z_STRVAL_P(reference), lcname_len); if (zend_hash_find(EG(function_table), lcname, lcname_len + 1, (void**) &fptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Function %s() does not exist", Z_STRVAL_P(reference)); return; } @@@ -2140,7 -2032,7 +2140,7 @@@ zend_class_entry **pce; unsigned int lcname_len; char *lcname; - + if ((zend_hash_index_find(Z_ARRVAL_P(reference), 0, (void **) &classref) == FAILURE) || (zend_hash_index_find(Z_ARRVAL_P(reference), 1, (void **) &method) == FAILURE)) { @@@ -2159,7 -2051,7 +2159,7 @@@ } ce = *pce; } - + convert_to_string_ex(method); lcname_len = Z_STRLEN_PP(method); lcname = zend_str_tolower_dup(Z_STRVAL_PP(method), lcname_len); @@@ -2168,21 -2060,21 +2168,21 @@@ && memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 && (fptr = zend_get_closure_invoke_method(*classref TSRMLS_CC)) != NULL) { - /* nothign to do. don't set is_closure since is the invoke handler, - not the closure itself */ + /* nothing to do. don't set is_closure since is the invoke handler, +- not the closure itself */ } else if (zend_hash_find(&ce->function_table, lcname, lcname_len + 1, (void **) &fptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s::%s() does not exist", ce->name, Z_STRVAL_PP(method)); return; } efree(lcname); } break; - + case IS_OBJECT: { ce = Z_OBJCE_P(reference); - + if (instanceof_function(ce, zend_ce_closure TSRMLS_CC)) { fptr = (zend_function *)zend_get_closure_method_def(reference TSRMLS_CC); Z_ADDREF_P(reference); @@@ -2194,12 -2086,12 +2194,12 @@@ } } break; - + default: _DO_THROW("The parameter class is expected to be either a string, an array(class, method) or a callable object"); /* returns out of this function */ } - + /* Now, search for the parameter */ arg_info = fptr->common.arg_info; if (Z_TYPE_PP(parameter) == IS_LONG) { @@@ -2207,7 -2099,7 +2207,7 @@@ if (position < 0 || (zend_uint)position >= fptr->common.num_args) { if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) { if (fptr->type != ZEND_OVERLOADED_FUNCTION) { - efree(fptr->common.function_name); + efree((char*)fptr->common.function_name); } efree(fptr); } @@@ -2231,7 -2123,7 +2231,7 @@@ if (position == -1) { if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) { if (fptr->type != ZEND_OVERLOADED_FUNCTION) { - efree(fptr->common.function_name); + efree((char*)fptr->common.function_name); } efree(fptr); } @@@ -2242,14 -2134,14 +2242,14 @@@ /* returns out of this function */ } } - + MAKE_STD_ZVAL(name); if (arg_info[position].name) { ZVAL_STRINGL(name, arg_info[position].name, arg_info[position].name_len, 1); } else { ZVAL_NULL(name); } - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); ref = (parameter_reference*) emalloc(sizeof(parameter_reference)); ref->arg_info = &arg_info[position]; @@@ -2329,7 -2221,7 +2329,7 @@@ ZEND_METHOD(reflection_parameter, getDe if (param->fptr->common.scope) { zend_reflection_class_factory(param->fptr->common.scope, return_value TSRMLS_CC); - } + } } /* }}} */ @@@ -2359,29 -2251,29 +2359,29 @@@ ZEND_METHOD(reflection_parameter, getCl * TODO: Think about moving these checks to the compiler or some sort of * lint-mode. */ - if (0 == strncmp(param->arg_info->class_name, "self", sizeof("self")- 1)) { + if (0 == zend_binary_strcasecmp(param->arg_info->class_name, param->arg_info->class_name_len, "self", sizeof("self")- 1)) { ce = param->fptr->common.scope; if (!ce) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter uses 'self' as type hint but function is not a class member!"); return; } pce= &ce; - } else if (0 == strncmp(param->arg_info->class_name, "parent", sizeof("parent")- 1)) { + } else if (0 == zend_binary_strcasecmp(param->arg_info->class_name, param->arg_info->class_name_len, "parent", sizeof("parent")- 1)) { ce = param->fptr->common.scope; if (!ce) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter uses 'parent' as type hint but function is not a class member!"); return; } if (!ce->parent) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter uses 'parent' as type hint although class does not have a parent!"); return; } pce= &ce->parent; } else if (zend_lookup_class(param->arg_info->class_name, param->arg_info->class_name_len, &pce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not exist", param->arg_info->class_name); return; } @@@ -2402,23 -2294,7 +2402,23 @@@ ZEND_METHOD(reflection_parameter, isArr } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(param->arg_info->array_type_hint); + RETVAL_BOOL(param->arg_info->type_hint == IS_ARRAY); +} +/* }}} */ + +/* {{{ proto public bool ReflectionParameter::isCallable() + Returns whether parameter MUST be callable */ +ZEND_METHOD(reflection_parameter, isCallable) +{ + reflection_object *intern; + parameter_reference *param; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(param); + + RETVAL_BOOL(param->arg_info->type_hint == IS_CALLABLE); } /* }}} */ @@@ -2454,23 -2330,6 +2454,23 @@@ ZEND_METHOD(reflection_parameter, isPas } /* }}} */ +/* {{{ proto public bool ReflectionParameter::canBePassedByValue() + Returns whether this parameter can be passed by value */ +ZEND_METHOD(reflection_parameter, canBePassedByValue) +{ + reflection_object *intern; + parameter_reference *param; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(param); + + /* true if it's ZEND_SEND_BY_VAL or ZEND_SEND_PREFER_REF */ + RETVAL_BOOL(param->arg_info->pass_by_reference != ZEND_SEND_BY_REF); +} +/* }}} */ + /* {{{ proto public bool ReflectionParameter::getPosition() Returns whether this parameter is an optional parameter */ ZEND_METHOD(reflection_parameter, getPosition) @@@ -2524,7 -2383,7 +2524,7 @@@ ZEND_METHOD(reflection_parameter, isDef RETURN_FALSE; } precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); - if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) { + if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { RETURN_FALSE; } RETURN_TRUE; @@@ -2550,16 -2409,16 +2550,16 @@@ ZEND_METHOD(reflection_parameter, getDe return; } if (param->offset < param->required) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); return; } precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); - if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); + if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); return; } - *return_value = precv->op2.u.constant; + *return_value = *precv->op2.zv; INIT_PZVAL(return_value); if (Z_TYPE_P(return_value) != IS_CONSTANT && Z_TYPE_P(return_value) != IS_CONSTANT_ARRAY) { zval_copy_ctor(return_value); @@@ -2596,7 -2455,7 +2596,7 @@@ ZEND_METHOD(reflection_method, __constr return; } if ((tmp = strstr(name_str, "::")) == NULL) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invalid method name %s", name_str); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invalid method name %s", name_str); return; } classname = &ztmp; @@@ -2616,13 -2475,13 +2616,13 @@@ if (intern == NULL) { return; } - + /* Find the class entry */ switch (Z_TYPE_P(classname)) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Class %s does not exist", Z_STRVAL_P(classname)); + "Class %s does not exist", Z_STRVAL_P(classname)); if (classname == &ztmp) { zval_dtor(&ztmp); } @@@ -2656,7 -2515,7 +2656,7 @@@ /* do nothing, mptr already set */ } else if (zend_hash_find(&ce->function_table, lcname, name_len + 1, (void **) &mptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s::%s() does not exist", ce->name, name_str); return; } @@@ -2665,11 -2524,11 +2665,11 @@@ MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, mptr->common.scope->name, mptr->common.scope->name_length, 1); - zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); - + reflection_update_property(object, "class", classname); + MAKE_STD_ZVAL(name); ZVAL_STRING(name, mptr->common.function_name, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); intern->ptr = mptr; intern->ref_type = REF_TYPE_FUNCTION; intern->ce = ce; @@@ -2694,41 -2553,6 +2694,41 @@@ ZEND_METHOD(reflection_method, __toStri } /* }}} */ +/* {{{ proto public mixed ReflectionMethod::getClosure([mixed object]) + Invokes the function */ +ZEND_METHOD(reflection_method, getClosure) +{ + reflection_object *intern; + zval *obj; + zend_function *mptr; + + METHOD_NOTSTATIC(reflection_method_ptr); + GET_REFLECTION_OBJECT_PTR(mptr); + + if (mptr->common.fn_flags & ZEND_ACC_STATIC) { + zend_create_closure(return_value, mptr, mptr->common.scope, NULL TSRMLS_CC); + } else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) { + return; + } + + if (!instanceof_function(Z_OBJCE_P(obj), mptr->common.scope TSRMLS_CC)) { + _DO_THROW("Given object is not an instance of the class this method was declared in"); + /* Returns from this function */ + } + + /* This is an original closure object and __invoke is to be called. */ + if (Z_OBJCE_P(obj) == zend_ce_closure && mptr->type == ZEND_INTERNAL_FUNCTION && + (mptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) + { + RETURN_ZVAL(obj, 1, 0); + } else { + zend_create_closure(return_value, mptr, mptr->common.scope, obj TSRMLS_CC); + } + } +} +/* }}} */ + /* {{{ proto public mixed ReflectionMethod::invoke(mixed object, mixed* args) Invokes the method. */ ZEND_METHOD(reflection_method, invoke) @@@ -2742,7 -2566,7 +2742,7 @@@ zend_fcall_info fci; zend_fcall_info_cache fcc; zend_class_entry *obj_ce; - + METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); @@@ -2752,12 -2576,12 +2752,12 @@@ && intern->ignore_visibility == 0) { if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke abstract method %s::%s()", + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Trying to invoke abstract method %s::%s()", mptr->common.scope->name, mptr->common.function_name); } else { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke %s method %s::%s() from scope %s", + "Trying to invoke %s method %s::%s() from scope %s", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", mptr->common.scope->name, mptr->common.function_name, Z_OBJCE_P(getThis())->name); @@@ -2768,7 -2592,7 +2768,7 @@@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", ¶ms, &num_args) == FAILURE) { return; } - + /* In case this is a static method, we should'nt pass an object_ptr * (which is used as calling context aka $this). We can thus ignore the * first parameter. @@@ -2794,10 -2618,10 +2794,10 @@@ _DO_THROW("Given object is not an instance of the class this method was declared in"); /* Returns from this function */ } - + object_ptr = *params[0]; } - + fci.size = sizeof(fci); fci.function_table = NULL; fci.function_name = NULL; @@@ -2815,13 -2639,13 +2815,13 @@@ fcc.object_ptr = object_ptr; result = zend_call_function(&fci, &fcc TSRMLS_CC); - + if (params) { efree(params); } if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name); return; } @@@ -2847,7 -2671,7 +2847,7 @@@ ZEND_METHOD(reflection_method, invokeAr zend_fcall_info_cache fcc; zend_class_entry *obj_ce; zval *param_array; - + METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); @@@ -2861,12 -2685,12 +2861,12 @@@ && intern->ignore_visibility == 0) { if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke abstract method %s::%s()", + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Trying to invoke abstract method %s::%s()", mptr->common.scope->name, mptr->common.function_name); } else { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke %s method %s::%s() from scope %s", + "Trying to invoke %s method %s::%s() from scope %s", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", mptr->common.scope->name, mptr->common.function_name, Z_OBJCE_P(getThis())->name); @@@ -2875,11 -2699,11 +2875,11 @@@ } argc = zend_hash_num_elements(Z_ARRVAL_P(param_array)); - + params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); params -= argc; - + /* In case this is a static method, we should'nt pass an object_ptr * (which is used as calling context aka $this). We can thus ignore the * first parameter. @@@ -2893,11 -2717,11 +2893,11 @@@ if (!object) { efree(params); zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke non static method %s::%s() without an object", + "Trying to invoke non static method %s::%s() without an object", mptr->common.scope->name, mptr->common.function_name); return; } - + obj_ce = Z_OBJCE_P(object); if (!instanceof_function(obj_ce, mptr->common.scope TSRMLS_CC)) { @@@ -2906,7 -2730,7 +2906,7 @@@ /* Returns from this function */ } } - + fci.size = sizeof(fci); fci.function_table = NULL; fci.function_name = NULL; @@@ -2924,11 -2748,11 +2924,11 @@@ fcc.object_ptr = object; result = zend_call_function(&fci, &fcc TSRMLS_CC); - + efree(params); if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name); return; } @@@ -3000,7 -2824,7 +3000,7 @@@ ZEND_METHOD(reflection_function, isDepr ZEND_METHOD(reflection_function, inNamespace) { zval **name; - char *colon; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -3009,8 -2833,8 +3009,8 @@@ RETURN_FALSE; } if (Z_TYPE_PP(name) == IS_STRING - && (colon = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) - && colon > Z_STRVAL_PP(name)) + && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) + && backslash > Z_STRVAL_PP(name)) { RETURN_TRUE; } @@@ -3023,7 -2847,7 +3023,7 @@@ ZEND_METHOD(reflection_function, getNamespaceName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -3046,7 -2870,7 +3046,7 @@@ ZEND_METHOD(reflection_function, getShortName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -3075,7 -2899,7 +3075,7 @@@ ZEND_METHOD(reflection_method, isConstr return; } GET_REFLECTION_OBJECT_PTR(mptr); - /* we need to check if the ctor is the ctor of the class level we we + /* we need to check if the ctor is the ctor of the class level we we * looking at since we might be looking at an inherited old style ctor * defined in base class. */ RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_CTOR && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope); @@@ -3122,7 -2946,7 +3122,7 @@@ ZEND_METHOD(reflection_method, getDecla METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -3140,13 -2964,13 +3140,13 @@@ ZEND_METHOD(reflection_method, getProto METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); - + if (zend_parse_parameters_none() == FAILURE) { return; } - + if (!mptr->common.prototype) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s::%s does not have a prototype", intern->ce->name, mptr->common.function_name); return; } @@@ -3208,17 -3032,17 +3208,17 @@@ static void reflection_class_object_cto if (intern == NULL) { return; } - + if (Z_TYPE_P(argument) == IS_OBJECT) { MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, Z_OBJCE_P(argument)->name, Z_OBJCE_P(argument)->name_length, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &classname, sizeof(zval *), NULL); + reflection_update_property(object, "name", classname); intern->ptr = Z_OBJCE_P(argument); if (is_object) { intern->obj = argument; zval_add_ref(&argument); } - } else { + } else { convert_to_string_ex(&argument); if (zend_lookup_class(Z_STRVAL_P(argument), Z_STRLEN_P(argument), &ce TSRMLS_CC) == FAILURE) { if (!EG(exception)) { @@@ -3229,7 -3053,7 +3229,7 @@@ MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, (*ce)->name, (*ce)->name_length, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &classname, sizeof(zval *), NULL); + reflection_update_property(object, "name", classname); intern->ptr = *ce; } @@@ -3245,74 -3069,49 +3245,74 @@@ ZEND_METHOD(reflection_class, __constru } /* }}} */ +/* {{{ add_class_vars */ +static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value TSRMLS_DC) +{ + HashPosition pos; + zend_property_info *prop_info; + zval *prop, *prop_copy; + char *key; + uint key_len; + ulong num_index; + + zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos); + while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop_info, &pos) == SUCCESS) { + zend_hash_get_current_key_ex(&ce->properties_info, &key, &key_len, &num_index, 0, &pos); + zend_hash_move_forward_ex(&ce->properties_info, &pos); + if (((prop_info->flags & ZEND_ACC_SHADOW) && + prop_info->ce != ce) || + ((prop_info->flags & ZEND_ACC_PROTECTED) && + !zend_check_protected(prop_info->ce, ce)) || + ((prop_info->flags & ZEND_ACC_PRIVATE) && + prop_info->ce != ce)) { + continue; + } + prop = NULL; + if (prop_info->offset >= 0) { + if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { + prop = ce->default_static_members_table[prop_info->offset]; + } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { + prop = ce->default_properties_table[prop_info->offset]; + } + } + if (!prop) { + 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, (void *) 1 TSRMLS_CC); + } + + add_assoc_zval(return_value, key, prop_copy); + } +} +/* }}} */ + /* {{{ proto public array ReflectionClass::getStaticProperties() Returns an associative array containing all static property values of the class */ ZEND_METHOD(reflection_class, getStaticProperties) { reflection_object *intern; zend_class_entry *ce; - HashPosition pos; - zval **value; if (zend_parse_parameters_none() == FAILURE) { return; } - + GET_REFLECTION_OBJECT_PTR(ce); zend_update_class_constants(ce TSRMLS_CC); array_init(return_value); - - zend_hash_internal_pointer_reset_ex(CE_STATIC_MEMBERS(ce), &pos); - - while (zend_hash_get_current_data_ex(CE_STATIC_MEMBERS(ce), (void **) &value, &pos) == SUCCESS) { - uint key_len; - char *key; - ulong num_index; - - if (zend_hash_get_current_key_ex(CE_STATIC_MEMBERS(ce), &key, &key_len, &num_index, 0, &pos) != FAILURE && key) { - char *prop_name, *class_name; - zval *prop_copy; - - zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name); - - /* filter privates from base classes */ - if (!(class_name && class_name[0] != '*' && strcmp(class_name, ce->name))) { - /* copy: enforce read only access */ - ALLOC_ZVAL(prop_copy); - MAKE_COPY_ZVAL(value, prop_copy); - - add_assoc_zval(return_value, prop_name, prop_copy); - } - } - zend_hash_move_forward_ex(CE_STATIC_MEMBERS(ce), &pos); - } + add_class_vars(ce, 1, return_value TSRMLS_CC); } /* }}} */ @@@ -3325,7 -3124,7 +3325,7 @@@ ZEND_METHOD(reflection_class, getStatic char *name; int name_len; zval **prop, *def_value = NULL; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &name, &name_len, &def_value) == FAILURE) { return; } @@@ -3333,12 -3132,12 +3333,12 @@@ GET_REFLECTION_OBJECT_PTR(ce); zend_update_class_constants(ce TSRMLS_CC); - prop = zend_std_get_static_property(ce, name, name_len, 1 TSRMLS_CC); + prop = zend_std_get_static_property(ce, name, name_len, 1, NULL TSRMLS_CC); if (!prop) { if (def_value) { RETURN_ZVAL(def_value, 1, 0); } else { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a property named %s", ce->name, name); } return; @@@ -3359,7 -3158,7 +3359,7 @@@ ZEND_METHOD(reflection_class, setStatic zval **variable_ptr, *value; int refcount; zend_uchar is_ref; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &value) == FAILURE) { return; } @@@ -3367,12 -3166,12 +3367,12 @@@ GET_REFLECTION_OBJECT_PTR(ce); zend_update_class_constants(ce TSRMLS_CC); - variable_ptr = zend_std_get_static_property(ce, name, name_len, 1 TSRMLS_CC); + variable_ptr = zend_std_get_static_property(ce, name, name_len, 1, NULL TSRMLS_CC); if (!variable_ptr) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a property named %s", ce->name, name); return; - } + } refcount = Z_REFCOUNT_PP(variable_ptr); is_ref = Z_ISREF_PP(variable_ptr); zval_dtor(*variable_ptr); @@@ -3390,15 -3189,51 +3390,15 @@@ ZEND_METHOD(reflection_class, getDefaul { reflection_object *intern; zend_class_entry *ce; - int count, i; - HashTable *ht_list[3]; - + if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ce); array_init(return_value); - zend_update_class_constants(ce TSRMLS_CC); - - ht_list[0] = CE_STATIC_MEMBERS(ce); - ht_list[1] = &ce->default_properties; - ht_list[2] = NULL; - - for (i = 0; ht_list[i] != NULL; i++) { - - count = zend_hash_num_elements(ht_list[i]); - if (count > 0) { - HashPosition pos; - zval **prop; - - zend_hash_internal_pointer_reset_ex(ht_list[i], &pos); - while (zend_hash_get_current_data_ex(ht_list[i], (void **) &prop, &pos) == SUCCESS) { - char *key, *class_name, *prop_name; - uint key_len; - ulong num_index; - zval *prop_copy; - - zend_hash_get_current_key_ex(ht_list[i], &key, &key_len, &num_index, 0, &pos); - zend_hash_move_forward_ex(ht_list[i], &pos); - zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name); - if (class_name && class_name[0] != '*' && strcmp(class_name, ce->name)) { - /* filter privates from base classes */ - continue; - } - - /* copy: enforce read only access */ - ALLOC_ZVAL(prop_copy); - MAKE_COPY_ZVAL(prop, prop_copy); - - add_assoc_zval(return_value, prop_name, prop_copy); - } - } - } + add_class_vars(ce, 1, return_value TSRMLS_CC); + add_class_vars(ce, 0, return_value TSRMLS_CC); } /* }}} */ @@@ -3473,7 -3308,7 +3473,7 @@@ ZEND_METHOD(reflection_class, getFileNa } GET_REFLECTION_OBJECT_PTR(ce); if (ce->type == ZEND_USER_CLASS) { - RETURN_STRING(ce->filename, 1); + RETURN_STRING(ce->info.user.filename, 1); } RETURN_FALSE; } @@@ -3491,7 -3326,7 +3491,7 @@@ ZEND_METHOD(reflection_class, getStartL } GET_REFLECTION_OBJECT_PTR(ce); if (ce->type == ZEND_USER_FUNCTION) { - RETURN_LONG(ce->line_start); + RETURN_LONG(ce->info.user.line_start); } RETURN_FALSE; } @@@ -3509,7 -3344,7 +3509,7 @@@ ZEND_METHOD(reflection_class, getEndLin } GET_REFLECTION_OBJECT_PTR(ce); if (ce->type == ZEND_USER_CLASS) { - RETURN_LONG(ce->line_end); + RETURN_LONG(ce->info.user.line_end); } RETURN_FALSE; } @@@ -3526,8 -3361,8 +3526,8 @@@ ZEND_METHOD(reflection_class, getDocCom return; } GET_REFLECTION_OBJECT_PTR(ce); - if (ce->type == ZEND_USER_CLASS && ce->doc_comment) { - RETURN_STRINGL(ce->doc_comment, ce->doc_comment_len, 1); + if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) { + RETURN_STRINGL(ce->info.user.doc_comment, ce->info.user.doc_comment_len, 1); } RETURN_FALSE; } @@@ -3559,7 -3394,7 +3559,7 @@@ ZEND_METHOD(reflection_class, hasMethod { reflection_object *intern; zend_class_entry *ce; - char *name, *lc_name; + char *name, *lc_name; int name_len; METHOD_NOTSTATIC(reflection_class_ptr); @@@ -3589,7 -3424,7 +3589,7 @@@ ZEND_METHOD(reflection_class, getMethod zend_class_entry *ce; zend_function *mptr; zval obj_tmp; - char *name, *lc_name; + char *name, *lc_name; int name_len; METHOD_NOTSTATIC(reflection_class_ptr); @@@ -3620,7 -3455,7 +3620,7 @@@ efree(lc_name); } else { efree(lc_name); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s does not exist", name); return; } @@@ -3658,7 -3493,7 +3658,7 @@@ static int _addmethod_va(zend_function zval *retval = va_arg(args, zval*); long filter = va_arg(args, long); zval *obj = va_arg(args, zval *); - + _addmethod(mptr, ce, retval, filter, obj TSRMLS_CC); return ZEND_HASH_APPLY_KEEP; } @@@ -3704,7 -3539,7 +3704,7 @@@ ZEND_METHOD(reflection_class, hasProper reflection_object *intern; zend_property_info *property_info; zend_class_entry *ce; - char *name; + char *name; int name_len; zval *property; @@@ -3723,7 -3558,7 +3723,7 @@@ if (intern->obj && Z_OBJ_HANDLER_P(intern->obj, has_property)) { MAKE_STD_ZVAL(property); ZVAL_STRINGL(property, name, name_len, 1); - if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 2 TSRMLS_CC)) { + if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 2, 0 TSRMLS_CC)) { zval_ptr_dtor(&property); RETURN_TRUE; } @@@ -3741,7 -3576,7 +3741,7 @@@ ZEND_METHOD(reflection_class, getProper reflection_object *intern; zend_class_entry *ce, **pce; zend_property_info *property_info; - char *name, *tmp, *classname; + char *name, *tmp, *classname; int name_len, classname_len; METHOD_NOTSTATIC(reflection_class_ptr); @@@ -3797,9 -3632,9 +3797,9 @@@ if (zend_hash_find(&ce->properties_info, name, name_len + 1, (void**) &property_info) == SUCCESS && (property_info->flags & ZEND_ACC_SHADOW) == 0) { reflection_property_factory(ce, property_info, return_value TSRMLS_CC); return; - } + } } - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Property %s does not exist", name); } /* }}} */ @@@ -3815,7 -3650,7 +3815,7 @@@ static int _addproperty(zend_property_i if (pptr->flags & ZEND_ACC_SHADOW) { return 0; } - + if (pptr->flags & filter) { ALLOC_ZVAL(property); reflection_property_factory(ce, pptr, property TSRMLS_CC); @@@ -3933,7 -3768,7 +3933,7 @@@ ZEND_METHOD(reflection_class, getConsta reflection_object *intern; zend_class_entry *ce; zval **value; - char *name; + char *name; int name_len; METHOD_NOTSTATIC(reflection_class_ptr); @@@ -3989,39 -3824,6 +3989,39 @@@ ZEND_METHOD(reflection_class, isInstant } /* }}} */ +/* {{{ proto public bool ReflectionClass::isCloneable() + Returns whether this class is cloneable */ +ZEND_METHOD(reflection_class, isCloneable) +{ + reflection_object *intern; + zend_class_entry *ce; + zval obj; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) { + RETURN_FALSE; + } + if (intern->obj) { + if (ce->clone) { + RETURN_BOOL(ce->clone->common.fn_flags & ZEND_ACC_PUBLIC); + } else { + RETURN_BOOL(Z_OBJ_HANDLER_P(intern->obj, clone_obj) != NULL); + } + } else { + if (ce->clone) { + RETURN_BOOL(ce->clone->common.fn_flags & ZEND_ACC_PUBLIC); + } else { + object_init_ex(&obj, ce); + RETVAL_BOOL(Z_OBJ_HANDLER(obj, clone_obj) != NULL); + zval_dtor(&obj); + } + } +} +/* }}} */ + /* {{{ proto public bool ReflectionClass::isInterface() Returns whether this is an interface or a class */ ZEND_METHOD(reflection_class, isInterface) @@@ -4030,14 -3832,6 +4030,14 @@@ } /* }}} */ +/* {{{ proto public bool ReflectionClass::isTrait() + Returns whether this is a trait */ +ZEND_METHOD(reflection_class, isTrait) +{ + _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT & ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); +} +/* }}} */ + /* {{{ proto public bool ReflectionClass::isFinal() Returns whether this class is final */ ZEND_METHOD(reflection_class, isFinal) @@@ -4082,7 -3876,7 +4082,7 @@@ ZEND_METHOD(reflection_class, isInstanc if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) { return; } - GET_REFLECTION_OBJECT_PTR(ce); + GET_REFLECTION_OBJECT_PTR(ce); RETURN_BOOL(HAS_CLASS_ENTRY(*object) && instanceof_function(Z_OBJCE_P(object), ce TSRMLS_CC)); } /* }}} */ @@@ -4094,7 -3888,7 +4094,7 @@@ ZEND_METHOD(reflection_class, newInstan zval *retval_ptr = NULL; reflection_object *intern; zend_class_entry *ce; - + METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); @@@ -4159,24 -3953,6 +4159,24 @@@ } /* }}} */ +/* {{{ proto public stdclass ReflectionClass::newInstanceWithoutConstructor() + Returns an instance of this class without invoking its constructor */ +ZEND_METHOD(reflection_class, newInstanceWithoutConstructor) +{ + reflection_object *intern; + zend_class_entry *ce; + + METHOD_NOTSTATIC(reflection_class_ptr); + GET_REFLECTION_OBJECT_PTR(ce); + + if (ce->create_object != NULL) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class that cannot be instantiated without invoking its constructor", ce->name); + } + + object_init_ex(return_value, ce); +} +/* }}} */ + /* {{{ proto public stdclass ReflectionClass::newInstanceArgs([array args]) Returns an instance of this class */ ZEND_METHOD(reflection_class, newInstanceArgs) @@@ -4186,8 -3962,8 +4186,8 @@@ zend_class_entry *ce; int argc = 0; HashTable *args; - - + + METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); @@@ -4197,7 -3973,7 +4197,7 @@@ if (ZEND_NUM_ARGS() > 0) { argc = args->nNumOfElements; } - + /* Run the constructor if there is one */ if (ce->constructor) { zval ***params = NULL; @@@ -4208,10 -3984,10 +4208,10 @@@ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name); return; } - + if (argc) { params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); params -= argc; } @@@ -4307,80 -4083,6 +4307,80 @@@ ZEND_METHOD(reflection_class, getInterf } /* }}} */ +/* {{{ proto public ReflectionClass[] ReflectionClass::getTraits() + Returns an array of traits used by this class */ +ZEND_METHOD(reflection_class, getTraits) +{ + reflection_object *intern; + zend_class_entry *ce; + zend_uint i; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + for (i=0; i < ce->num_traits; i++) { + zval *trait; + ALLOC_ZVAL(trait); + zend_reflection_class_factory(ce->traits[i], trait TSRMLS_CC); + add_assoc_zval_ex(return_value, ce->traits[i]->name, ce->traits[i]->name_length + 1, trait); + } +} +/* }}} */ + +/* {{{ proto public String[] ReflectionClass::getTraitNames() + Returns an array of names of traits used by this class */ +ZEND_METHOD(reflection_class, getTraitNames) +{ + reflection_object *intern; + zend_class_entry *ce; + zend_uint i; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + for (i=0; i < ce->num_traits; i++) { + add_next_index_stringl(return_value, ce->traits[i]->name, ce->traits[i]->name_length, 1); + } +} +/* }}} */ + +/* {{{ proto public arra ReflectionClass::getTraitaliases() + Returns an array of trait aliases */ +ZEND_METHOD(reflection_class, getTraitAliases) +{ + reflection_object *intern; + zend_class_entry *ce; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + if (ce->trait_aliases) { + zend_uint i = 0; + while (ce->trait_aliases[i]) { + char *method_name; + int method_name_len; + zend_trait_method_reference *cur_ref = ce->trait_aliases[i]->trait_method; + + method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->class_name, cur_ref->method_name); + add_assoc_stringl_ex(return_value, ce->trait_aliases[i]->alias, ce->trait_aliases[i]->alias_len + 1, method_name, method_name_len, 0); + i++; + } + } +} +/* }}} */ + /* {{{ proto public ReflectionClass ReflectionClass::getParentClass() Returns the class' parent class, or, if none exists, FALSE */ ZEND_METHOD(reflection_class, getParentClass) @@@ -4392,7 -4094,7 +4392,7 @@@ return; } GET_REFLECTION_OBJECT_PTR(ce); - + if (ce->parent) { zend_reflection_class_factory(ce->parent, return_value TSRMLS_CC); } else { @@@ -4415,16 -4117,16 +4415,16 @@@ ZEND_METHOD(reflection_class, isSubclas if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &class_name) == FAILURE) { return; } - + switch(class_name->type) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(class_name)); return; } class_ce = *pce; - break; + break; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(class_name), reflection_class_ptr TSRMLS_CC)) { argument = (reflection_object *) zend_object_store_get_object(class_name TSRMLS_CC); @@@ -4437,7 -4139,7 +4437,7 @@@ } /* no break */ default: - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter one must either be a string or a ReflectionClass object"); return; } @@@ -4460,16 -4162,16 +4460,16 @@@ ZEND_METHOD(reflection_class, implement if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &interface) == FAILURE) { return; } - + switch(interface->type) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(interface), Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s does not exist", Z_STRVAL_P(interface)); return; } interface_ce = *pce; - break; + break; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(interface), reflection_class_ptr TSRMLS_CC)) { argument = (reflection_object *) zend_object_store_get_object(interface TSRMLS_CC); @@@ -4482,13 -4184,13 +4482,13 @@@ } /* no break */ default: - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter one must either be a string or a ReflectionClass object"); return; } if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s is a Class", interface_ce->name); return; } @@@ -4502,7 -4204,7 +4502,7 @@@ ZEND_METHOD(reflection_class, isIterate { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -4520,7 -4222,7 +4520,7 @@@ ZEND_METHOD(reflection_class, getExtens { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -4528,8 -4230,8 +4528,8 @@@ METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); - if (ce->module) { - reflection_extension_factory(return_value, ce->module->name TSRMLS_CC); + if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module) { + reflection_extension_factory(return_value, ce->info.internal.module->name TSRMLS_CC); } } /* }}} */ @@@ -4540,7 -4242,7 +4540,7 @@@ ZEND_METHOD(reflection_class, getExtens { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -4548,8 -4250,8 +4548,8 @@@ METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); - if (ce->module) { - RETURN_STRING(ce->module->name, 1); + if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module) { + RETURN_STRING(ce->info.internal.module->name, 1); } else { RETURN_FALSE; } @@@ -4561,7 -4263,7 +4561,7 @@@ ZEND_METHOD(reflection_class, inNamespace) { zval **name; - char *colon; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -4570,8 -4272,8 +4570,8 @@@ RETURN_FALSE; } if (Z_TYPE_PP(name) == IS_STRING - && (colon = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) - && colon > Z_STRVAL_PP(name)) + && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) + && backslash > Z_STRVAL_PP(name)) { RETURN_TRUE; } @@@ -4584,7 -4286,7 +4584,7 @@@ ZEND_METHOD(reflection_class, getNamespaceName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -4607,7 -4309,7 +4607,7 @@@ ZEND_METHOD(reflection_class, getShortName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -4654,8 -4356,7 +4654,8 @@@ ZEND_METHOD(reflection_property, export ZEND_METHOD(reflection_property, __construct) { zval *propname, *classname; - char *name_str, *class_name, *prop_name; + char *name_str; + const char *class_name, *prop_name; int name_len, dynam_prop = 0; zval *object; reflection_object *intern; @@@ -4673,13 -4374,13 +4673,13 @@@ if (intern == NULL) { return; } - + /* Find the class entry */ switch (Z_TYPE_P(classname)) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Class %s does not exist", Z_STRVAL_P(classname)); + "Class %s does not exist", Z_STRVAL_P(classname)); return; } ce = *pce; @@@ -4688,7 -4389,7 +4688,7 @@@ case IS_OBJECT: ce = Z_OBJCE_P(classname); break; - + default: _DO_THROW("The parameter class is expected to be either a string or an object"); /* returns out of this function */ @@@ -4706,12 -4407,12 +4706,12 @@@ return; } } - + if (dynam_prop == 0 && (property_info->flags & ZEND_ACC_PRIVATE) == 0) { /* we have to search the class hierarchy for this (implicit) public or protected property */ zend_class_entry *tmp_ce = ce; zend_property_info *tmp_info; - + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) != SUCCESS) { ce = tmp_ce; property_info = tmp_info; @@@ -4719,19 -4420,19 +4719,19 @@@ } } - MAKE_STD_ZVAL(classname); + MAKE_STD_ZVAL(classname); MAKE_STD_ZVAL(propname); - + if (dynam_prop == 0) { zend_unmangle_property_name(property_info->name, property_info->name_length, &class_name, &prop_name); ZVAL_STRINGL(classname, property_info->ce->name, property_info->ce->name_length, 1); ZVAL_STRING(propname, prop_name, 1); } else { - ZVAL_STRINGL(classname, ce->name, ce->name_length, 1); + ZVAL_STRINGL(classname, ce->name, ce->name_length, 1); ZVAL_STRINGL(propname, name_str, name_len, 1); } - zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &propname, sizeof(zval *), NULL); + reflection_update_property(object, "class", classname); + reflection_update_property(object, "name", propname); reference = (property_reference*) emalloc(sizeof(property_reference)); if (dynam_prop) { @@@ -4781,7 -4482,7 +4781,7 @@@ ZEND_METHOD(reflection_property, getNam } /* }}} */ -static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) +static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /* {{{ */ { reflection_object *intern; property_reference *ref; @@@ -4792,7 -4493,6 +4792,7 @@@ GET_REFLECTION_OBJECT_PTR(ref); RETURN_BOOL(ref->prop.flags & mask); } +/* }}} */ /* {{{ proto public bool ReflectionProperty::isPublic() Returns whether this property is public */ @@@ -4857,14 -4557,14 +4857,14 @@@ ZEND_METHOD(reflection_property, getVal reflection_object *intern; property_reference *ref; zval *object, name; - zval **member = NULL, *member_p = NULL; + zval *member_p = NULL; METHOD_NOTSTATIC(reflection_property_ptr); GET_REFLECTION_OBJECT_PTR(ref); if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) { _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name)); zval_dtor(&name); return; @@@ -4872,16 -4572,14 +4872,16 @@@ if ((ref->prop.flags & ZEND_ACC_STATIC)) { zend_update_class_constants(intern->ce TSRMLS_CC); - if (zend_hash_quick_find(CE_STATIC_MEMBERS(intern->ce), ref->prop.name, ref->prop.name_length + 1, ref->prop.h, (void **) &member) == FAILURE) { + if (!CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name); /* Bails out */ } - MAKE_COPY_ZVAL(member, return_value); + *return_value= *CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]; + zval_copy_ctor(return_value); + INIT_PZVAL(return_value); } else { - char *class_name, *prop_name; - + const char *class_name, *prop_name; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) { return; } @@@ -4905,14 -4603,16 +4905,14 @@@ ZEND_METHOD(reflection_property, setVal zval **variable_ptr; zval *object, name; zval *value; - int setter_done = 0; zval *tmp; - HashTable *prop_table; METHOD_NOTSTATIC(reflection_property_ptr); GET_REFLECTION_OBJECT_PTR(ref); if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) { _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name)); zval_dtor(&name); return; @@@ -4925,37 -4625,36 +4925,37 @@@ } } zend_update_class_constants(intern->ce TSRMLS_CC); - prop_table = CE_STATIC_MEMBERS(intern->ce); - if (zend_hash_quick_find(prop_table, ref->prop.name, ref->prop.name_length + 1, ref->prop.h, (void **) &variable_ptr) == FAILURE) { + if (!CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name); /* Bails out */ } - if (*variable_ptr == value) { - setter_done = 1; - } else { + variable_ptr = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]; + if (*variable_ptr != value) { if (PZVAL_IS_REF(*variable_ptr)) { - zval_dtor(*variable_ptr); - (*variable_ptr)->type = value->type; + zval garbage = **variable_ptr; /* old value should be destroyed */ + + /* To check: can't *variable_ptr be some system variable like error_zval here? */ + Z_TYPE_PP(variable_ptr) = Z_TYPE_P(value); (*variable_ptr)->value = value->value; if (Z_REFCOUNT_P(value) > 0) { zval_copy_ctor(*variable_ptr); } - setter_done = 1; - } - } - if (!setter_done) { - zval **foo; + zval_dtor(&garbage); + } else { + zval *garbage = *variable_ptr; - Z_ADDREF_P(value); - if (PZVAL_IS_REF(value)) { - SEPARATE_ZVAL(&value); + /* if we assign referenced variable, we should separate it */ + Z_ADDREF_P(value); + if (PZVAL_IS_REF(value)) { + SEPARATE_ZVAL(&value); + } + *variable_ptr = value; + zval_ptr_dtor(&garbage); } - zend_hash_quick_update(prop_table, ref->prop.name, ref->prop.name_length+1, ref->prop.h, &value, sizeof(zval *), (void **) &foo); } } else { - char *class_name, *prop_name; + const char *class_name, *prop_name; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oz", &object, &value) == FAILURE) { return; @@@ -4974,7 -4673,7 +4974,7 @@@ ZEND_METHOD(reflection_property, getDec property_reference *ref; zend_class_entry *tmp_ce, *ce; zend_property_info *tmp_info; - char *prop_name, *class_name; + const char *prop_name, *class_name; int prop_name_len; if (zend_parse_parameters_none() == FAILURE) { @@@ -5078,14 -4777,14 +5078,14 @@@ ZEND_METHOD(reflection_extension, __con zend_str_tolower_copy(lcname, name_str, name_len); if (zend_hash_find(&module_registry, lcname, name_len + 1, (void **)&module) == FAILURE) { free_alloca(lcname, use_heap); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Extension %s does not exist", name_str); return; } free_alloca(lcname, use_heap); MAKE_STD_ZVAL(name); ZVAL_STRING(name, module->name, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property( object, "name", name); intern->ptr = module; intern->ref_type = REF_TYPE_OTHER; intern->ce = NULL; @@@ -5171,7 -4870,7 +5171,7 @@@ ZEND_METHOD(reflection_extension, getFu efree(lc_name); continue; } - + ALLOC_ZVAL(function); reflection_function_factory(fptr, NULL, function TSRMLS_CC); add_assoc_zval_ex(return_value, func->fname, fname_len+1, function); @@@ -5182,7 -4881,7 +5182,7 @@@ } /* }}} */ -static int _addconstant(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _addconstant(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { zval *const_val; zval *retval = va_arg(args, zval*); @@@ -5197,7 -4896,6 +5197,7 @@@ } return 0; } +/* }}} */ /* {{{ proto public array ReflectionExtension::getConstants() Returns an associative array containing this extension's constants and their values */ @@@ -5257,7 -4955,7 +5257,7 @@@ static int add_extension_class(zend_cla struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*); int add_reflection_class = va_arg(args, int); - if ((*pce)->module && !strcasecmp((*pce)->module->name, module->name)) { + if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) { if (add_reflection_class) { ALLOC_ZVAL(zclass); zend_reflection_class_factory(*pce, zclass TSRMLS_CC); @@@ -5316,11 -5014,11 +5316,11 @@@ ZEND_METHOD(reflection_extension, getDe return; } GET_REFLECTION_OBJECT_PTR(module); - + array_init(return_value); dep = module->deps; - + if (!dep) { return; @@@ -5330,7 -5028,7 +5330,7 @@@ char *relation; char *rel_type; int len; - + switch(dep->type) { case MODULE_DEP_REQUIRED: rel_type = "Required"; @@@ -5346,10 -5044,10 +5346,10 @@@ break; } - len = spprintf(&relation, 0, "%s%s%s%s%s", + len = spprintf(&relation, 0, "%s%s%s%s%s", rel_type, dep->rel ? " " : "", - dep->rel ? dep->rel : "", + dep->rel ? dep->rel : "", dep->version ? " " : "", dep->version ? dep->version : ""); add_assoc_stringl(return_value, dep->name, relation, len, 0); @@@ -5358,7 -5056,7 +5358,7 @@@ } /* }}} */ -/* {{{ proto public void ReflectionExtension::info() U +/* {{{ proto public void ReflectionExtension::info() Prints phpinfo block for the extension */ ZEND_METHOD(reflection_extension, info) { @@@ -5374,180 -5072,6 +5374,180 @@@ } /* }}} */ +/* {{{ proto public bool ReflectionExtension::isPersistent() + Returns whether this extension is persistent */ +ZEND_METHOD(reflection_extension, isPersistent) +{ + reflection_object *intern; + zend_module_entry *module; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(module); + + RETURN_BOOL(module->type == MODULE_PERSISTENT); +} +/* }}} */ + +/* {{{ proto public bool ReflectionExtension::isTemporary() + Returns whether this extension is temporary */ +ZEND_METHOD(reflection_extension, isTemporary) +{ + reflection_object *intern; + zend_module_entry *module; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(module); + + RETURN_BOOL(module->type == MODULE_TEMPORARY); +} +/* }}} */ + +/* {{{ proto public static mixed ReflectionZendExtension::export(string name [, bool return]) throws ReflectionException + * Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */ +ZEND_METHOD(reflection_zend_extension, export) +{ + _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_zend_extension_ptr, 1); +} +/* }}} */ + +/* {{{ proto public void ReflectionZendExtension::__construct(string name) + Constructor. Throws an Exception in case the given Zend extension does not exist */ +ZEND_METHOD(reflection_zend_extension, __construct) +{ + zval *name; + zval *object; + reflection_object *intern; + zend_extension *extension; + char *name_str; + int name_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len) == FAILURE) { + return; + } + + object = getThis(); + intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC); + if (intern == NULL) { + return; + } + + extension = zend_get_extension(name_str); + if (!extension) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Zend Extension %s does not exist", name_str); + return; + } + MAKE_STD_ZVAL(name); + ZVAL_STRING(name, extension->name, 1); + reflection_update_property(object, "name", name); + intern->ptr = extension; + intern->ref_type = REF_TYPE_OTHER; + intern->ce = NULL; +} +/* }}} */ + +/* {{{ proto public string ReflectionZendExtension::__toString() + Returns a string representation */ +ZEND_METHOD(reflection_zend_extension, __toString) +{ + reflection_object *intern; + zend_extension *extension; + string str; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + string_init(&str); + _zend_extension_string(&str, extension, "" TSRMLS_CC); + RETURN_STRINGL(str.string, str.len - 1, 0); +} +/* }}} */ + +/* {{{ proto public string ReflectionZendExtension::getName() + Returns the name of this Zend extension */ +ZEND_METHOD(reflection_zend_extension, getName) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->name, 1); +} +/* }}} */ + +/* {{{ proto public string ReflectionZendExtension::getVersion() + Returns the version information of this Zend extension */ +ZEND_METHOD(reflection_zend_extension, getVersion) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->version ? extension->version : "", 1); +} +/* }}} */ + +/* {{{ proto public void ReflectionZendExtension::getAuthor() + * Returns the name of this Zend extension's author */ +ZEND_METHOD(reflection_zend_extension, getAuthor) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->author ? extension->author : "", 1); +} +/* }}} */ + +/* {{{ proto public void ReflectionZendExtension::getURL() + Returns this Zend extension's URL*/ +ZEND_METHOD(reflection_zend_extension, getURL) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->URL ? extension->URL : "", 1); +} +/* }}} */ + +/* {{{ proto public void ReflectionZendExtension::getCopyright() + Returns this Zend extension's copyright information */ +ZEND_METHOD(reflection_zend_extension, getCopyright) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->copyright ? extension->copyright : "", 1); +} +/* }}} */ + /* {{{ method tables */ static const zend_function_entry reflection_exception_functions[] = { PHP_FE_END @@@ -5603,8 -5127,6 +5603,8 @@@ static const zend_function_entry reflec ZEND_ME(reflection_function, isDeprecated, arginfo_reflection__void, 0) ZEND_ME(reflection_function, isInternal, arginfo_reflection__void, 0) ZEND_ME(reflection_function, isUserDefined, arginfo_reflection__void, 0) + ZEND_ME(reflection_function, getClosureThis, arginfo_reflection__void, 0) + ZEND_ME(reflection_function, getClosureScopeClass, arginfo_reflection__void, 0) ZEND_ME(reflection_function, getDocComment, arginfo_reflection__void, 0) ZEND_ME(reflection_function, getEndLine, arginfo_reflection__void, 0) ZEND_ME(reflection_function, getExtension, arginfo_reflection__void, 0) @@@ -5629,7 -5151,6 +5629,7 @@@ static const zend_function_entry reflec ZEND_ME(reflection_function, isDisabled, arginfo_reflection__void, 0) ZEND_ME(reflection_function, invoke, arginfo_reflection_function_invoke, 0) ZEND_ME(reflection_function, invokeArgs, arginfo_reflection_function_invokeArgs, 0) + ZEND_ME(reflection_function, getClosure, arginfo_reflection__void, 0) PHP_FE_END }; @@@ -5658,10 -5179,6 +5658,10 @@@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_ ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_getClosure, 0) + ZEND_ARG_INFO(0, object) +ZEND_END_ARG_INFO() + static const zend_function_entry reflection_method_functions[] = { ZEND_ME(reflection_method, export, arginfo_reflection_method_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) ZEND_ME(reflection_method, __construct, arginfo_reflection_method___construct, 0) @@@ -5674,7 -5191,6 +5674,7 @@@ ZEND_ME(reflection_method, isStatic, arginfo_reflection__void, 0) ZEND_ME(reflection_method, isConstructor, arginfo_reflection__void, 0) ZEND_ME(reflection_method, isDestructor, arginfo_reflection__void, 0) + ZEND_ME(reflection_method, getClosure, arginfo_reflection_method_getClosure, 0) ZEND_ME(reflection_method, getModifiers, arginfo_reflection__void, 0) ZEND_ME(reflection_method, invoke, arginfo_reflection_method_invoke, 0) ZEND_ME(reflection_method, invokeArgs, arginfo_reflection_method_invokeArgs, 0) @@@ -5744,9 -5260,6 +5744,9 @@@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_ ZEND_ARG_INFO(0, args) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_newInstanceWithoutConstructor, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_newInstanceArgs, 0, 0, 0) ZEND_ARG_ARRAY_INFO(0, args, 0) ZEND_END_ARG_INFO() @@@ -5768,7 -5281,6 +5768,7 @@@ static const zend_function_entry reflec ZEND_ME(reflection_class, isInternal, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isUserDefined, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isInstantiable, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, isCloneable, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getFileName, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getStartLine, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getEndLine, arginfo_reflection__void, 0) @@@ -5786,16 -5298,11 +5786,16 @@@ ZEND_ME(reflection_class, getInterfaces, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getInterfaceNames, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isInterface, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, getTraits, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, getTraitNames, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, getTraitAliases, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, isTrait, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isAbstract, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isFinal, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getModifiers, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isInstance, arginfo_reflection_class_isInstance, 0) ZEND_ME(reflection_class, newInstance, arginfo_reflection_class_newInstance, 0) + ZEND_ME(reflection_class, newInstanceWithoutConstructor, arginfo_reflection_class_newInstanceWithoutConstructor, 0) ZEND_ME(reflection_class, newInstanceArgs, arginfo_reflection_class_newInstanceArgs, 0) ZEND_ME(reflection_class, getParentClass, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isSubclassOf, arginfo_reflection_class_isSubclassOf, 0) @@@ -5892,12 -5399,10 +5892,12 @@@ static const zend_function_entry reflec ZEND_ME(reflection_parameter, __toString, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getName, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isPassedByReference, arginfo_reflection__void, 0) + ZEND_ME(reflection_parameter, canBePassedByValue, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getDeclaringFunction, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getDeclaringClass, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getClass, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isArray, arginfo_reflection__void, 0) + ZEND_ME(reflection_parameter, isCallable, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, allowsNull, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getPosition, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isOptional, arginfo_reflection__void, 0) @@@ -5929,25 -5434,6 +5929,25 @@@ static const zend_function_entry reflec ZEND_ME(reflection_extension, getClassNames, arginfo_reflection__void, 0) ZEND_ME(reflection_extension, getDependencies, arginfo_reflection__void, 0) ZEND_ME(reflection_extension, info, arginfo_reflection__void, 0) + ZEND_ME(reflection_extension, isPersistent, arginfo_reflection__void, 0) + ZEND_ME(reflection_extension, isTemporary, arginfo_reflection__void, 0) + PHP_FE_END +}; + +ZEND_BEGIN_ARG_INFO(arginfo_reflection_zend_extension___construct, 0) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +static const zend_function_entry reflection_zend_extension_functions[] = { + ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) + ZEND_ME(reflection_zend_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) + ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_extension___construct, 0) + ZEND_ME(reflection_zend_extension, __toString, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getName, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getVersion, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getAuthor, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getURL, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getCopyright, arginfo_reflection__void, 0) PHP_FE_END }; /* }}} */ @@@ -5959,19 -5445,19 +5959,19 @@@ const zend_function_entry reflection_ex static zend_object_handlers *zend_std_obj_handlers; /* {{{ _reflection_write_property */ -static void _reflection_write_property(zval *object, zval *member, zval *value TSRMLS_DC) +static void _reflection_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) { if ((Z_TYPE_P(member) == IS_STRING) - && zend_hash_exists(&Z_OBJCE_P(object)->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) + && zend_hash_exists(&Z_OBJCE_P(object)->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) && ((Z_STRLEN_P(member) == sizeof("name") - 1 && !memcmp(Z_STRVAL_P(member), "name", sizeof("name"))) || (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class"))))) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot set read-only property %s::$%s", Z_OBJCE_P(object)->name, Z_STRVAL_P(member)); } else { - zend_std_obj_handlers->write_property(object, member, value TSRMLS_CC); + zend_std_obj_handlers->write_property(object, member, value, key TSRMLS_CC); } } /* }}} */ @@@ -6058,12 -5544,6 +6058,12 @@@ PHP_MINIT_FUNCTION(reflection) /* {{{ * reflection_register_implement(reflection_extension_ptr, reflector_ptr TSRMLS_CC); zend_declare_property_string(reflection_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); + INIT_CLASS_ENTRY(_reflection_entry, "ReflectionZendExtension", reflection_zend_extension_functions); + _reflection_entry.create_object = reflection_objects_new; + reflection_zend_extension_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC); + reflection_register_implement(reflection_zend_extension_ptr, reflector_ptr TSRMLS_CC); + zend_declare_property_string(reflection_zend_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); + return SUCCESS; } /* }}} */ @@@ -6072,7 -5552,7 +6072,7 @@@ PHP_MINFO_FUNCTION(reflection) /* {{{ * php_info_print_table_start(); php_info_print_table_header(2, "Reflection", "enabled"); - php_info_print_table_row(2, "Version", "$Revision$"); + php_info_print_table_row(2, "Version", "$Id$"); php_info_print_table_end(); } /* }}} */ @@@ -6086,7 -5566,7 +6086,7 @@@ zend_module_entry reflection_module_ent NULL, NULL, PHP_MINFO(reflection), - "$Revision$", + "$Id$", STANDARD_MODULE_PROPERTIES }; /* }}} */ diff --combined ext/simplexml/simplexml.c index 334dcd4,a379111..455280f --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@@ -389,7 -389,7 +389,7 @@@ static zval * sxe_prop_dim_read(zval *o /* {{{ sxe_property_read() */ -static zval * sxe_property_read(zval *object, zval *member, int type TSRMLS_DC) +static zval * sxe_property_read(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) { return sxe_prop_dim_read(object, member, 1, 0, type TSRMLS_CC); } @@@ -680,7 -680,7 +680,7 @@@ next_iter /* {{{ sxe_property_write() */ -static void sxe_property_write(zval *object, zval *member, zval *value TSRMLS_DC) +static void sxe_property_write(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) { sxe_prop_dim_write(object, member, value, 1, 0, NULL TSRMLS_CC); } @@@ -694,7 -694,7 +694,7 @@@ static void sxe_dimension_write(zval *o } /* }}} */ -static zval** sxe_property_get_adr(zval *object, zval *member TSRMLS_DC) /* {{{ */ +static zval** sxe_property_get_adr(zval *object, zval *member, const zend_literal *key TSRMLS_DC) /* {{{ */ { php_sxe_object *sxe; xmlNodePtr node; @@@ -846,7 -846,7 +846,7 @@@ static int sxe_prop_dim_exists(zval *ob /* {{{ sxe_property_exists() */ -static int sxe_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC) +static int sxe_property_exists(zval *object, zval *member, int check_empty, const zend_literal *key TSRMLS_DC) { return sxe_prop_dim_exists(object, member, check_empty, 1, 0 TSRMLS_CC); } @@@ -971,7 -971,7 +971,7 @@@ next_iter /* {{{ sxe_property_delete() */ -static void sxe_property_delete(zval *object, zval *member TSRMLS_DC) +static void sxe_property_delete(zval *object, zval *member, const zend_literal *key TSRMLS_DC) { sxe_prop_dim_delete(object, member, 1, 0 TSRMLS_CC); } @@@ -1069,10 -1069,6 +1069,10 @@@ static HashTable * sxe_get_prop_hash(zv xmlAttrPtr attr; int namelen; int test; + char use_iter; + zval *iter_data; + + use_iter = 0; sxe = php_sxe_fetch_object(object TSRMLS_CC); @@@ -1126,7 -1122,6 +1126,7 @@@ GET_NODE(sxe, node); node = php_sxe_get_first_node(sxe, node TSRMLS_CC); + if (node && sxe->iter.type != SXE_ITER_ATTRLIST) { if (node->type == XML_ATTRIBUTE_NODE) { MAKE_STD_ZVAL(value); @@@ -1134,17 -1129,7 +1134,17 @@@ zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); node = NULL; } else if (sxe->iter.type != SXE_ITER_CHILD) { - node = node->children; + + if ( !node->children || !node->parent || node->children->next || node->children->children || node->parent->children == node->parent->last ) { + node = node->children; + } else { + iter_data = sxe->iter.data; + sxe->iter.data = NULL; + + node = php_sxe_reset_iterator(sxe, 0 TSRMLS_CC); + + use_iter = 1; + } } while (node) { @@@ -1176,25 -1161,10 +1176,25 @@@ _get_base_node_value(sxe, node, &value, sxe->iter.nsprefix, sxe->iter.isprefix TSRMLS_CC); - sxe_properties_add(rv, name, namelen, value TSRMLS_CC); + if ( use_iter ) { + zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); + } else { + sxe_properties_add(rv, name, namelen, value TSRMLS_CC); + } next_iter: - node = node->next; + if ( use_iter ) { + node = php_sxe_iterator_fetch(sxe, node->next, 0 TSRMLS_CC); + } else { + node = node->next; + } + } + } + + if ( use_iter ) { + if (sxe->iter.data) { + zval_ptr_dtor(&sxe->iter.data); } + sxe->iter.data = iter_data; } return rv; @@@ -1365,7 -1335,7 +1365,7 @@@ SXE_METHOD(asXML } if (ZEND_NUM_ARGS() == 1) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { RETURN_FALSE; } @@@ -2148,7 -2118,7 +2148,7 @@@ PHP_FUNCTION(simplexml_load_file zend_class_entry *ce= sxe_class_entry; zend_bool isprefix = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|C!lsb", &filename, &filename_len, &ce, &options, &ns, &ns_len, &isprefix) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|C!lsb", &filename, &filename_len, &ce, &options, &ns, &ns_len, &isprefix) == FAILURE) { return; } @@@ -2638,7 -2608,7 +2638,7 @@@ PHP_MINFO_FUNCTION(simplexml { php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision$"); + php_info_print_table_row(2, "Revision", "$Id$"); php_info_print_table_row(2, "Schema support", #ifdef LIBXML_SCHEMAS_ENABLED "enabled"); diff --combined ext/sysvmsg/sysvmsg.c index 9ba10cb,bf99fb0..6360183 --- a/ext/sysvmsg/sysvmsg.c +++ b/ext/sysvmsg/sysvmsg.c @@@ -145,7 -145,7 +145,7 @@@ PHP_MINFO_FUNCTION(sysvmsg { php_info_print_table_start(); php_info_print_table_row(2, "sysvmsg support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision$"); + php_info_print_table_row(2, "Revision", "$Id$"); php_info_print_table_end(); } /* }}} */ @@@ -271,7 -271,7 +271,7 @@@ PHP_FUNCTION(msg_get_queue RETURN_FALSE; } } - RETVAL_RESOURCE(zend_list_insert(mq, le_sysvmsg)); + RETVAL_RESOURCE(zend_list_insert(mq, le_sysvmsg TSRMLS_CC)); } /* }}} */ diff --combined sapi/continuity/capi.c index f6a2d06,cdf7283..96c3923 --- a/sapi/continuity/capi.c +++ b/sapi/continuity/capi.c @@@ -110,7 -110,7 +110,7 @@@ PHP_MSHUTDOWN_FUNCTION(continuity PHP_MINFO_FUNCTION(continuity) { php_info_print_table_start(); - php_info_print_table_row(2, "Continuity Module Revision", "$Revision$"); + php_info_print_table_row(2, "Continuity Module Revision", "$Id$"); php_info_print_table_row(2, "Server Version", conFget_build()); #ifdef CONTINUITY_CDPEXT php_info_print_table_row(2,"CDP Extensions", "enabled"); @@@ -343,8 -343,9 +343,8 @@@ static void sapi_capi_register_server_v } -static void capi_log_message(char *message) +static void capi_log_message(char *message TSRMLS_DC) { - TSRMLS_FETCH(); capi_request_context *rc = (capi_request_context *) SG(server_context); logFmsg(0, "mod/php: %s", message); } diff --combined sapi/nsapi/nsapi.c index 7e009df,202bf54..1579ef7 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@@ -312,7 -312,7 +312,7 @@@ PHP_MSHUTDOWN_FUNCTION(nsapi PHP_MINFO_FUNCTION(nsapi) { php_info_print_table_start(); - php_info_print_table_row(2, "NSAPI Module Revision", "$Revision$"); + php_info_print_table_row(2, "NSAPI Module Revision", "$Id$"); php_info_print_table_row(2, "Server Software", system_version()); php_info_print_table_row(2, "Sub-requests with nsapi_virtual()", (nsapi_servact_service)?((zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0))?"not supported with zlib.output_compression":"enabled"):"not supported on this platform" ); @@@ -347,7 -347,7 +347,7 @@@ PHP_FUNCTION(nsapi_virtual php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Sub-requests do not work with zlib.output_compression", uri); RETURN_FALSE; } else { - php_end_ob_buffers(1 TSRMLS_CC); + php_output_end_all(TSRMLS_C); php_header(TSRMLS_C); /* do the sub-request */ @@@ -414,7 -414,9 +414,7 @@@ PHP_FUNCTION(nsapi_request_headers for (i=0; i < rc->rq->headers->hsize; i++) { entry=rc->rq->headers->ht[i]; while (entry) { - if (!PG(safe_mode) || strncasecmp(entry->param->name, "authorization", 13)) { - add_assoc_string(return_value, entry->param->name, entry->param->value, 1); - } + add_assoc_string(return_value, entry->param->name, entry->param->value, 1); entry=entry->next; } } @@@ -674,22 -676,24 +674,22 @@@ static void sapi_nsapi_register_server_ for (i=0; i < rc->rq->headers->hsize; i++) { entry=rc->rq->headers->ht[i]; while (entry) { - if (!PG(safe_mode) || strncasecmp(entry->param->name, "authorization", 13)) { - if (strcasecmp(entry->param->name, "content-length")==0 || strcasecmp(entry->param->name, "content-type")==0) { - value=estrdup(entry->param->name); - pos = 0; - } else { - spprintf(&value, 0, "HTTP_%s", entry->param->name); - pos = 5; - } - if (value) { - for(p = value + pos; *p; p++) { - *p = toupper(*p); - if (!isalnum(*p)) { - *p = '_'; - } + if (strcasecmp(entry->param->name, "content-length")==0 || strcasecmp(entry->param->name, "content-type")==0) { + value=estrdup(entry->param->name); + pos = 0; + } else { + spprintf(&value, 0, "HTTP_%s", entry->param->name); + pos = 5; + } + if (value) { + for(p = value + pos; *p; p++) { + *p = toupper(*p); + if (!isalnum(*p)) { + *p = '_'; } - php_register_variable(value, entry->param->value, track_vars_array TSRMLS_CC); - efree(value); } + php_register_variable(value, entry->param->value, track_vars_array TSRMLS_CC); + efree(value); } entry=entry->next; } @@@ -775,8 -779,9 +775,8 @@@ } } -static void nsapi_log_message(char *message) +static void nsapi_log_message(char *message TSRMLS_DC) { - TSRMLS_FETCH(); nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); if (rc) { @@@ -786,7 -791,7 +786,7 @@@ } } -static time_t sapi_nsapi_get_request_time(TSRMLS_D) +static double sapi_nsapi_get_request_time(TSRMLS_D) { return REQ_TIME( ((nsapi_request_context *)SG(server_context))->rq ); } @@@ -1030,7 -1035,7 +1030,7 @@@ int NSAPI_PUBLIC php5_execute(pblock *p nsapi_php_ini_entries(NSLS_C TSRMLS_CC); - if (!PG(safe_mode)) php_handle_auth_data(pblock_findval("authorization", rq->headers) TSRMLS_CC); + php_handle_auth_data(pblock_findval("authorization", rq->headers) TSRMLS_CC); file_handle.type = ZEND_HANDLE_FILENAME; file_handle.filename = SG(request_info).path_translated;
c918ca57a7233206ec78ac00438eeb6830e3680b diff --combined README.input_filter index 4b83b9d,488ca82..e2941d0 --- a/README.input_filter +++ b/README.input_filter @@@ -19,7 -19,9 +19,7 @@@ A simple implementation might look lik original raw user data and adds a my_get_raw() function while the normal $_POST, $_GET and $_COOKIE arrays are only populated with stripped data. In this simple example all I am doing is calling strip_tags() on -the data. If register_globals is turned on, the default globals that -are created will be stripped ($foo) while a $RAW_foo is created with the -original user input. +the data. ZEND_BEGIN_MODULE_GLOBALS(my_input_filter) zval *post_array; @@@ -86,7 -88,7 +86,7 @@@ PHP_MINFO_FUNCTION(my_input_filter { php_info_print_table_start(); php_info_print_table_row( 2, "My Input Filter Support", "enabled" ); - php_info_print_table_row( 2, "Revision", "$Revision$"); + php_info_print_table_row( 2, "Revision", "$Id$"); php_info_print_table_end(); } @@@ -153,6 -155,8 +153,6 @@@ PHP_FUNCTION(my_get_raw int var_len; zval **tmp; zval *array_ptr = NULL; - HashTable *hash_ptr; - char *raw_var; if(zend_parse_parameters(2 TSRMLS_CC, "ls", &arg, &var, &var_len) == FAILURE) { return; @@@ -170,15 -174,23 +170,15 @@@ break; } - if(!array_ptr) RETURN_FALSE; - - /* - * I'm changing the variable name here because when running with register_globals on, - * the variable will end up in the global symbol table - */ - raw_var = emalloc(var_len+5); /* RAW_ and a \0 */ - strcpy(raw_var, "RAW_"); - strlcat(raw_var,var,var_len+5); - hash_ptr = HASH_OF(array_ptr); + if(!array_ptr) { + RETURN_FALSE; + } - if(zend_hash_find(hash_ptr, raw_var, var_len+5, (void **)&tmp) == SUCCESS) { + if(zend_hash_find(HASH_OF(array_ptr), var, var_len+5, (void **)&tmp) == SUCCESS) { *return_value = **tmp; zval_copy_ctor(return_value); } else { RETVAL_FALSE; } - efree(raw_var); } diff --combined ext/dba/libflatfile/flatfile.c index e81b8ea,081af74..bf85184 --- a/ext/dba/libflatfile/flatfile.c +++ b/ext/dba/libflatfile/flatfile.c @@@ -27,6 -27,7 +27,6 @@@ #include "php.h" #include "php_globals.h" -#include "safe_mode.h" #include <stdlib.h> #include <string.h> @@@ -306,7 -307,7 +306,7 @@@ datum flatfile_nextkey(flatfile *dba TS /* {{{ flatfile_version */ char *flatfile_version() { - return "1.0, $Revision$"; + return "1.0, $Id$"; } /* }}} */ diff --combined ext/dba/libinifile/inifile.c index 4c85087,f7157ed..35930d1 --- a/ext/dba/libinifile/inifile.c +++ b/ext/dba/libinifile/inifile.c @@@ -24,6 -24,7 +24,6 @@@ #include "php.h" #include "php_globals.h" -#include "safe_mode.h" #include <stdlib.h> #include <string.h> @@@ -42,7 -43,7 +42,7 @@@ /* {{{ inifile_version */ char *inifile_version() { - return "1.0, $Revision$"; + return "1.0, $Id$"; } /* }}} */ diff --combined ext/enchant/enchant.c index c85c22c,0126d9e..2d784eb --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@@ -124,7 -124,7 +124,7 @@@ ZEND_END_ARG_INFO( * * Every user visible function must have an entry in enchant_functions[]. */ -function_entry enchant_functions[] = { +zend_function_entry enchant_functions[] = { PHP_FE(enchant_broker_init, arginfo_enchant_broker_init) PHP_FE(enchant_broker_free, arginfo_enchant_broker_free) PHP_FE(enchant_broker_get_error, arginfo_enchant_broker_free) @@@ -244,8 -244,8 +244,8 @@@ static void php_enchant_broker_free(zen if (broker->pbroker) { if (broker->dictcnt && broker->dict) { if (broker->dict) { - int total, tofree; - tofree = total = broker->dictcnt-1; + int total; + total = broker->dictcnt-1; do { zend_list_delete(broker->dict[total]->rsrc_id); efree(broker->dict[total]); @@@ -326,7 -326,7 +326,7 @@@ PHP_MINFO_FUNCTION(enchant #elif defined(HAVE_ENCHANT_BROKER_SET_PARAM) php_info_print_table_row(2, "Libenchant Version", "1.5.0 or later"); #endif - php_info_print_table_row(2, "Revision", "$Revision$"); + php_info_print_table_row(2, "Revision", "$Id$"); php_info_print_table_end(); php_info_print_table_start(); @@@ -357,8 -357,8 +357,8 @@@ PHP_FUNCTION(enchant_broker_init enchant_broker *broker; EnchantBroker *pbroker; - if (ZEND_NUM_ARGS()) { - ZEND_WRONG_PARAM_COUNT(); + if (zend_parse_parameters_none() == FAILURE) { + return; } pbroker = enchant_broker_init(); @@@ -542,11 -542,6 +542,11 @@@ PHP_FUNCTION(enchant_broker_request_dic } PHP_ENCHANT_GET_BROKER; + + if (taglen == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tag cannot be empty"); + RETURN_FALSE; + } d = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag); if (d) { @@@ -591,7 -586,11 +591,7 @@@ PHP_FUNCTION(enchant_broker_request_pwl int pwllen; int pos; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &pwl, &pwllen) == FAILURE) { - RETURN_FALSE; - } - - if (strlen(pwl) != pwllen) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &broker, &pwl, &pwllen) == FAILURE) { RETURN_FALSE; } diff --combined ext/filter/filter.c index f2aae47,2b8c730..e523cdc --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@@ -276,7 -276,7 +276,7 @@@ PHP_MINIT_FUNCTION(filter REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_RES_RANGE", FILTER_FLAG_NO_RES_RANGE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_PRIV_RANGE", FILTER_FLAG_NO_PRIV_RANGE, CONST_CS | CONST_PERSISTENT); - sapi_register_input_filter(php_sapi_filter, php_sapi_filter_init); + sapi_register_input_filter(php_sapi_filter, php_sapi_filter_init TSRMLS_CC); return SUCCESS; } @@@ -318,7 -318,7 +318,7 @@@ PHP_MINFO_FUNCTION(filter { php_info_print_table_start(); php_info_print_table_row( 2, "Input Validation and Filtering", "enabled" ); - php_info_print_table_row( 2, "Revision", "$Revision$"); + php_info_print_table_row( 2, "Revision", "$Id$"); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); @@@ -406,6 -406,7 +406,6 @@@ static unsigned int php_sapi_filter(in { zval new_var, raw_var; zval *array_ptr = NULL, *orig_array_ptr = NULL; - char *orig_var = NULL; int retval = 0; assert(*val != NULL); @@@ -446,7 -447,13 +446,7 @@@ } if (array_ptr) { - /* Make a copy of the variable name, as php_register_variable_ex seems to - * modify it */ - orig_var = estrdup(var); - /* Store the RAW variable internally */ - /* FIXME: Should not use php_register_variable_ex as that also registers - * globals when register_globals is turned on */ Z_STRLEN(raw_var) = val_len; Z_STRVAL(raw_var) = estrndup(*val, val_len); Z_TYPE(raw_var) = IS_STRING; @@@ -456,6 -463,8 +456,6 @@@ if (val_len) { /* Register mangled variable */ - /* FIXME: Should not use php_register_variable_ex as that also registers - * globals when register_globals is turned on */ Z_STRLEN(new_var) = val_len; Z_TYPE(new_var) = IS_STRING; @@@ -464,6 -473,8 +464,6 @@@ Z_STRVAL(new_var) = estrndup(*val, val_len); INIT_PZVAL(tmp_new_var); php_zval_filter(&tmp_new_var, IF_G(default_filter), IF_G(default_filter_flags), NULL, NULL/*charset*/, 0 TSRMLS_CC); - } else if (PG(magic_quotes_gpc) && !retval) { /* for PARSE_STRING php_register_variable_safe() will do the addslashes() */ - Z_STRVAL(new_var) = php_addslashes(*val, Z_STRLEN(new_var), &Z_STRLEN(new_var), 0 TSRMLS_CC); } else { Z_STRVAL(new_var) = estrndup(*val, val_len); } @@@ -472,7 -483,10 +472,7 @@@ } if (orig_array_ptr) { - php_register_variable_ex(orig_var, &new_var, orig_array_ptr TSRMLS_CC); - } - if (array_ptr) { - efree(orig_var); + php_register_variable_ex(var, &new_var, orig_array_ptr TSRMLS_CC); } if (retval) { @@@ -525,6 -539,7 +525,6 @@@ static zval *php_filter_get_storage(lon { zval *array_ptr = NULL; - zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays)); switch (arg) { case PARSE_GET: @@@ -537,13 -552,13 +537,13 @@@ array_ptr = IF_G(cookie_array); break; case PARSE_SERVER: - if (jit_initialization) { + if (PG(auto_globals_jit)) { zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); } array_ptr = IF_G(server_array); break; case PARSE_ENV: - if (jit_initialization) { + if (PG(auto_globals_jit)) { zend_is_auto_global("_ENV", sizeof("_ENV")-1 TSRMLS_CC); } array_ptr = IF_G(env_array) ? IF_G(env_array) : PG(http_globals)[TRACK_VARS_ENV]; diff --combined ext/mysqlnd/mysqlnd.h index 11aea7a,65fe78e..b0b3b15 --- a/ext/mysqlnd/mysqlnd.h +++ b/ext/mysqlnd/mysqlnd.h @@@ -12,9 -12,9 +12,9 @@@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Georg Richter <georg@mysql.com> | - | Andrey Hristov <andrey@mysql.com> | + | Authors: Andrey Hristov <andrey@mysql.com> | | Ulf Wendel <uwendel@mysql.com> | + | Georg Richter <georg@mysql.com> | +----------------------------------------------------------------------+ */ /* $Id$ */ @@@ -22,10 -22,12 +22,10 @@@ #ifndef MYSQLND_H #define MYSQLND_H - #define MYSQLND_VERSION "mysqlnd 5.0.10 - 20111026 - $Revision$" -#define MYSQLND_VERSION "mysqlnd 5.0.8-dev - 20102224 - $Id$" -#define MYSQLND_VERSION_ID 50008 ++#define MYSQLND_VERSION "mysqlnd 5.0.10 - 20111026 - $Id$" +#define MYSQLND_VERSION_ID 50010 -/* This forces inlining of some accessor functions */ -#define MYSQLND_USE_OPTIMISATIONS 0 -#define AUTOCOMMIT_TX_COMMIT_ROLLBACK +#define MYSQLND_PLUGIN_API_VERSION 1 #define MYSQLND_STRING_TO_INT_CONVERSION /* @@@ -67,16 -69,29 +67,16 @@@ PHPAPI void mysqlnd_library_init(TSRMLS PHPAPI void mysqlnd_library_end(TSRMLS_D); PHPAPI unsigned int mysqlnd_plugin_register(); +PHPAPI unsigned int mysqlnd_plugin_register_ex(struct st_mysqlnd_plugin_header * plugin TSRMLS_DC); PHPAPI unsigned int mysqlnd_plugin_count(); -PHPAPI void ** _mysqlnd_plugin_get_plugin_connection_data(const MYSQLND * conn, unsigned int plugin_id TSRMLS_DC); -#define mysqlnd_plugin_get_plugin_connection_data(c, p_id) _mysqlnd_plugin_get_plugin_connection_data((c), (p_id) TSRMLS_CC) +PHPAPI void * _mysqlnd_plugin_find(const char * const name TSRMLS_DC); +#define mysqlnd_plugin_find(name) _mysqlnd_plugin_find((name) TSRMLS_CC); -PHPAPI void ** _mysqlnd_plugin_get_plugin_result_data(const MYSQLND_RES * result, unsigned int plugin_id TSRMLS_DC); -#define mysqlnd_plugin_get_plugin_result_data(r, p_id) _mysqlnd_plugin_get_plugin_result_data((r), (p_id) TSRMLS_CC) +PHPAPI void _mysqlnd_plugin_apply_with_argument(apply_func_arg_t apply_func, void * argument TSRMLS_DC); +#define mysqlnd_plugin_apply_with_argument(func, argument) _mysqlnd_plugin_apply_with_argument((func), (argument) TSRMLS_CC); -PHPAPI void ** _mysqlnd_plugin_get_plugin_stmt_data(const MYSQLND_STMT * stmt, unsigned int plugin_id TSRMLS_DC); -#define mysqlnd_plugin_get_plugin_stmt_data(s, p_id) _mysqlnd_plugin_get_plugin_stmt_data((s), (p_id) TSRMLS_CC) - -PHPAPI void ** _mysqlnd_plugin_get_plugin_protocol_data(const MYSQLND_PROTOCOL * protocol, unsigned int plugin_id TSRMLS_DC); -#define mysqlnd_plugin_get_plugin_protocol_data(p, p_id) _mysqlnd_plugin_get_plugin_protocol_data((p), (p_id) TSRMLS_CC) - - -PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods(); -PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods); - -PHPAPI struct st_mysqlnd_stmt_methods * mysqlnd_stmt_get_methods(); -PHPAPI void mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods *methods); - - -#define mysqlnd_restart_psession(conn) (conn)->m->restart_psession((conn) TSRMLS_CC) -#define mysqlnd_end_psession(conn) (conn)->m->end_psession((conn) TSRMLS_CC) +#define mysqlnd_restart_psession(conn) ((conn)->data)->m->restart_psession((conn)->data TSRMLS_CC) +#define mysqlnd_end_psession(conn) ((conn)->data)->m->end_psession((conn)->data TSRMLS_CC) PHPAPI void mysqlnd_minfo_print_hash(zval *values); #define mysqlnd_thread_safe() TRUE @@@ -87,17 -102,16 +87,17 @@@ PHPAPI const MYSQLND_CHARSET * mysqlnd_ /* Connect */ #define mysqlnd_init(persistent) _mysqlnd_init((persistent) TSRMLS_CC) PHPAPI MYSQLND * _mysqlnd_init(zend_bool persistent TSRMLS_DC); -PHPAPI MYSQLND * mysqlnd_connect(MYSQLND *conn, - const char *host, const char *user, - const char *passwd, unsigned int passwd_len, - const char *db, unsigned int db_len, +PHPAPI MYSQLND * mysqlnd_connect(MYSQLND * conn, + const char * host, const char * user, + const char * passwd, unsigned int passwd_len, + const char * db, unsigned int db_len, unsigned int port, - const char *socket_or_pipe, + const char * socket_or_pipe, unsigned int mysql_flags TSRMLS_DC); -#define mysqlnd_change_user(conn, user, passwd, db, silent) (conn)->m->change_user((conn), (user), (passwd), (db), (silent) TSRMLS_CC) +#define mysqlnd_change_user(conn, user, passwd, db, silent) ((conn)->data)->m->change_user((conn)->data, (user), (passwd), (db), (silent), strlen((passwd)) TSRMLS_CC) +#define mysqlnd_change_user_ex(conn, user, passwd, db, silent, passwd_len) ((conn)->data)->m->change_user((conn)->data, (user), (passwd), (db), (silent), (passwd_len) TSRMLS_CC) #define mysqlnd_debug(x) _mysqlnd_debug((x) TSRMLS_CC) PHPAPI void _mysqlnd_debug(const char *mode TSRMLS_DC); @@@ -107,45 -121,43 +107,45 @@@ #define mysqlnd_fetch_row_c(result) (result)->m.fetch_row_c((result) TSRMLS_CC) #define mysqlnd_fetch_all(result, flags, return_value) (result)->m.fetch_all((result), (flags), (return_value) TSRMLS_CC ZEND_FILE_LINE_CC) #define mysqlnd_result_fetch_field_data(res,offset,ret) (res)->m.fetch_field_data((res), (offset), (ret) TSRMLS_CC) -#define mysqlnd_get_connection_stats(conn, values) (conn)->m->get_statistics((conn), (values) TSRMLS_CC ZEND_FILE_LINE_CC) +#define mysqlnd_get_connection_stats(conn, values) ((conn)->data)->m->get_statistics((conn)->data, (values) TSRMLS_CC ZEND_FILE_LINE_CC) #define mysqlnd_get_client_stats(values) _mysqlnd_get_client_stats((values) TSRMLS_CC ZEND_FILE_LINE_CC) #define mysqlnd_close(conn,is_forced) (conn)->m->close((conn), (is_forced) TSRMLS_CC) -#define mysqlnd_query(conn, query_str, query_len) (conn)->m->query((conn), (query_str), (query_len) TSRMLS_CC) -#define mysqlnd_async_query(conn, query_str, query_len) (conn)->m->send_query((conn), (query_str), (query_len) TSRMLS_CC) +#define mysqlnd_query(conn, query_str, query_len) ((conn)->data)->m->query((conn)->data, (query_str), (query_len) TSRMLS_CC) +#define mysqlnd_async_query(conn, query_str, query_len) ((conn)->data)->m->send_query((conn)->data, (query_str), (query_len) TSRMLS_CC) #define mysqlnd_poll(r, err, d_pull,sec,usec,desc_num) _mysqlnd_poll((r), (err), (d_pull), (sec), (usec), (desc_num) TSRMLS_CC) -#define mysqlnd_reap_async_query(conn) (conn)->m->reap_query((conn) TSRMLS_CC) +#define mysqlnd_reap_async_query(conn) ((conn)->data)->m->reap_query((conn)->data TSRMLS_CC) #define mysqlnd_unbuffered_skip_result(result) (result)->m.skip_result((result) TSRMLS_CC) PHPAPI enum_func_status _mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQLND ***dont_poll, long sec, long usec, uint * desc_num TSRMLS_DC); -#define mysqlnd_use_result(conn) (conn)->m->use_result((conn) TSRMLS_CC) -#define mysqlnd_store_result(conn) (conn)->m->store_result((conn) TSRMLS_CC) -#define mysqlnd_next_result(conn) (conn)->m->next_result((conn) TSRMLS_CC) -#define mysqlnd_more_results(conn) (conn)->m->more_results((conn) TSRMLS_CC) +#define mysqlnd_use_result(conn) ((conn)->data)->m->use_result((conn)->data TSRMLS_CC) +#define mysqlnd_store_result(conn) ((conn)->data)->m->store_result((conn)->data TSRMLS_CC) +#define mysqlnd_next_result(conn) ((conn)->data)->m->next_result((conn)->data TSRMLS_CC) +#define mysqlnd_more_results(conn) ((conn)->data)->m->more_results((conn)->data TSRMLS_CC) #define mysqlnd_free_result(r,e_or_i) ((MYSQLND_RES*)r)->m.free_result(((MYSQLND_RES*)(r)), (e_or_i) TSRMLS_CC) #define mysqlnd_data_seek(result, row) (result)->m.seek_data((result), (row) TSRMLS_CC) /* Errors */ -#define mysqlnd_errno(conn) (conn)->m->get_error_no((conn) TSRMLS_CC) -#define mysqlnd_error(conn) (conn)->m->get_error_str((conn) TSRMLS_CC) -#define mysqlnd_sqlstate(conn) (conn)->m->get_sqlstate((conn) TSRMLS_CC) +#define mysqlnd_errno(conn) ((conn)->data)->m->get_error_no((conn)->data TSRMLS_CC) +#define mysqlnd_error(conn) ((conn)->data)->m->get_error_str((conn)->data TSRMLS_CC) +#define mysqlnd_sqlstate(conn) ((conn)->data)->m->get_sqlstate((conn)->data TSRMLS_CC) /* Charset */ -#define mysqlnd_character_set_name(conn) (conn)->m->charset_name((conn) TSRMLS_CC) +#define mysqlnd_character_set_name(conn) ((conn)->data)->m->charset_name((conn)->data TSRMLS_CC) /* Simple metadata */ -#define mysqlnd_field_count(conn) (conn)->m->get_field_count((conn) TSRMLS_CC) -#define mysqlnd_insert_id(conn) (conn)->m->get_last_insert_id((conn) TSRMLS_CC) -#define mysqlnd_affected_rows(conn) (conn)->m->get_affected_rows((conn) TSRMLS_CC) -#define mysqlnd_warning_count(conn) (conn)->m->get_warning_count((conn) TSRMLS_CC) -#define mysqlnd_info(conn) (conn)->m->get_last_message((conn) TSRMLS_CC) -#define mysqlnd_get_server_info(conn) (conn)->m->get_server_information((conn) TSRMLS_CC) -#define mysqlnd_get_host_info(conn) (conn)->m->get_host_information((conn) TSRMLS_CC) -#define mysqlnd_get_proto_info(conn) (conn)->m->get_protocol_information((conn) TSRMLS_CC) -#define mysqlnd_thread_id(conn) (conn)->m->get_thread_id((conn) TSRMLS_CC) +#define mysqlnd_field_count(conn) ((conn)->data)->m->get_field_count((conn)->data TSRMLS_CC) +#define mysqlnd_insert_id(conn) ((conn)->data)->m->get_last_insert_id((conn)->data TSRMLS_CC) +#define mysqlnd_affected_rows(conn) ((conn)->data)->m->get_affected_rows((conn)->data TSRMLS_CC) +#define mysqlnd_warning_count(conn) ((conn)->data)->m->get_warning_count((conn)->data TSRMLS_CC) +#define mysqlnd_info(conn) ((conn)->data)->m->get_last_message((conn)->data TSRMLS_CC) +#define mysqlnd_get_server_info(conn) ((conn)->data)->m->get_server_information((conn)->data TSRMLS_CC) +#define mysqlnd_get_server_version(conn) ((conn)->data)->m->get_server_version((conn)->data TSRMLS_CC) +#define mysqlnd_get_host_info(conn) ((conn)->data)->m->get_host_information((conn)->data TSRMLS_CC) +#define mysqlnd_get_proto_info(conn) ((conn)->data)->m->get_protocol_information((conn)->data TSRMLS_CC) +#define mysqlnd_thread_id(conn) ((conn)->data)->m->get_thread_id((conn)->data TSRMLS_CC) +#define mysqlnd_get_server_status(conn) ((conn)->data)->m->get_server_status((conn)->data TSRMLS_CC) #define mysqlnd_num_rows(result) (result)->m.num_rows((result) TSRMLS_CC) #define mysqlnd_num_fields(result) (result)->m.num_fields((result) TSRMLS_CC) @@@ -163,7 -175,7 +163,7 @@@ PHPAPI unsigned long * _mysqlnd_fetch_l PHPAPI const char * mysqlnd_get_client_info(); PHPAPI unsigned int mysqlnd_get_client_version(); -#define mysqlnd_ssl_set(conn, key, cert, ca, capath, cipher) (conn)->m->ssl_set((conn), (key), (cert), (ca), (capath), (cipher) TSRMLS_CC) +#define mysqlnd_ssl_set(conn, key, cert, ca, capath, cipher) ((conn)->data)->m->ssl_set((conn)->data, (key), (cert), (ca), (capath), (cipher) TSRMLS_CC) /* PS */ #define mysqlnd_stmt_insert_id(stmt) (stmt)->m->get_last_insert_id((stmt) TSRMLS_CC) @@@ -187,39 -199,46 +187,39 @@@ PHPAPI void mysqlnd_free_result_bind_dt PHPAPI const char * mysqlnd_field_type_name(enum mysqlnd_field_types field_type); /* LOAD DATA LOCAL */ -PHPAPI void mysqlnd_local_infile_default(MYSQLND *conn); -PHPAPI void mysqlnd_set_local_infile_handler(MYSQLND * const conn, const char * const funcname); +PHPAPI void mysqlnd_local_infile_default(MYSQLND_CONN_DATA * conn); +PHPAPI void mysqlnd_set_local_infile_handler(MYSQLND_CONN_DATA * const conn, const char * const funcname); /* Simple commands */ -#ifdef AUTOCOMMIT_TX_COMMIT_ROLLBACK -#define mysqlnd_autocommit(conn, mode) (conn)->m->set_autocommit((conn), (mode) TSRMLS_CC) -#define mysqlnd_commit(conn) (conn)->m->tx_commit((conn) TSRMLS_CC) -#define mysqlnd_rollback(conn) (conn)->m->tx_rollback((conn) TSRMLS_CC) -#else -#define mysqlnd_autocommit(conn, mode) (conn)->m->query((conn),(mode) ? "SET AUTOCOMMIT=1":"SET AUTOCOMMIT=0", 16 TSRMLS_CC) -#define mysqlnd_commit(conn) (conn)->m->query((conn), "COMMIT", sizeof("COMMIT")-1 TSRMLS_CC) -#define mysqlnd_rollback(conn) (conn)->m->query((conn), "ROLLBACK", sizeof("ROLLBACK")-1 TSRMLS_CC) -#endif -#define mysqlnd_list_dbs(conn, wild) (conn)->m->list_method((conn), wild? "SHOW DATABASES LIKE %s":"SHOW DATABASES", (wild), NULL TSRMLS_CC) -#define mysqlnd_list_fields(conn, tab,wild) (conn)->m->list_fields((conn), (tab), (wild) TSRMLS_CC) -#define mysqlnd_list_processes(conn) (conn)->m->list_method((conn), "SHOW PROCESSLIST", NULL, NULL TSRMLS_CC) -#define mysqlnd_list_tables(conn, wild) (conn)->m->list_method((conn), wild? "SHOW TABLES LIKE %s":"SHOW TABLES", (wild), NULL TSRMLS_CC) -#define mysqlnd_dump_debug_info(conn) (conn)->m->server_dump_debug_information((conn) TSRMLS_CC) -#define mysqlnd_select_db(conn, db, db_len) (conn)->m->select_db((conn), (db), (db_len) TSRMLS_CC) -#define mysqlnd_ping(conn) (conn)->m->ping((conn) TSRMLS_CC) -#define mysqlnd_kill(conn, pid) (conn)->m->kill_connection((conn), (pid) TSRMLS_CC) -#define mysqlnd_refresh(conn, options) (conn)->m->refresh_server((conn), (options) TSRMLS_CC) -#define mysqlnd_shutdown(conn, level) (conn)->m->shutdown_server((conn), (level) TSRMLS_CC) -#define mysqlnd_get_server_version(conn) (conn)->m->get_server_version((conn) TSRMLS_CC) -#define mysqlnd_set_character_set(conn, cs) (conn)->m->set_charset((conn), (cs) TSRMLS_CC) -#define mysqlnd_stat(conn, msg, msg_len) (conn)->m->get_server_statistics((conn), (msg), (msg_len) TSRMLS_CC) -#define mysqlnd_options(conn, opt, value) (conn)->m->set_client_option((conn), (opt), (value) TSRMLS_CC) -#define mysqlnd_set_server_option(conn, op) (conn)->m->set_server_option((conn), (op) TSRMLS_CC) +#define mysqlnd_autocommit(conn, mode) ((conn)->data)->m->set_autocommit((conn)->data, (mode) TSRMLS_CC) +#define mysqlnd_commit(conn) ((conn)->data)->m->tx_commit((conn)->data TSRMLS_CC) +#define mysqlnd_rollback(conn) ((conn)->data)->m->tx_rollback((conn)->data TSRMLS_CC) +#define mysqlnd_list_dbs(conn, wild) ((conn)->data)->m->list_method((conn)->data, wild? "SHOW DATABASES LIKE %s":"SHOW DATABASES", (wild), NULL TSRMLS_CC) +#define mysqlnd_list_fields(conn, tab,wild) ((conn)->data)->m->list_fields((conn)->data, (tab), (wild) TSRMLS_CC) +#define mysqlnd_list_processes(conn) ((conn)->data)->m->list_method((conn)->data, "SHOW PROCESSLIST", NULL, NULL TSRMLS_CC) +#define mysqlnd_list_tables(conn, wild) ((conn)->data)->m->list_method((conn)->data, wild? "SHOW TABLES LIKE %s":"SHOW TABLES", (wild), NULL TSRMLS_CC) +#define mysqlnd_dump_debug_info(conn) ((conn)->data)->m->server_dump_debug_information((conn)->data TSRMLS_CC) +#define mysqlnd_select_db(conn, db, db_len) ((conn)->data)->m->select_db((conn)->data, (db), (db_len) TSRMLS_CC) +#define mysqlnd_ping(conn) ((conn)->data)->m->ping((conn)->data TSRMLS_CC) +#define mysqlnd_kill(conn, pid) ((conn)->data)->m->kill_connection((conn)->data, (pid) TSRMLS_CC) +#define mysqlnd_refresh(conn, options) ((conn)->data)->m->refresh_server((conn)->data, (options) TSRMLS_CC) +#define mysqlnd_shutdown(conn, level) ((conn)->data)->m->shutdown_server((conn)->data, (level) TSRMLS_CC) +#define mysqlnd_set_character_set(conn, cs) ((conn)->data)->m->set_charset((conn)->data, (cs) TSRMLS_CC) +#define mysqlnd_stat(conn, msg, msg_len) ((conn)->data)->m->get_server_statistics(((conn)->data), (msg), (msg_len) TSRMLS_CC) +#define mysqlnd_options(conn, opt, value) ((conn)->data)->m->set_client_option((conn)->data, (opt), (value) TSRMLS_CC) +#define mysqlnd_set_server_option(conn, op) ((conn)->data)->m->set_server_option((conn)->data, (op) TSRMLS_CC) /* Escaping */ #define mysqlnd_real_escape_string(conn, newstr, escapestr, escapestr_len) \ - (conn)->m->escape_string((conn), (newstr), (escapestr), (escapestr_len) TSRMLS_CC) + ((conn)->data)->m->escape_string((conn)->data, (newstr), (escapestr), (escapestr_len) TSRMLS_CC) #define mysqlnd_escape_string(newstr, escapestr, escapestr_len) \ mysqlnd_old_escape_string((newstr), (escapestr), (escapestr_len) TSRMLS_CC) -PHPAPI ulong mysqlnd_old_escape_string(char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC); +PHPAPI ulong mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len TSRMLS_DC); /* PS */ -#define mysqlnd_stmt_init(conn) (conn)->m->stmt_init((conn) TSRMLS_CC) +#define mysqlnd_stmt_init(conn) ((conn)->data)->m->stmt_init(((conn)->data) TSRMLS_CC) #define mysqlnd_stmt_store_result(stmt) (!mysqlnd_stmt_field_count((stmt)) ? PASS:((stmt)->m->store_result((stmt) TSRMLS_CC)? PASS:FAIL)) #define mysqlnd_stmt_get_result(stmt) (stmt)->m->get_result((stmt) TSRMLS_CC) #define mysqlnd_stmt_more_results(stmt) (stmt)->m->more_results((stmt) TSRMLS_CC) @@@ -243,7 -262,6 +243,7 @@@ #define mysqlnd_stmt_free_result(stmt) (stmt)->m->free_result((stmt) TSRMLS_CC) #define mysqlnd_stmt_close(stmt, implicit) (stmt)->m->dtor((stmt), (implicit) TSRMLS_CC) #define mysqlnd_stmt_reset(stmt) (stmt)->m->reset((stmt) TSRMLS_CC) +#define mysqlnd_stmt_flush(stmt) (stmt)->m->flush((stmt) TSRMLS_CC) #define mysqlnd_stmt_attr_get(stmt, attr, value) (stmt)->m->get_attribute((stmt), (attr), (value) TSRMLS_CC) diff --combined ext/phar/phar.c index d9d9b08,d8eaad1..2a47d3d --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@@ -1738,30 -1738,31 +1738,30 @@@ static int phar_open_from_fp(php_stream static int phar_analyze_path(const char *fname, const char *ext, int ext_len, int for_create TSRMLS_DC) /* {{{ */ { php_stream_statbuf ssb; - char *realpath, old, *a = (char *)(ext + ext_len); + char *realpath; + char *filename = estrndup(fname, (ext - fname) + ext_len); - old = *a; - *a = '\0'; - - if ((realpath = expand_filepath(fname, NULL TSRMLS_CC))) { + if ((realpath = expand_filepath(filename, NULL TSRMLS_CC))) { #ifdef PHP_WIN32 phar_unixify_path_separators(realpath, strlen(realpath)); #endif if (zend_hash_exists(&(PHAR_GLOBALS->phar_fname_map), realpath, strlen(realpath))) { - *a = old; efree(realpath); + efree(filename); return SUCCESS; } if (PHAR_G(manifest_cached) && zend_hash_exists(&cached_phars, realpath, strlen(realpath))) { - *a = old; efree(realpath); + efree(filename); return SUCCESS; } efree(realpath); } - if (SUCCESS == php_stream_stat_path((char *) fname, &ssb)) { - *a = old; + if (SUCCESS == php_stream_stat_path((char *) filename, &ssb)) { + + efree(filename); if (ssb.sb.st_mode & S_IFDIR) { return FAILURE; @@@ -1776,56 -1777,57 +1776,56 @@@ char *slash; if (!for_create) { - *a = old; + efree(filename); return FAILURE; } - slash = (char *) strrchr(fname, '/'); - *a = old; + slash = (char *) strrchr(filename, '/'); if (slash) { *slash = '\0'; } - if (SUCCESS != php_stream_stat_path((char *) fname, &ssb)) { - if (slash) { - *slash = old; - } else { - if (!(realpath = expand_filepath(fname, NULL TSRMLS_CC))) { + if (SUCCESS != php_stream_stat_path((char *) filename, &ssb)) { + if (!slash) { + if (!(realpath = expand_filepath(filename, NULL TSRMLS_CC))) { + efree(filename); return FAILURE; } #ifdef PHP_WIN32 phar_unixify_path_separators(realpath, strlen(realpath)); #endif - a = strstr(realpath, fname) + ((ext - fname) + ext_len); - *a = '\0'; + slash = strstr(realpath, filename) + ((ext - fname) + ext_len); + *slash = '\0'; slash = strrchr(realpath, '/'); if (slash) { *slash = '\0'; } else { efree(realpath); + efree(filename); return FAILURE; } if (SUCCESS != php_stream_stat_path(realpath, &ssb)) { efree(realpath); + efree(filename); return FAILURE; } efree(realpath); if (ssb.sb.st_mode & S_IFDIR) { + efree(filename); return SUCCESS; } } + efree(filename); return FAILURE; } - if (slash) { - *slash = old; - } + efree(filename); if (ssb.sb.st_mode & S_IFDIR) { return SUCCESS; @@@ -2333,7 -2335,7 +2333,7 @@@ int phar_open_executed_filename(char *a *error = NULL; } - fname = zend_get_executed_filename(TSRMLS_C); + fname = (char*)zend_get_executed_filename(TSRMLS_C); fname_len = strlen(fname); if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, 0, REPORT_ERRORS, NULL, 0 TSRMLS_CC) == SUCCESS) { @@@ -3338,7 -3340,7 +3338,7 @@@ static zend_op_array *phar_compile_file return phar_orig_compile_file(file_handle, type TSRMLS_CC); } if (strstr(file_handle->filename, ".phar") && !strstr(file_handle->filename, "://")) { - if (SUCCESS == phar_open_from_filename(file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL TSRMLS_CC)) { + if (SUCCESS == phar_open_from_filename((char*)file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL TSRMLS_CC)) { if (phar->is_zip || phar->is_tar) { zend_file_handle f = *file_handle; @@@ -3419,7 -3421,7 +3419,7 @@@ int phar_zend_open(const char *filename char *fname; int fname_len; - fname = zend_get_executed_filename(TSRMLS_C); + fname = (char*)zend_get_executed_filename(TSRMLS_C); fname_len = strlen(fname); if (fname_len > 7 && !strncasecmp(fname, "phar://", 7)) { @@@ -3667,7 -3669,7 +3667,7 @@@ PHP_MINFO_FUNCTION(phar) /* {{{ * php_info_print_table_header(2, "Phar: PHP Archive support", "enabled"); php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION); php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION); - php_info_print_table_row(2, "SVN revision", "$Revision$"); + php_info_print_table_row(2, "SVN revision", "$Id$"); php_info_print_table_row(2, "Phar-based phar archives", "enabled"); php_info_print_table_row(2, "Tar-based phar archives", "enabled"); php_info_print_table_row(2, "ZIP-based phar archives", "enabled"); diff --combined ext/posix/posix.c index 8e49c52,c00b746..967584c --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@@ -310,7 -310,7 +310,7 @@@ const zend_function_entry posix_functio static PHP_MINFO_FUNCTION(posix) { php_info_print_table_start(); - php_info_print_table_row(2, "Revision", "$Revision$"); + php_info_print_table_row(2, "Revision", "$Id$"); php_info_print_table_end(); } /* }}} */ @@@ -838,11 -838,16 +838,11 @@@ PHP_FUNCTION(posix_mkfifo long mode; int result; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &path, &path_len, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pl", &path, &path_len, &mode) == FAILURE) { RETURN_FALSE; } - if (strlen(path) != path_len) { - RETURN_FALSE; - } - - if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) || - (PG(safe_mode) && (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_DIR)))) { + if (php_check_open_basedir_ex(path, 0 TSRMLS_CC)) { RETURN_FALSE; } @@@ -871,12 -876,17 +871,12 @@@ PHP_FUNCTION(posix_mknod php_dev = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|ll", &path, &path_len, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pl|ll", &path, &path_len, &mode, &major, &minor) == FAILURE) { RETURN_FALSE; } - if (strlen(path) != path_len) { - RETURN_FALSE; - } - - if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) || - (PG(safe_mode) && (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_DIR)))) { + if (php_check_open_basedir_ex(path, 0 TSRMLS_CC)) { RETURN_FALSE; } @@@ -951,7 -961,11 +951,7 @@@ PHP_FUNCTION(posix_access int filename_len, ret; char *filename, *path; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, &filename_len, &mode) == FAILURE) { - RETURN_FALSE; - } - - if (strlen(filename) != filename_len) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &filename, &filename_len, &mode) == FAILURE) { RETURN_FALSE; } @@@ -961,7 -975,8 +961,7 @@@ RETURN_FALSE; } - if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) || - (PG(safe_mode) && (!php_checkuid_ex(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR, CHECKUID_NO_ERRORS)))) { + if (php_check_open_basedir_ex(path, 0 TSRMLS_CC)) { efree(path); POSIX_G(last_error) = EPERM; RETURN_FALSE; diff --combined ext/reflection/php_reflection.c index 28184e1,522fef1..1cf65ce --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@@ -39,16 -39,11 +39,16 @@@ #include "zend_ini.h" #include "zend_interfaces.h" #include "zend_closures.h" +#include "zend_extensions.h" -/* Undefine "getParameters" macro defined in "main/php3_compat.h" */ -#ifdef getParameters -# undef getParameters -#endif +#define reflection_update_property(object, name, value) do { \ + zval *member; \ + MAKE_STD_ZVAL(member); \ + ZVAL_STRINGL(member, name, sizeof(name)-1, 1); \ + zend_std_write_property(object, member, value, NULL TSRMLS_CC); \ + Z_DELREF_P(value); \ + zval_ptr_dtor(&member); \ + } while (0) /* Class entry pointers */ PHPAPI zend_class_entry *reflector_ptr; @@@ -62,7 -57,6 +62,7 @@@ PHPAPI zend_class_entry *reflection_obj PHPAPI zend_class_entry *reflection_method_ptr; PHPAPI zend_class_entry *reflection_property_ptr; PHPAPI zend_class_entry *reflection_extension_ptr; +PHPAPI zend_class_entry *reflection_zend_extension_ptr; #if MBO_0 ZEND_BEGIN_MODULE_GLOBALS(reflection) @@@ -125,7 -119,7 +125,7 @@@ static void string_init(string *str str->alloced = 1024; *str->string = '\0'; } - + static string *string_printf(string *str, const char *format, ...) { int len; @@@ -178,8 -172,6 +178,8 @@@ static void string_free(string *str } /* }}} */ +/* {{{ Object structure */ + /* Struct for properties */ typedef struct _property_reference { zend_class_entry *ce; @@@ -212,11 -204,9 +212,11 @@@ typedef struct unsigned int ignore_visibility:1; } reflection_object; +/* }}} */ + static zend_object_handlers reflection_object_handlers; -static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) +static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) /* {{{ */ { zval **value; @@@ -226,7 -216,6 +226,7 @@@ MAKE_COPY_ZVAL(value, return_value); } +/* }}} */ #ifdef ilia_0 static void _default_lookup_entry(zval *object, char *name, int name_len, zval **return_value TSRMLS_DC) /* {{{ */ @@@ -242,14 -231,13 +242,14 @@@ /* }}} */ #endif -static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) +static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) /* {{{ */ { zend_uint num_interfaces = ++class_entry->num_interfaces; class_entry->interfaces = (zend_class_entry **) realloc(class_entry->interfaces, sizeof(zend_class_entry *) * num_interfaces); class_entry->interfaces[num_interfaces - 1] = interface_entry; } +/* }}} */ static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */ { @@@ -275,13 -263,13 +275,13 @@@ static void _free_function(zend_functio && fptr->type == ZEND_INTERNAL_FUNCTION && (fptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) { - efree(fptr->internal_function.function_name); + efree((char*)fptr->internal_function.function_name); efree(fptr); } } /* }}} */ -static void reflection_free_objects_storage(void *object TSRMLS_DC) +static void reflection_free_objects_storage(void *object TSRMLS_DC) /* {{{ */ { reflection_object *intern = (reflection_object *) object; parameter_reference *reference; @@@ -302,7 -290,7 +302,7 @@@ break; case REF_TYPE_DYNAMIC_PROPERTY: prop_reference = (property_reference*)intern->ptr; - efree(prop_reference->prop.name); + efree((char*)prop_reference->prop.name); efree(intern->ptr); break; case REF_TYPE_OTHER: @@@ -315,10 -303,10 +315,10 @@@ } zend_objects_free_object_storage(object TSRMLS_CC); } +/* }}} */ -static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) +static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { - zval tmp; zend_object_value retval; reflection_object *intern; @@@ -326,14 -314,13 +326,14 @@@ intern->zo.ce = class_type; zend_object_std_init(&intern->zo, class_type TSRMLS_CC); - zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + object_properties_init(&intern->zo, class_type); retval.handle = zend_objects_store_put(intern, NULL, reflection_free_objects_storage, NULL TSRMLS_CC); retval.handlers = &reflection_object_handlers; return retval; } +/* }}} */ -static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) +static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) /* {{{ */ { if (!object) { ALLOC_ZVAL(object); @@@ -344,44 -331,36 +344,44 @@@ Z_SET_ISREF_P(object); return object; } +/* }}} */ static void _const_string(string *str, char *name, zval *value, char *indent TSRMLS_DC); -static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char *indent TSRMLS_DC); +static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char* indent TSRMLS_DC); static void _property_string(string *str, zend_property_info *prop, char *prop_name, char* indent TSRMLS_DC); static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *indent TSRMLS_DC); static void _extension_string(string *str, zend_module_entry *module, char *indent TSRMLS_DC); +static void _zend_extension_string(string *str, zend_extension *extension, char *indent TSRMLS_DC); /* {{{ _class_string */ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *indent TSRMLS_DC) { int count, count_static_props = 0, count_static_funcs = 0, count_shadow_props = 0; string sub_indent; - + string_init(&sub_indent); string_printf(&sub_indent, "%s ", indent); /* TBD: Repair indenting of doc comment (or is this to be done in the parser?) */ - if (ce->type == ZEND_USER_CLASS && ce->doc_comment) { - string_printf(str, "%s%s", indent, ce->doc_comment); + if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) { + string_printf(str, "%s%s", indent, ce->info.user.doc_comment); string_write(str, "\n", 1); } if (obj) { string_printf(str, "%sObject of class [ ", indent); } else { - string_printf(str, "%s%s [ ", indent, (ce->ce_flags & ZEND_ACC_INTERFACE) ? "Interface" : "Class"); + char *kind = "Class"; + if (ce->ce_flags & ZEND_ACC_INTERFACE) { + kind = "Interface"; + } else if ((ce->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { + kind = "Trait"; + } + string_printf(str, "%s%s [ ", indent, kind); } string_printf(str, (ce->type == ZEND_USER_CLASS) ? "<user" : "<internal"); - if (ce->module) { - string_printf(str, ":%s", ce->module->name); + if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module) { + string_printf(str, ":%s", ce->info.internal.module->name); } string_printf(str, "> "); if (ce->get_iterator != NULL) { @@@ -389,15 -368,13 +389,15 @@@ } if (ce->ce_flags & ZEND_ACC_INTERFACE) { string_printf(str, "interface "); + } else if ((ce->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { + string_printf(str, "trait "); } else { if (ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { string_printf(str, "abstract "); } if (ce->ce_flags & ZEND_ACC_FINAL_CLASS) { string_printf(str, "final "); - } + } string_printf(str, "class "); } string_printf(str, "%s", ce->name); @@@ -421,8 -398,8 +421,8 @@@ /* The information where a class is declared is only available for user classes */ if (ce->type == ZEND_USER_CLASS) { - string_printf(str, "%s @@ %s %d-%d\n", indent, ce->filename, - ce->line_start, ce->line_end); + string_printf(str, "%s @@ %s %d-%d\n", indent, ce->info.user.filename, + ce->info.user.line_start, ce->info.user.line_end); } /* Constants */ @@@ -452,7 -429,7 +452,7 @@@ /* Static properties */ if (&ce->properties_info) { - /* counting static properties */ + /* counting static properties */ count = zend_hash_num_elements(&ce->properties_info); if (count > 0) { HashPosition pos; @@@ -470,7 -447,7 +470,7 @@@ } } - /* static properties */ + /* static properties */ string_printf(str, "\n%s - Static properties [%d] {\n", indent, count_static_props); if (count_static_props > 0) { HashPosition pos; @@@ -488,10 -465,10 +488,10 @@@ } string_printf(str, "%s }\n", indent); } - + /* Static methods */ if (&ce->function_table) { - /* counting static methods */ + /* counting static methods */ count = zend_hash_num_elements(&ce->function_table); if (count > 0) { HashPosition pos; @@@ -509,7 -486,7 +509,7 @@@ } } - /* static methods */ + /* static methods */ string_printf(str, "\n%s - Static methods [%d] {", indent, count_static_funcs); if (count_static_funcs > 0) { HashPosition pos; @@@ -573,7 -550,7 +573,7 @@@ if (prop_name_size && prop_name[0]) { /* skip all private and protected properties */ if (!zend_hash_quick_exists(&ce->properties_info, prop_name, prop_name_size, zend_get_hash_value(prop_name, prop_name_size))) { count++; - _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC); + _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC); } } efree(prop_name); @@@ -644,7 -621,7 +644,7 @@@ } string_printf(str, "%s }\n", indent); } - + string_printf(str, "%s}\n", indent); string_free(&sub_indent); } @@@ -682,7 -659,7 +682,7 @@@ static zend_op* _get_recv_op(zend_op_ar ++offset; while (op < end) { if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT) - && op->op1.u.constant.value.lval == (long)offset) + && op->op1.num == (long)offset) { return op; } @@@ -706,8 -683,8 +706,8 @@@ static void _parameter_string(string *s if (arg_info->allow_null) { string_printf(str, "or NULL "); } - } else if (arg_info->array_type_hint) { - string_printf(str, "array "); + } else if (arg_info->type_hint) { + string_printf(str, "%s ", zend_get_type_by_const(arg_info->type_hint)); if (arg_info->allow_null) { string_printf(str, "or NULL "); } @@@ -722,12 -699,12 +722,12 @@@ } if (fptr->type == ZEND_USER_FUNCTION && offset >= required) { zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset); - if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2.op_type != IS_UNUSED) { + if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) { zval *zv, zv_copy; int use_copy; string_write(str, " = ", sizeof(" = ")-1); ALLOC_ZVAL(zv); - *zv = precv->op2.u.constant; + *zv = *precv->op2.zv; zval_copy_ctor(zv); INIT_PZVAL(zv); zval_update_constant_ex(&zv, (void*)1, fptr->common.scope TSRMLS_CC); @@@ -746,8 -723,6 +746,8 @@@ string_write(str, "...", sizeof("...")-1); } string_write(str, "'", sizeof("'")-1); + } else if (Z_TYPE_P(zv) == IS_ARRAY) { + string_write(str, "Array", sizeof("Array")-1); } else { zend_make_printable_zval(zv, &zv_copy, &use_copy); string_write(str, Z_STRVAL(zv_copy), Z_STRLEN(zv_copy)); @@@ -827,7 -802,7 +827,7 @@@ static void _function_string(string *st unsigned int lc_name_len; /* TBD: Repair indenting of doc comment (or is this to be done in the parser?) - * What's "wrong" is that any whitespace before the doc comment start is + * What's "wrong" is that any whitespace before the doc comment start is * swallowed, leading to an unaligned comment. */ if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) { @@@ -900,13 -875,13 +900,13 @@@ string_printf(str, "function "); } - if (fptr->op_array.return_reference) { + if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) { string_printf(str, "&"); } string_printf(str, "%s ] {\n", fptr->common.function_name); /* The information where a function is declared is only available for user classes */ if (fptr->type == ZEND_USER_FUNCTION) { - string_printf(str, "%s @@ %s %d - %d\n", indent, + string_printf(str, "%s @@ %s %d - %d\n", indent, fptr->op_array.filename, fptr->op_array.line_start, fptr->op_array.line_end); @@@ -925,7 -900,7 +925,7 @@@ /* {{{ _property_string */ static void _property_string(string *str, zend_property_info *prop, char *prop_name, char* indent TSRMLS_DC) { - char *class_name; + const char *class_name; string_printf(str, "%sProperty [ ", indent); if (!prop) { @@@ -938,7 -913,7 +938,7 @@@ string_write(str, "<default> ", sizeof("<default> ") - 1); } } - + /* These are mutually exclusive */ switch (prop->flags & ZEND_ACC_PPP_MASK) { case ZEND_ACC_PUBLIC: @@@ -955,7 -930,7 +955,7 @@@ string_printf(str, "static "); } - zend_unmangle_property_name(prop->name, prop->name_length, &class_name, &prop_name); + zend_unmangle_property_name(prop->name, prop->name_length, &class_name, (const char**)&prop_name); string_printf(str, "$%s", prop_name); } @@@ -963,7 -938,7 +963,7 @@@ } /* }}} */ -static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@@ -997,25 -972,23 +997,25 @@@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ -static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*); int *num_classes = va_arg(args, int*); - if ((*pce)->module && !strcasecmp((*pce)->module->name, module->name)) { + if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) { string_printf(str, "\n"); _class_string(str, *pce, NULL, indent TSRMLS_CC); (*num_classes)++; } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ -static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@@ -1028,7 -1001,6 +1028,7 @@@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ /* {{{ _extension_string */ static void _extension_string(string *str, zend_module_entry *module, char *indent TSRMLS_DC) @@@ -1051,7 -1023,7 +1051,7 @@@ while(dep->name) { string_printf(str, "%s Dependency [ %s (", indent, dep->name); - + switch(dep->type) { case MODULE_DEP_REQUIRED: string_write(str, "Required", sizeof("Required") - 1); @@@ -1067,10 -1039,10 +1067,10 @@@ break; } - if (dep->rel) { + if (dep->rel) { string_printf(str, " %s", dep->rel); } - if (dep->version) { + if (dep->version) { string_printf(str, " %s", dep->version); } string_write(str, ") ]\n", sizeof(") ]\n") - 1); @@@ -1094,7 -1066,7 +1094,7 @@@ { string str_constants; int num_constants = 0; - + string_init(&str_constants); zend_hash_apply_with_arguments(EG(zend_constants) TSRMLS_CC, (apply_func_args_t) _extension_const_string, 4, &str_constants, indent, module, &num_constants); if (num_constants) { @@@ -1115,26 -1087,26 +1115,26 @@@ while (func->fname) { int fname_len = strlen(func->fname); char *lc_name = zend_str_tolower_dup(func->fname, fname_len); - - if (zend_hash_find(EG(function_table), lc_name, fname_len+1, (void**) &fptr) == FAILURE) { + + if (zend_hash_find(EG(function_table), lc_name, fname_len + 1, (void**) &fptr) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal error: Cannot find extension function %s in global function table", func->fname); func++; efree(lc_name); continue; } - + _function_string(str, fptr, NULL, " " TSRMLS_CC); efree(lc_name); func++; } string_printf(str, "%s }\n", indent); } - + { string str_classes; string sub_indent; int num_classes = 0; - + string_init(&sub_indent); string_printf(&sub_indent, "%s ", indent); string_init(&str_classes); @@@ -1152,27 -1124,6 +1152,27 @@@ } /* }}} */ +static void _zend_extension_string(string *str, zend_extension *extension, char *indent TSRMLS_DC) /* {{{ */ +{ + string_printf(str, "%sZend Extension [ %s ", indent, extension->name); + + if (extension->version) { + string_printf(str, "%s ", extension->version); + } + if (extension->copyright) { + string_printf(str, "%s ", extension->copyright); + } + if (extension->author) { + string_printf(str, "by %s ", extension->author); + } + if (extension->URL) { + string_printf(str, "<%s> ", extension->URL); + } + + string_printf(str, "]\n"); +} +/* }}} */ + /* {{{ _function_check_flag */ static void _function_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) { @@@ -1200,7 -1151,7 +1200,7 @@@ PHPAPI void zend_reflection_class_facto intern->ptr = ce; intern->ref_type = REF_TYPE_OTHER; intern->ce = ce; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); } /* }}} */ @@@ -1229,7 -1180,7 +1229,7 @@@ static void reflection_extension_factor intern->ptr = module; intern->ref_type = REF_TYPE_OTHER; intern->ce = NULL; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); } /* }}} */ @@@ -1260,7 -1211,7 +1260,7 @@@ static void reflection_parameter_factor intern->ref_type = REF_TYPE_PARAMETER; intern->ce = fptr->common.scope; intern->obj = closure_object; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); } /* }}} */ @@@ -1282,7 -1233,7 +1282,7 @@@ static void reflection_function_factory intern->ref_type = REF_TYPE_FUNCTION; intern->ce = NULL; intern->obj = closure_object; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); } /* }}} */ @@@ -1306,8 -1257,8 +1306,8 @@@ static void reflection_method_factory(z intern->ref_type = REF_TYPE_FUNCTION; intern->ce = ce; intern->obj = closure_object; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); - zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); + reflection_update_property(object, "class", classname); } /* }}} */ @@@ -1318,7 -1269,7 +1318,7 @@@ static void reflection_property_factory zval *name; zval *classname; property_reference *reference; - char *class_name, *prop_name; + const char *class_name, *prop_name; zend_unmangle_property_name(prop->name, prop->name_length, &class_name, &prop_name); @@@ -1353,8 -1304,8 +1353,8 @@@ intern->ref_type = REF_TYPE_PROPERTY; intern->ce = ce; intern->ignore_visibility = 0; - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); - zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); + reflection_update_property(object, "class", classname); } /* }}} */ @@@ -1410,7 -1361,7 +1410,7 @@@ static void _reflection_export(INTERNAL fcc.object_ptr = reflector_ptr; result = zend_call_function(&fci, &fcc TSRMLS_CC); - + if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } @@@ -1585,10 -1536,10 +1585,10 @@@ ZEND_METHOD(reflection_function, __cons nsname = &lcname[1]; name_len--; } - + if (zend_hash_find(EG(function_table), nsname, name_len + 1, (void **)&fptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Function %s() does not exist", name_str); return; } @@@ -1599,7 -1550,7 +1599,7 @@@ MAKE_STD_ZVAL(name); ZVAL_STRING(name, fptr->common.function_name, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); intern->ptr = fptr; intern->ref_type = REF_TYPE_FUNCTION; intern->obj = closure; @@@ -1651,65 -1602,6 +1651,65 @@@ ZEND_METHOD(reflection_function, isClos } /* }}} */ +/* {{{ proto public bool ReflectionFunction::getClosureThis() + Returns this pointer bound to closure */ +ZEND_METHOD(reflection_function, getClosureThis) +{ + reflection_object *intern; + zend_function *fptr; + zval* closure_this; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(fptr); + if (intern->obj) { + closure_this = zend_get_closure_this_ptr(intern->obj TSRMLS_CC); + if (closure_this) { + RETURN_ZVAL(closure_this, 1, 0); + } + } +} +/* }}} */ + +/* {{{ proto public ReflectionClass ReflectionFunction::getClosureScopeClass() + Returns the scope associated to the closure */ +ZEND_METHOD(reflection_function, getClosureScopeClass) +{ + reflection_object *intern; + zend_function *fptr; + const zend_function *closure_func; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(fptr); + if (intern->obj) { + closure_func = zend_get_closure_method_def(intern->obj TSRMLS_CC); + if (closure_func && closure_func->common.scope) { + zend_reflection_class_factory(closure_func->common.scope, return_value TSRMLS_CC); + } + } +} +/* }}} */ + +/* {{{ proto public mixed ReflectionFunction::getClosure() + Returns a dynamically created closure for the function */ +ZEND_METHOD(reflection_function, getClosure) +{ + reflection_object *intern; + zend_function *fptr; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(fptr); + + zend_create_closure(return_value, fptr, NULL, NULL TSRMLS_CC); +} +/* }}} */ + + /* {{{ proto public bool ReflectionFunction::isInternal() Returns whether this is an internal function */ ZEND_METHOD(reflection_function, isInternal) @@@ -1832,7 -1724,7 +1832,7 @@@ ZEND_METHOD(reflection_function, getSta zval *tmp_copy; reflection_object *intern; zend_function *fptr; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -1858,7 -1750,7 +1858,7 @@@ ZEND_METHOD(reflection_function, invoke zend_fcall_info_cache fcc; reflection_object *intern; zend_function *fptr; - + METHOD_NOTSTATIC(reflection_function_ptr); GET_REFLECTION_OBJECT_PTR(fptr); @@@ -1889,7 -1781,7 +1889,7 @@@ } if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of function %s() failed", fptr->common.function_name); return; } @@@ -1919,7 -1811,7 +1919,7 @@@ ZEND_METHOD(reflection_function, invoke reflection_object *intern; zend_function *fptr; zval *param_array; - + METHOD_NOTSTATIC(reflection_function_ptr); GET_REFLECTION_OBJECT_PTR(fptr); @@@ -1928,9 -1820,9 +1928,9 @@@ } argc = zend_hash_num_elements(Z_ARRVAL_P(param_array)); - + params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); params -= argc; fci.size = sizeof(fci); @@@ -1954,7 -1846,7 +1954,7 @@@ efree(params); if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of function %s() failed", fptr->common.function_name); return; } @@@ -1975,7 -1867,7 +1975,7 @@@ ZEND_METHOD(reflection_function, return METHOD_NOTSTATIC(reflection_function_abstract_ptr); GET_REFLECTION_OBJECT_PTR(fptr); - RETURN_BOOL(fptr->op_array.return_reference); + RETURN_BOOL((fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0); } /* }}} */ @@@ -2023,7 -1915,7 +2023,7 @@@ ZEND_METHOD(reflection_function, getPar array_init(return_value); for (i = 0; i < fptr->common.num_args; i++) { - zval *parameter; + zval *parameter; ALLOC_ZVAL(parameter); reflection_parameter_factory(_copy_function(fptr TSRMLS_CC), intern->obj, arg_info, i, fptr->common.required_num_args, parameter TSRMLS_CC); @@@ -2114,7 -2006,7 +2114,7 @@@ ZEND_METHOD(reflection_parameter, __con if (intern == NULL) { return; } - + /* First, find the function */ switch (Z_TYPE_P(reference)) { case IS_STRING: { @@@ -2125,7 -2017,7 +2125,7 @@@ lcname = zend_str_tolower_dup(Z_STRVAL_P(reference), lcname_len); if (zend_hash_find(EG(function_table), lcname, lcname_len + 1, (void**) &fptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Function %s() does not exist", Z_STRVAL_P(reference)); return; } @@@ -2140,7 -2032,7 +2140,7 @@@ zend_class_entry **pce; unsigned int lcname_len; char *lcname; - + if ((zend_hash_index_find(Z_ARRVAL_P(reference), 0, (void **) &classref) == FAILURE) || (zend_hash_index_find(Z_ARRVAL_P(reference), 1, (void **) &method) == FAILURE)) { @@@ -2159,7 -2051,7 +2159,7 @@@ } ce = *pce; } - + convert_to_string_ex(method); lcname_len = Z_STRLEN_PP(method); lcname = zend_str_tolower_dup(Z_STRVAL_PP(method), lcname_len); @@@ -2168,21 -2060,21 +2168,21 @@@ && memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 && (fptr = zend_get_closure_invoke_method(*classref TSRMLS_CC)) != NULL) { - /* nothign to do. don't set is_closure since is the invoke handler, - not the closure itself */ + /* nothing to do. don't set is_closure since is the invoke handler, +- not the closure itself */ } else if (zend_hash_find(&ce->function_table, lcname, lcname_len + 1, (void **) &fptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s::%s() does not exist", ce->name, Z_STRVAL_PP(method)); return; } efree(lcname); } break; - + case IS_OBJECT: { ce = Z_OBJCE_P(reference); - + if (instanceof_function(ce, zend_ce_closure TSRMLS_CC)) { fptr = (zend_function *)zend_get_closure_method_def(reference TSRMLS_CC); Z_ADDREF_P(reference); @@@ -2194,12 -2086,12 +2194,12 @@@ } } break; - + default: _DO_THROW("The parameter class is expected to be either a string, an array(class, method) or a callable object"); /* returns out of this function */ } - + /* Now, search for the parameter */ arg_info = fptr->common.arg_info; if (Z_TYPE_PP(parameter) == IS_LONG) { @@@ -2207,7 -2099,7 +2207,7 @@@ if (position < 0 || (zend_uint)position >= fptr->common.num_args) { if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) { if (fptr->type != ZEND_OVERLOADED_FUNCTION) { - efree(fptr->common.function_name); + efree((char*)fptr->common.function_name); } efree(fptr); } @@@ -2231,7 -2123,7 +2231,7 @@@ if (position == -1) { if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) { if (fptr->type != ZEND_OVERLOADED_FUNCTION) { - efree(fptr->common.function_name); + efree((char*)fptr->common.function_name); } efree(fptr); } @@@ -2242,14 -2134,14 +2242,14 @@@ /* returns out of this function */ } } - + MAKE_STD_ZVAL(name); if (arg_info[position].name) { ZVAL_STRINGL(name, arg_info[position].name, arg_info[position].name_len, 1); } else { ZVAL_NULL(name); } - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); ref = (parameter_reference*) emalloc(sizeof(parameter_reference)); ref->arg_info = &arg_info[position]; @@@ -2329,7 -2221,7 +2329,7 @@@ ZEND_METHOD(reflection_parameter, getDe if (param->fptr->common.scope) { zend_reflection_class_factory(param->fptr->common.scope, return_value TSRMLS_CC); - } + } } /* }}} */ @@@ -2359,29 -2251,29 +2359,29 @@@ ZEND_METHOD(reflection_parameter, getCl * TODO: Think about moving these checks to the compiler or some sort of * lint-mode. */ - if (0 == strncmp(param->arg_info->class_name, "self", sizeof("self")- 1)) { + if (0 == zend_binary_strcasecmp(param->arg_info->class_name, param->arg_info->class_name_len, "self", sizeof("self")- 1)) { ce = param->fptr->common.scope; if (!ce) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter uses 'self' as type hint but function is not a class member!"); return; } pce= &ce; - } else if (0 == strncmp(param->arg_info->class_name, "parent", sizeof("parent")- 1)) { + } else if (0 == zend_binary_strcasecmp(param->arg_info->class_name, param->arg_info->class_name_len, "parent", sizeof("parent")- 1)) { ce = param->fptr->common.scope; if (!ce) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter uses 'parent' as type hint but function is not a class member!"); return; } if (!ce->parent) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter uses 'parent' as type hint although class does not have a parent!"); return; } pce= &ce->parent; } else if (zend_lookup_class(param->arg_info->class_name, param->arg_info->class_name_len, &pce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not exist", param->arg_info->class_name); return; } @@@ -2402,23 -2294,7 +2402,23 @@@ ZEND_METHOD(reflection_parameter, isArr } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(param->arg_info->array_type_hint); + RETVAL_BOOL(param->arg_info->type_hint == IS_ARRAY); +} +/* }}} */ + +/* {{{ proto public bool ReflectionParameter::isCallable() + Returns whether parameter MUST be callable */ +ZEND_METHOD(reflection_parameter, isCallable) +{ + reflection_object *intern; + parameter_reference *param; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(param); + + RETVAL_BOOL(param->arg_info->type_hint == IS_CALLABLE); } /* }}} */ @@@ -2454,23 -2330,6 +2454,23 @@@ ZEND_METHOD(reflection_parameter, isPas } /* }}} */ +/* {{{ proto public bool ReflectionParameter::canBePassedByValue() + Returns whether this parameter can be passed by value */ +ZEND_METHOD(reflection_parameter, canBePassedByValue) +{ + reflection_object *intern; + parameter_reference *param; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(param); + + /* true if it's ZEND_SEND_BY_VAL or ZEND_SEND_PREFER_REF */ + RETVAL_BOOL(param->arg_info->pass_by_reference != ZEND_SEND_BY_REF); +} +/* }}} */ + /* {{{ proto public bool ReflectionParameter::getPosition() Returns whether this parameter is an optional parameter */ ZEND_METHOD(reflection_parameter, getPosition) @@@ -2524,7 -2383,7 +2524,7 @@@ ZEND_METHOD(reflection_parameter, isDef RETURN_FALSE; } precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); - if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) { + if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { RETURN_FALSE; } RETURN_TRUE; @@@ -2550,16 -2409,16 +2550,16 @@@ ZEND_METHOD(reflection_parameter, getDe return; } if (param->offset < param->required) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); return; } precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); - if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2.op_type == IS_UNUSED) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); + if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); return; } - *return_value = precv->op2.u.constant; + *return_value = *precv->op2.zv; INIT_PZVAL(return_value); if (Z_TYPE_P(return_value) != IS_CONSTANT && Z_TYPE_P(return_value) != IS_CONSTANT_ARRAY) { zval_copy_ctor(return_value); @@@ -2596,7 -2455,7 +2596,7 @@@ ZEND_METHOD(reflection_method, __constr return; } if ((tmp = strstr(name_str, "::")) == NULL) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invalid method name %s", name_str); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invalid method name %s", name_str); return; } classname = &ztmp; @@@ -2616,13 -2475,13 +2616,13 @@@ if (intern == NULL) { return; } - + /* Find the class entry */ switch (Z_TYPE_P(classname)) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Class %s does not exist", Z_STRVAL_P(classname)); + "Class %s does not exist", Z_STRVAL_P(classname)); if (classname == &ztmp) { zval_dtor(&ztmp); } @@@ -2656,7 -2515,7 +2656,7 @@@ /* do nothing, mptr already set */ } else if (zend_hash_find(&ce->function_table, lcname, name_len + 1, (void **) &mptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s::%s() does not exist", ce->name, name_str); return; } @@@ -2665,11 -2524,11 +2665,11 @@@ MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, mptr->common.scope->name, mptr->common.scope->name_length, 1); - zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); - + reflection_update_property(object, "class", classname); + MAKE_STD_ZVAL(name); ZVAL_STRING(name, mptr->common.function_name, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property(object, "name", name); intern->ptr = mptr; intern->ref_type = REF_TYPE_FUNCTION; intern->ce = ce; @@@ -2694,41 -2553,6 +2694,41 @@@ ZEND_METHOD(reflection_method, __toStri } /* }}} */ +/* {{{ proto public mixed ReflectionMethod::getClosure([mixed object]) + Invokes the function */ +ZEND_METHOD(reflection_method, getClosure) +{ + reflection_object *intern; + zval *obj; + zend_function *mptr; + + METHOD_NOTSTATIC(reflection_method_ptr); + GET_REFLECTION_OBJECT_PTR(mptr); + + if (mptr->common.fn_flags & ZEND_ACC_STATIC) { + zend_create_closure(return_value, mptr, mptr->common.scope, NULL TSRMLS_CC); + } else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) { + return; + } + + if (!instanceof_function(Z_OBJCE_P(obj), mptr->common.scope TSRMLS_CC)) { + _DO_THROW("Given object is not an instance of the class this method was declared in"); + /* Returns from this function */ + } + + /* This is an original closure object and __invoke is to be called. */ + if (Z_OBJCE_P(obj) == zend_ce_closure && mptr->type == ZEND_INTERNAL_FUNCTION && + (mptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) + { + RETURN_ZVAL(obj, 1, 0); + } else { + zend_create_closure(return_value, mptr, mptr->common.scope, obj TSRMLS_CC); + } + } +} +/* }}} */ + /* {{{ proto public mixed ReflectionMethod::invoke(mixed object, mixed* args) Invokes the method. */ ZEND_METHOD(reflection_method, invoke) @@@ -2742,7 -2566,7 +2742,7 @@@ zend_fcall_info fci; zend_fcall_info_cache fcc; zend_class_entry *obj_ce; - + METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); @@@ -2752,12 -2576,12 +2752,12 @@@ && intern->ignore_visibility == 0) { if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke abstract method %s::%s()", + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Trying to invoke abstract method %s::%s()", mptr->common.scope->name, mptr->common.function_name); } else { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke %s method %s::%s() from scope %s", + "Trying to invoke %s method %s::%s() from scope %s", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", mptr->common.scope->name, mptr->common.function_name, Z_OBJCE_P(getThis())->name); @@@ -2768,7 -2592,7 +2768,7 @@@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", ¶ms, &num_args) == FAILURE) { return; } - + /* In case this is a static method, we should'nt pass an object_ptr * (which is used as calling context aka $this). We can thus ignore the * first parameter. @@@ -2794,10 -2618,10 +2794,10 @@@ _DO_THROW("Given object is not an instance of the class this method was declared in"); /* Returns from this function */ } - + object_ptr = *params[0]; } - + fci.size = sizeof(fci); fci.function_table = NULL; fci.function_name = NULL; @@@ -2815,13 -2639,13 +2815,13 @@@ fcc.object_ptr = object_ptr; result = zend_call_function(&fci, &fcc TSRMLS_CC); - + if (params) { efree(params); } if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name); return; } @@@ -2847,7 -2671,7 +2847,7 @@@ ZEND_METHOD(reflection_method, invokeAr zend_fcall_info_cache fcc; zend_class_entry *obj_ce; zval *param_array; - + METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); @@@ -2861,12 -2685,12 +2861,12 @@@ && intern->ignore_visibility == 0) { if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke abstract method %s::%s()", + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Trying to invoke abstract method %s::%s()", mptr->common.scope->name, mptr->common.function_name); } else { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke %s method %s::%s() from scope %s", + "Trying to invoke %s method %s::%s() from scope %s", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", mptr->common.scope->name, mptr->common.function_name, Z_OBJCE_P(getThis())->name); @@@ -2875,11 -2699,11 +2875,11 @@@ } argc = zend_hash_num_elements(Z_ARRVAL_P(param_array)); - + params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); params -= argc; - + /* In case this is a static method, we should'nt pass an object_ptr * (which is used as calling context aka $this). We can thus ignore the * first parameter. @@@ -2893,11 -2717,11 +2893,11 @@@ if (!object) { efree(params); zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke non static method %s::%s() without an object", + "Trying to invoke non static method %s::%s() without an object", mptr->common.scope->name, mptr->common.function_name); return; } - + obj_ce = Z_OBJCE_P(object); if (!instanceof_function(obj_ce, mptr->common.scope TSRMLS_CC)) { @@@ -2906,7 -2730,7 +2906,7 @@@ /* Returns from this function */ } } - + fci.size = sizeof(fci); fci.function_table = NULL; fci.function_name = NULL; @@@ -2924,11 -2748,11 +2924,11 @@@ fcc.object_ptr = object; result = zend_call_function(&fci, &fcc TSRMLS_CC); - + efree(params); if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name); return; } @@@ -3000,7 -2824,7 +3000,7 @@@ ZEND_METHOD(reflection_function, isDepr ZEND_METHOD(reflection_function, inNamespace) { zval **name; - char *colon; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -3009,8 -2833,8 +3009,8 @@@ RETURN_FALSE; } if (Z_TYPE_PP(name) == IS_STRING - && (colon = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) - && colon > Z_STRVAL_PP(name)) + && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) + && backslash > Z_STRVAL_PP(name)) { RETURN_TRUE; } @@@ -3023,7 -2847,7 +3023,7 @@@ ZEND_METHOD(reflection_function, getNamespaceName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -3046,7 -2870,7 +3046,7 @@@ ZEND_METHOD(reflection_function, getShortName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -3075,7 -2899,7 +3075,7 @@@ ZEND_METHOD(reflection_method, isConstr return; } GET_REFLECTION_OBJECT_PTR(mptr); - /* we need to check if the ctor is the ctor of the class level we we + /* we need to check if the ctor is the ctor of the class level we we * looking at since we might be looking at an inherited old style ctor * defined in base class. */ RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_CTOR && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope); @@@ -3122,7 -2946,7 +3122,7 @@@ ZEND_METHOD(reflection_method, getDecla METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -3140,13 -2964,13 +3140,13 @@@ ZEND_METHOD(reflection_method, getProto METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); - + if (zend_parse_parameters_none() == FAILURE) { return; } - + if (!mptr->common.prototype) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s::%s does not have a prototype", intern->ce->name, mptr->common.function_name); return; } @@@ -3208,17 -3032,17 +3208,17 @@@ static void reflection_class_object_cto if (intern == NULL) { return; } - + if (Z_TYPE_P(argument) == IS_OBJECT) { MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, Z_OBJCE_P(argument)->name, Z_OBJCE_P(argument)->name_length, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &classname, sizeof(zval *), NULL); + reflection_update_property(object, "name", classname); intern->ptr = Z_OBJCE_P(argument); if (is_object) { intern->obj = argument; zval_add_ref(&argument); } - } else { + } else { convert_to_string_ex(&argument); if (zend_lookup_class(Z_STRVAL_P(argument), Z_STRLEN_P(argument), &ce TSRMLS_CC) == FAILURE) { if (!EG(exception)) { @@@ -3229,7 -3053,7 +3229,7 @@@ MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, (*ce)->name, (*ce)->name_length, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &classname, sizeof(zval *), NULL); + reflection_update_property(object, "name", classname); intern->ptr = *ce; } @@@ -3245,74 -3069,49 +3245,74 @@@ ZEND_METHOD(reflection_class, __constru } /* }}} */ +/* {{{ add_class_vars */ +static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value TSRMLS_DC) +{ + HashPosition pos; + zend_property_info *prop_info; + zval *prop, *prop_copy; + char *key; + uint key_len; + ulong num_index; + + zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos); + while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop_info, &pos) == SUCCESS) { + zend_hash_get_current_key_ex(&ce->properties_info, &key, &key_len, &num_index, 0, &pos); + zend_hash_move_forward_ex(&ce->properties_info, &pos); + if (((prop_info->flags & ZEND_ACC_SHADOW) && + prop_info->ce != ce) || + ((prop_info->flags & ZEND_ACC_PROTECTED) && + !zend_check_protected(prop_info->ce, ce)) || + ((prop_info->flags & ZEND_ACC_PRIVATE) && + prop_info->ce != ce)) { + continue; + } + prop = NULL; + if (prop_info->offset >= 0) { + if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { + prop = ce->default_static_members_table[prop_info->offset]; + } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { + prop = ce->default_properties_table[prop_info->offset]; + } + } + if (!prop) { + 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, (void *) 1 TSRMLS_CC); + } + + add_assoc_zval(return_value, key, prop_copy); + } +} +/* }}} */ + /* {{{ proto public array ReflectionClass::getStaticProperties() Returns an associative array containing all static property values of the class */ ZEND_METHOD(reflection_class, getStaticProperties) { reflection_object *intern; zend_class_entry *ce; - HashPosition pos; - zval **value; if (zend_parse_parameters_none() == FAILURE) { return; } - + GET_REFLECTION_OBJECT_PTR(ce); zend_update_class_constants(ce TSRMLS_CC); array_init(return_value); - - zend_hash_internal_pointer_reset_ex(CE_STATIC_MEMBERS(ce), &pos); - - while (zend_hash_get_current_data_ex(CE_STATIC_MEMBERS(ce), (void **) &value, &pos) == SUCCESS) { - uint key_len; - char *key; - ulong num_index; - - if (zend_hash_get_current_key_ex(CE_STATIC_MEMBERS(ce), &key, &key_len, &num_index, 0, &pos) != FAILURE && key) { - char *prop_name, *class_name; - zval *prop_copy; - - zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name); - - /* filter privates from base classes */ - if (!(class_name && class_name[0] != '*' && strcmp(class_name, ce->name))) { - /* copy: enforce read only access */ - ALLOC_ZVAL(prop_copy); - MAKE_COPY_ZVAL(value, prop_copy); - - add_assoc_zval(return_value, prop_name, prop_copy); - } - } - zend_hash_move_forward_ex(CE_STATIC_MEMBERS(ce), &pos); - } + add_class_vars(ce, 1, return_value TSRMLS_CC); } /* }}} */ @@@ -3325,7 -3124,7 +3325,7 @@@ ZEND_METHOD(reflection_class, getStatic char *name; int name_len; zval **prop, *def_value = NULL; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &name, &name_len, &def_value) == FAILURE) { return; } @@@ -3333,12 -3132,12 +3333,12 @@@ GET_REFLECTION_OBJECT_PTR(ce); zend_update_class_constants(ce TSRMLS_CC); - prop = zend_std_get_static_property(ce, name, name_len, 1 TSRMLS_CC); + prop = zend_std_get_static_property(ce, name, name_len, 1, NULL TSRMLS_CC); if (!prop) { if (def_value) { RETURN_ZVAL(def_value, 1, 0); } else { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a property named %s", ce->name, name); } return; @@@ -3359,7 -3158,7 +3359,7 @@@ ZEND_METHOD(reflection_class, setStatic zval **variable_ptr, *value; int refcount; zend_uchar is_ref; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &value) == FAILURE) { return; } @@@ -3367,12 -3166,12 +3367,12 @@@ GET_REFLECTION_OBJECT_PTR(ce); zend_update_class_constants(ce TSRMLS_CC); - variable_ptr = zend_std_get_static_property(ce, name, name_len, 1 TSRMLS_CC); + variable_ptr = zend_std_get_static_property(ce, name, name_len, 1, NULL TSRMLS_CC); if (!variable_ptr) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a property named %s", ce->name, name); return; - } + } refcount = Z_REFCOUNT_PP(variable_ptr); is_ref = Z_ISREF_PP(variable_ptr); zval_dtor(*variable_ptr); @@@ -3390,15 -3189,51 +3390,15 @@@ ZEND_METHOD(reflection_class, getDefaul { reflection_object *intern; zend_class_entry *ce; - int count, i; - HashTable *ht_list[3]; - + if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ce); array_init(return_value); - zend_update_class_constants(ce TSRMLS_CC); - - ht_list[0] = CE_STATIC_MEMBERS(ce); - ht_list[1] = &ce->default_properties; - ht_list[2] = NULL; - - for (i = 0; ht_list[i] != NULL; i++) { - - count = zend_hash_num_elements(ht_list[i]); - if (count > 0) { - HashPosition pos; - zval **prop; - - zend_hash_internal_pointer_reset_ex(ht_list[i], &pos); - while (zend_hash_get_current_data_ex(ht_list[i], (void **) &prop, &pos) == SUCCESS) { - char *key, *class_name, *prop_name; - uint key_len; - ulong num_index; - zval *prop_copy; - - zend_hash_get_current_key_ex(ht_list[i], &key, &key_len, &num_index, 0, &pos); - zend_hash_move_forward_ex(ht_list[i], &pos); - zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name); - if (class_name && class_name[0] != '*' && strcmp(class_name, ce->name)) { - /* filter privates from base classes */ - continue; - } - - /* copy: enforce read only access */ - ALLOC_ZVAL(prop_copy); - MAKE_COPY_ZVAL(prop, prop_copy); - - add_assoc_zval(return_value, prop_name, prop_copy); - } - } - } + add_class_vars(ce, 1, return_value TSRMLS_CC); + add_class_vars(ce, 0, return_value TSRMLS_CC); } /* }}} */ @@@ -3473,7 -3308,7 +3473,7 @@@ ZEND_METHOD(reflection_class, getFileNa } GET_REFLECTION_OBJECT_PTR(ce); if (ce->type == ZEND_USER_CLASS) { - RETURN_STRING(ce->filename, 1); + RETURN_STRING(ce->info.user.filename, 1); } RETURN_FALSE; } @@@ -3491,7 -3326,7 +3491,7 @@@ ZEND_METHOD(reflection_class, getStartL } GET_REFLECTION_OBJECT_PTR(ce); if (ce->type == ZEND_USER_FUNCTION) { - RETURN_LONG(ce->line_start); + RETURN_LONG(ce->info.user.line_start); } RETURN_FALSE; } @@@ -3509,7 -3344,7 +3509,7 @@@ ZEND_METHOD(reflection_class, getEndLin } GET_REFLECTION_OBJECT_PTR(ce); if (ce->type == ZEND_USER_CLASS) { - RETURN_LONG(ce->line_end); + RETURN_LONG(ce->info.user.line_end); } RETURN_FALSE; } @@@ -3526,8 -3361,8 +3526,8 @@@ ZEND_METHOD(reflection_class, getDocCom return; } GET_REFLECTION_OBJECT_PTR(ce); - if (ce->type == ZEND_USER_CLASS && ce->doc_comment) { - RETURN_STRINGL(ce->doc_comment, ce->doc_comment_len, 1); + if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) { + RETURN_STRINGL(ce->info.user.doc_comment, ce->info.user.doc_comment_len, 1); } RETURN_FALSE; } @@@ -3559,7 -3394,7 +3559,7 @@@ ZEND_METHOD(reflection_class, hasMethod { reflection_object *intern; zend_class_entry *ce; - char *name, *lc_name; + char *name, *lc_name; int name_len; METHOD_NOTSTATIC(reflection_class_ptr); @@@ -3589,7 -3424,7 +3589,7 @@@ ZEND_METHOD(reflection_class, getMethod zend_class_entry *ce; zend_function *mptr; zval obj_tmp; - char *name, *lc_name; + char *name, *lc_name; int name_len; METHOD_NOTSTATIC(reflection_class_ptr); @@@ -3620,7 -3455,7 +3620,7 @@@ efree(lc_name); } else { efree(lc_name); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s does not exist", name); return; } @@@ -3658,7 -3493,7 +3658,7 @@@ static int _addmethod_va(zend_function zval *retval = va_arg(args, zval*); long filter = va_arg(args, long); zval *obj = va_arg(args, zval *); - + _addmethod(mptr, ce, retval, filter, obj TSRMLS_CC); return ZEND_HASH_APPLY_KEEP; } @@@ -3704,7 -3539,7 +3704,7 @@@ ZEND_METHOD(reflection_class, hasProper reflection_object *intern; zend_property_info *property_info; zend_class_entry *ce; - char *name; + char *name; int name_len; zval *property; @@@ -3723,7 -3558,7 +3723,7 @@@ if (intern->obj && Z_OBJ_HANDLER_P(intern->obj, has_property)) { MAKE_STD_ZVAL(property); ZVAL_STRINGL(property, name, name_len, 1); - if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 2 TSRMLS_CC)) { + if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 2, 0 TSRMLS_CC)) { zval_ptr_dtor(&property); RETURN_TRUE; } @@@ -3741,7 -3576,7 +3741,7 @@@ ZEND_METHOD(reflection_class, getProper reflection_object *intern; zend_class_entry *ce, **pce; zend_property_info *property_info; - char *name, *tmp, *classname; + char *name, *tmp, *classname; int name_len, classname_len; METHOD_NOTSTATIC(reflection_class_ptr); @@@ -3797,9 -3632,9 +3797,9 @@@ if (zend_hash_find(&ce->properties_info, name, name_len + 1, (void**) &property_info) == SUCCESS && (property_info->flags & ZEND_ACC_SHADOW) == 0) { reflection_property_factory(ce, property_info, return_value TSRMLS_CC); return; - } + } } - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Property %s does not exist", name); } /* }}} */ @@@ -3815,7 -3650,7 +3815,7 @@@ static int _addproperty(zend_property_i if (pptr->flags & ZEND_ACC_SHADOW) { return 0; } - + if (pptr->flags & filter) { ALLOC_ZVAL(property); reflection_property_factory(ce, pptr, property TSRMLS_CC); @@@ -3933,7 -3768,7 +3933,7 @@@ ZEND_METHOD(reflection_class, getConsta reflection_object *intern; zend_class_entry *ce; zval **value; - char *name; + char *name; int name_len; METHOD_NOTSTATIC(reflection_class_ptr); @@@ -3989,39 -3824,6 +3989,39 @@@ ZEND_METHOD(reflection_class, isInstant } /* }}} */ +/* {{{ proto public bool ReflectionClass::isCloneable() + Returns whether this class is cloneable */ +ZEND_METHOD(reflection_class, isCloneable) +{ + reflection_object *intern; + zend_class_entry *ce; + zval obj; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) { + RETURN_FALSE; + } + if (intern->obj) { + if (ce->clone) { + RETURN_BOOL(ce->clone->common.fn_flags & ZEND_ACC_PUBLIC); + } else { + RETURN_BOOL(Z_OBJ_HANDLER_P(intern->obj, clone_obj) != NULL); + } + } else { + if (ce->clone) { + RETURN_BOOL(ce->clone->common.fn_flags & ZEND_ACC_PUBLIC); + } else { + object_init_ex(&obj, ce); + RETVAL_BOOL(Z_OBJ_HANDLER(obj, clone_obj) != NULL); + zval_dtor(&obj); + } + } +} +/* }}} */ + /* {{{ proto public bool ReflectionClass::isInterface() Returns whether this is an interface or a class */ ZEND_METHOD(reflection_class, isInterface) @@@ -4030,14 -3832,6 +4030,14 @@@ } /* }}} */ +/* {{{ proto public bool ReflectionClass::isTrait() + Returns whether this is a trait */ +ZEND_METHOD(reflection_class, isTrait) +{ + _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT & ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); +} +/* }}} */ + /* {{{ proto public bool ReflectionClass::isFinal() Returns whether this class is final */ ZEND_METHOD(reflection_class, isFinal) @@@ -4082,7 -3876,7 +4082,7 @@@ ZEND_METHOD(reflection_class, isInstanc if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) { return; } - GET_REFLECTION_OBJECT_PTR(ce); + GET_REFLECTION_OBJECT_PTR(ce); RETURN_BOOL(HAS_CLASS_ENTRY(*object) && instanceof_function(Z_OBJCE_P(object), ce TSRMLS_CC)); } /* }}} */ @@@ -4094,7 -3888,7 +4094,7 @@@ ZEND_METHOD(reflection_class, newInstan zval *retval_ptr = NULL; reflection_object *intern; zend_class_entry *ce; - + METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); @@@ -4159,24 -3953,6 +4159,24 @@@ } /* }}} */ +/* {{{ proto public stdclass ReflectionClass::newInstanceWithoutConstructor() + Returns an instance of this class without invoking its constructor */ +ZEND_METHOD(reflection_class, newInstanceWithoutConstructor) +{ + reflection_object *intern; + zend_class_entry *ce; + + METHOD_NOTSTATIC(reflection_class_ptr); + GET_REFLECTION_OBJECT_PTR(ce); + + if (ce->create_object != NULL) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class that cannot be instantiated without invoking its constructor", ce->name); + } + + object_init_ex(return_value, ce); +} +/* }}} */ + /* {{{ proto public stdclass ReflectionClass::newInstanceArgs([array args]) Returns an instance of this class */ ZEND_METHOD(reflection_class, newInstanceArgs) @@@ -4186,8 -3962,8 +4186,8 @@@ zend_class_entry *ce; int argc = 0; HashTable *args; - - + + METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); @@@ -4197,7 -3973,7 +4197,7 @@@ if (ZEND_NUM_ARGS() > 0) { argc = args->nNumOfElements; } - + /* Run the constructor if there is one */ if (ce->constructor) { zval ***params = NULL; @@@ -4208,10 -3984,10 +4208,10 @@@ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name); return; } - + if (argc) { params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); params -= argc; } @@@ -4307,80 -4083,6 +4307,80 @@@ ZEND_METHOD(reflection_class, getInterf } /* }}} */ +/* {{{ proto public ReflectionClass[] ReflectionClass::getTraits() + Returns an array of traits used by this class */ +ZEND_METHOD(reflection_class, getTraits) +{ + reflection_object *intern; + zend_class_entry *ce; + zend_uint i; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + for (i=0; i < ce->num_traits; i++) { + zval *trait; + ALLOC_ZVAL(trait); + zend_reflection_class_factory(ce->traits[i], trait TSRMLS_CC); + add_assoc_zval_ex(return_value, ce->traits[i]->name, ce->traits[i]->name_length + 1, trait); + } +} +/* }}} */ + +/* {{{ proto public String[] ReflectionClass::getTraitNames() + Returns an array of names of traits used by this class */ +ZEND_METHOD(reflection_class, getTraitNames) +{ + reflection_object *intern; + zend_class_entry *ce; + zend_uint i; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + for (i=0; i < ce->num_traits; i++) { + add_next_index_stringl(return_value, ce->traits[i]->name, ce->traits[i]->name_length, 1); + } +} +/* }}} */ + +/* {{{ proto public arra ReflectionClass::getTraitaliases() + Returns an array of trait aliases */ +ZEND_METHOD(reflection_class, getTraitAliases) +{ + reflection_object *intern; + zend_class_entry *ce; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + if (ce->trait_aliases) { + zend_uint i = 0; + while (ce->trait_aliases[i]) { + char *method_name; + int method_name_len; + zend_trait_method_reference *cur_ref = ce->trait_aliases[i]->trait_method; + + method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->class_name, cur_ref->method_name); + add_assoc_stringl_ex(return_value, ce->trait_aliases[i]->alias, ce->trait_aliases[i]->alias_len + 1, method_name, method_name_len, 0); + i++; + } + } +} +/* }}} */ + /* {{{ proto public ReflectionClass ReflectionClass::getParentClass() Returns the class' parent class, or, if none exists, FALSE */ ZEND_METHOD(reflection_class, getParentClass) @@@ -4392,7 -4094,7 +4392,7 @@@ return; } GET_REFLECTION_OBJECT_PTR(ce); - + if (ce->parent) { zend_reflection_class_factory(ce->parent, return_value TSRMLS_CC); } else { @@@ -4415,16 -4117,16 +4415,16 @@@ ZEND_METHOD(reflection_class, isSubclas if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &class_name) == FAILURE) { return; } - + switch(class_name->type) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(class_name)); return; } class_ce = *pce; - break; + break; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(class_name), reflection_class_ptr TSRMLS_CC)) { argument = (reflection_object *) zend_object_store_get_object(class_name TSRMLS_CC); @@@ -4437,7 -4139,7 +4437,7 @@@ } /* no break */ default: - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter one must either be a string or a ReflectionClass object"); return; } @@@ -4460,16 -4162,16 +4460,16 @@@ ZEND_METHOD(reflection_class, implement if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &interface) == FAILURE) { return; } - + switch(interface->type) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(interface), Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s does not exist", Z_STRVAL_P(interface)); return; } interface_ce = *pce; - break; + break; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(interface), reflection_class_ptr TSRMLS_CC)) { argument = (reflection_object *) zend_object_store_get_object(interface TSRMLS_CC); @@@ -4482,13 -4184,13 +4482,13 @@@ } /* no break */ default: - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter one must either be a string or a ReflectionClass object"); return; } if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s is a Class", interface_ce->name); return; } @@@ -4502,7 -4204,7 +4502,7 @@@ ZEND_METHOD(reflection_class, isIterate { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -4520,7 -4222,7 +4520,7 @@@ ZEND_METHOD(reflection_class, getExtens { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -4528,8 -4230,8 +4528,8 @@@ METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); - if (ce->module) { - reflection_extension_factory(return_value, ce->module->name TSRMLS_CC); + if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module) { + reflection_extension_factory(return_value, ce->info.internal.module->name TSRMLS_CC); } } /* }}} */ @@@ -4540,7 -4242,7 +4540,7 @@@ ZEND_METHOD(reflection_class, getExtens { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@@ -4548,8 -4250,8 +4548,8 @@@ METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); - if (ce->module) { - RETURN_STRING(ce->module->name, 1); + if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module) { + RETURN_STRING(ce->info.internal.module->name, 1); } else { RETURN_FALSE; } @@@ -4561,7 -4263,7 +4561,7 @@@ ZEND_METHOD(reflection_class, inNamespace) { zval **name; - char *colon; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -4570,8 -4272,8 +4570,8 @@@ RETURN_FALSE; } if (Z_TYPE_PP(name) == IS_STRING - && (colon = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) - && colon > Z_STRVAL_PP(name)) + && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) + && backslash > Z_STRVAL_PP(name)) { RETURN_TRUE; } @@@ -4584,7 -4286,7 +4584,7 @@@ ZEND_METHOD(reflection_class, getNamespaceName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -4607,7 -4309,7 +4607,7 @@@ ZEND_METHOD(reflection_class, getShortName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@@ -4654,8 -4356,7 +4654,8 @@@ ZEND_METHOD(reflection_property, export ZEND_METHOD(reflection_property, __construct) { zval *propname, *classname; - char *name_str, *class_name, *prop_name; + char *name_str; + const char *class_name, *prop_name; int name_len, dynam_prop = 0; zval *object; reflection_object *intern; @@@ -4673,13 -4374,13 +4673,13 @@@ if (intern == NULL) { return; } - + /* Find the class entry */ switch (Z_TYPE_P(classname)) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Class %s does not exist", Z_STRVAL_P(classname)); + "Class %s does not exist", Z_STRVAL_P(classname)); return; } ce = *pce; @@@ -4688,7 -4389,7 +4688,7 @@@ case IS_OBJECT: ce = Z_OBJCE_P(classname); break; - + default: _DO_THROW("The parameter class is expected to be either a string or an object"); /* returns out of this function */ @@@ -4706,12 -4407,12 +4706,12 @@@ return; } } - + if (dynam_prop == 0 && (property_info->flags & ZEND_ACC_PRIVATE) == 0) { /* we have to search the class hierarchy for this (implicit) public or protected property */ zend_class_entry *tmp_ce = ce; zend_property_info *tmp_info; - + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) != SUCCESS) { ce = tmp_ce; property_info = tmp_info; @@@ -4719,19 -4420,19 +4719,19 @@@ } } - MAKE_STD_ZVAL(classname); + MAKE_STD_ZVAL(classname); MAKE_STD_ZVAL(propname); - + if (dynam_prop == 0) { zend_unmangle_property_name(property_info->name, property_info->name_length, &class_name, &prop_name); ZVAL_STRINGL(classname, property_info->ce->name, property_info->ce->name_length, 1); ZVAL_STRING(propname, prop_name, 1); } else { - ZVAL_STRINGL(classname, ce->name, ce->name_length, 1); + ZVAL_STRINGL(classname, ce->name, ce->name_length, 1); ZVAL_STRINGL(propname, name_str, name_len, 1); } - zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &propname, sizeof(zval *), NULL); + reflection_update_property(object, "class", classname); + reflection_update_property(object, "name", propname); reference = (property_reference*) emalloc(sizeof(property_reference)); if (dynam_prop) { @@@ -4781,7 -4482,7 +4781,7 @@@ ZEND_METHOD(reflection_property, getNam } /* }}} */ -static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) +static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /* {{{ */ { reflection_object *intern; property_reference *ref; @@@ -4792,7 -4493,6 +4792,7 @@@ GET_REFLECTION_OBJECT_PTR(ref); RETURN_BOOL(ref->prop.flags & mask); } +/* }}} */ /* {{{ proto public bool ReflectionProperty::isPublic() Returns whether this property is public */ @@@ -4857,14 -4557,14 +4857,14 @@@ ZEND_METHOD(reflection_property, getVal reflection_object *intern; property_reference *ref; zval *object, name; - zval **member = NULL, *member_p = NULL; + zval *member_p = NULL; METHOD_NOTSTATIC(reflection_property_ptr); GET_REFLECTION_OBJECT_PTR(ref); if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) { _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name)); zval_dtor(&name); return; @@@ -4872,16 -4572,14 +4872,16 @@@ if ((ref->prop.flags & ZEND_ACC_STATIC)) { zend_update_class_constants(intern->ce TSRMLS_CC); - if (zend_hash_quick_find(CE_STATIC_MEMBERS(intern->ce), ref->prop.name, ref->prop.name_length + 1, ref->prop.h, (void **) &member) == FAILURE) { + if (!CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name); /* Bails out */ } - MAKE_COPY_ZVAL(member, return_value); + *return_value= *CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]; + zval_copy_ctor(return_value); + INIT_PZVAL(return_value); } else { - char *class_name, *prop_name; - + const char *class_name, *prop_name; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) { return; } @@@ -4905,14 -4603,16 +4905,14 @@@ ZEND_METHOD(reflection_property, setVal zval **variable_ptr; zval *object, name; zval *value; - int setter_done = 0; zval *tmp; - HashTable *prop_table; METHOD_NOTSTATIC(reflection_property_ptr); GET_REFLECTION_OBJECT_PTR(ref); if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) { _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name)); zval_dtor(&name); return; @@@ -4925,37 -4625,36 +4925,37 @@@ } } zend_update_class_constants(intern->ce TSRMLS_CC); - prop_table = CE_STATIC_MEMBERS(intern->ce); - if (zend_hash_quick_find(prop_table, ref->prop.name, ref->prop.name_length + 1, ref->prop.h, (void **) &variable_ptr) == FAILURE) { + if (!CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name); /* Bails out */ } - if (*variable_ptr == value) { - setter_done = 1; - } else { + variable_ptr = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]; + if (*variable_ptr != value) { if (PZVAL_IS_REF(*variable_ptr)) { - zval_dtor(*variable_ptr); - (*variable_ptr)->type = value->type; + zval garbage = **variable_ptr; /* old value should be destroyed */ + + /* To check: can't *variable_ptr be some system variable like error_zval here? */ + Z_TYPE_PP(variable_ptr) = Z_TYPE_P(value); (*variable_ptr)->value = value->value; if (Z_REFCOUNT_P(value) > 0) { zval_copy_ctor(*variable_ptr); } - setter_done = 1; - } - } - if (!setter_done) { - zval **foo; + zval_dtor(&garbage); + } else { + zval *garbage = *variable_ptr; - Z_ADDREF_P(value); - if (PZVAL_IS_REF(value)) { - SEPARATE_ZVAL(&value); + /* if we assign referenced variable, we should separate it */ + Z_ADDREF_P(value); + if (PZVAL_IS_REF(value)) { + SEPARATE_ZVAL(&value); + } + *variable_ptr = value; + zval_ptr_dtor(&garbage); } - zend_hash_quick_update(prop_table, ref->prop.name, ref->prop.name_length+1, ref->prop.h, &value, sizeof(zval *), (void **) &foo); } } else { - char *class_name, *prop_name; + const char *class_name, *prop_name; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oz", &object, &value) == FAILURE) { return; @@@ -4974,7 -4673,7 +4974,7 @@@ ZEND_METHOD(reflection_property, getDec property_reference *ref; zend_class_entry *tmp_ce, *ce; zend_property_info *tmp_info; - char *prop_name, *class_name; + const char *prop_name, *class_name; int prop_name_len; if (zend_parse_parameters_none() == FAILURE) { @@@ -5078,14 -4777,14 +5078,14 @@@ ZEND_METHOD(reflection_extension, __con zend_str_tolower_copy(lcname, name_str, name_len); if (zend_hash_find(&module_registry, lcname, name_len + 1, (void **)&module) == FAILURE) { free_alloca(lcname, use_heap); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Extension %s does not exist", name_str); return; } free_alloca(lcname, use_heap); MAKE_STD_ZVAL(name); ZVAL_STRING(name, module->name, 1); - zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL); + reflection_update_property( object, "name", name); intern->ptr = module; intern->ref_type = REF_TYPE_OTHER; intern->ce = NULL; @@@ -5171,7 -4870,7 +5171,7 @@@ ZEND_METHOD(reflection_extension, getFu efree(lc_name); continue; } - + ALLOC_ZVAL(function); reflection_function_factory(fptr, NULL, function TSRMLS_CC); add_assoc_zval_ex(return_value, func->fname, fname_len+1, function); @@@ -5182,7 -4881,7 +5182,7 @@@ } /* }}} */ -static int _addconstant(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _addconstant(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { zval *const_val; zval *retval = va_arg(args, zval*); @@@ -5197,7 -4896,6 +5197,7 @@@ } return 0; } +/* }}} */ /* {{{ proto public array ReflectionExtension::getConstants() Returns an associative array containing this extension's constants and their values */ @@@ -5257,7 -4955,7 +5257,7 @@@ static int add_extension_class(zend_cla struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*); int add_reflection_class = va_arg(args, int); - if ((*pce)->module && !strcasecmp((*pce)->module->name, module->name)) { + if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) { if (add_reflection_class) { ALLOC_ZVAL(zclass); zend_reflection_class_factory(*pce, zclass TSRMLS_CC); @@@ -5316,11 -5014,11 +5316,11 @@@ ZEND_METHOD(reflection_extension, getDe return; } GET_REFLECTION_OBJECT_PTR(module); - + array_init(return_value); dep = module->deps; - + if (!dep) { return; @@@ -5330,7 -5028,7 +5330,7 @@@ char *relation; char *rel_type; int len; - + switch(dep->type) { case MODULE_DEP_REQUIRED: rel_type = "Required"; @@@ -5346,10 -5044,10 +5346,10 @@@ break; } - len = spprintf(&relation, 0, "%s%s%s%s%s", + len = spprintf(&relation, 0, "%s%s%s%s%s", rel_type, dep->rel ? " " : "", - dep->rel ? dep->rel : "", + dep->rel ? dep->rel : "", dep->version ? " " : "", dep->version ? dep->version : ""); add_assoc_stringl(return_value, dep->name, relation, len, 0); @@@ -5358,7 -5056,7 +5358,7 @@@ } /* }}} */ -/* {{{ proto public void ReflectionExtension::info() U +/* {{{ proto public void ReflectionExtension::info() Prints phpinfo block for the extension */ ZEND_METHOD(reflection_extension, info) { @@@ -5374,180 -5072,6 +5374,180 @@@ } /* }}} */ +/* {{{ proto public bool ReflectionExtension::isPersistent() + Returns whether this extension is persistent */ +ZEND_METHOD(reflection_extension, isPersistent) +{ + reflection_object *intern; + zend_module_entry *module; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(module); + + RETURN_BOOL(module->type == MODULE_PERSISTENT); +} +/* }}} */ + +/* {{{ proto public bool ReflectionExtension::isTemporary() + Returns whether this extension is temporary */ +ZEND_METHOD(reflection_extension, isTemporary) +{ + reflection_object *intern; + zend_module_entry *module; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(module); + + RETURN_BOOL(module->type == MODULE_TEMPORARY); +} +/* }}} */ + +/* {{{ proto public static mixed ReflectionZendExtension::export(string name [, bool return]) throws ReflectionException + * Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */ +ZEND_METHOD(reflection_zend_extension, export) +{ + _reflection_export(INTERNAL_FUNCTION_PARAM_PASSTHRU, reflection_zend_extension_ptr, 1); +} +/* }}} */ + +/* {{{ proto public void ReflectionZendExtension::__construct(string name) + Constructor. Throws an Exception in case the given Zend extension does not exist */ +ZEND_METHOD(reflection_zend_extension, __construct) +{ + zval *name; + zval *object; + reflection_object *intern; + zend_extension *extension; + char *name_str; + int name_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len) == FAILURE) { + return; + } + + object = getThis(); + intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC); + if (intern == NULL) { + return; + } + + extension = zend_get_extension(name_str); + if (!extension) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Zend Extension %s does not exist", name_str); + return; + } + MAKE_STD_ZVAL(name); + ZVAL_STRING(name, extension->name, 1); + reflection_update_property(object, "name", name); + intern->ptr = extension; + intern->ref_type = REF_TYPE_OTHER; + intern->ce = NULL; +} +/* }}} */ + +/* {{{ proto public string ReflectionZendExtension::__toString() + Returns a string representation */ +ZEND_METHOD(reflection_zend_extension, __toString) +{ + reflection_object *intern; + zend_extension *extension; + string str; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + string_init(&str); + _zend_extension_string(&str, extension, "" TSRMLS_CC); + RETURN_STRINGL(str.string, str.len - 1, 0); +} +/* }}} */ + +/* {{{ proto public string ReflectionZendExtension::getName() + Returns the name of this Zend extension */ +ZEND_METHOD(reflection_zend_extension, getName) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->name, 1); +} +/* }}} */ + +/* {{{ proto public string ReflectionZendExtension::getVersion() + Returns the version information of this Zend extension */ +ZEND_METHOD(reflection_zend_extension, getVersion) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->version ? extension->version : "", 1); +} +/* }}} */ + +/* {{{ proto public void ReflectionZendExtension::getAuthor() + * Returns the name of this Zend extension's author */ +ZEND_METHOD(reflection_zend_extension, getAuthor) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->author ? extension->author : "", 1); +} +/* }}} */ + +/* {{{ proto public void ReflectionZendExtension::getURL() + Returns this Zend extension's URL*/ +ZEND_METHOD(reflection_zend_extension, getURL) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->URL ? extension->URL : "", 1); +} +/* }}} */ + +/* {{{ proto public void ReflectionZendExtension::getCopyright() + Returns this Zend extension's copyright information */ +ZEND_METHOD(reflection_zend_extension, getCopyright) +{ + reflection_object *intern; + zend_extension *extension; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(extension); + + RETURN_STRING(extension->copyright ? extension->copyright : "", 1); +} +/* }}} */ + /* {{{ method tables */ static const zend_function_entry reflection_exception_functions[] = { PHP_FE_END @@@ -5603,8 -5127,6 +5603,8 @@@ static const zend_function_entry reflec ZEND_ME(reflection_function, isDeprecated, arginfo_reflection__void, 0) ZEND_ME(reflection_function, isInternal, arginfo_reflection__void, 0) ZEND_ME(reflection_function, isUserDefined, arginfo_reflection__void, 0) + ZEND_ME(reflection_function, getClosureThis, arginfo_reflection__void, 0) + ZEND_ME(reflection_function, getClosureScopeClass, arginfo_reflection__void, 0) ZEND_ME(reflection_function, getDocComment, arginfo_reflection__void, 0) ZEND_ME(reflection_function, getEndLine, arginfo_reflection__void, 0) ZEND_ME(reflection_function, getExtension, arginfo_reflection__void, 0) @@@ -5629,7 -5151,6 +5629,7 @@@ static const zend_function_entry reflec ZEND_ME(reflection_function, isDisabled, arginfo_reflection__void, 0) ZEND_ME(reflection_function, invoke, arginfo_reflection_function_invoke, 0) ZEND_ME(reflection_function, invokeArgs, arginfo_reflection_function_invokeArgs, 0) + ZEND_ME(reflection_function, getClosure, arginfo_reflection__void, 0) PHP_FE_END }; @@@ -5658,10 -5179,6 +5658,10 @@@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_ ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_reflection_method_getClosure, 0) + ZEND_ARG_INFO(0, object) +ZEND_END_ARG_INFO() + static const zend_function_entry reflection_method_functions[] = { ZEND_ME(reflection_method, export, arginfo_reflection_method_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) ZEND_ME(reflection_method, __construct, arginfo_reflection_method___construct, 0) @@@ -5674,7 -5191,6 +5674,7 @@@ ZEND_ME(reflection_method, isStatic, arginfo_reflection__void, 0) ZEND_ME(reflection_method, isConstructor, arginfo_reflection__void, 0) ZEND_ME(reflection_method, isDestructor, arginfo_reflection__void, 0) + ZEND_ME(reflection_method, getClosure, arginfo_reflection_method_getClosure, 0) ZEND_ME(reflection_method, getModifiers, arginfo_reflection__void, 0) ZEND_ME(reflection_method, invoke, arginfo_reflection_method_invoke, 0) ZEND_ME(reflection_method, invokeArgs, arginfo_reflection_method_invokeArgs, 0) @@@ -5744,9 -5260,6 +5744,9 @@@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_ ZEND_ARG_INFO(0, args) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_newInstanceWithoutConstructor, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_newInstanceArgs, 0, 0, 0) ZEND_ARG_ARRAY_INFO(0, args, 0) ZEND_END_ARG_INFO() @@@ -5768,7 -5281,6 +5768,7 @@@ static const zend_function_entry reflec ZEND_ME(reflection_class, isInternal, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isUserDefined, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isInstantiable, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, isCloneable, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getFileName, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getStartLine, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getEndLine, arginfo_reflection__void, 0) @@@ -5786,16 -5298,11 +5786,16 @@@ ZEND_ME(reflection_class, getInterfaces, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getInterfaceNames, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isInterface, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, getTraits, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, getTraitNames, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, getTraitAliases, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, isTrait, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isAbstract, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isFinal, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getModifiers, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isInstance, arginfo_reflection_class_isInstance, 0) ZEND_ME(reflection_class, newInstance, arginfo_reflection_class_newInstance, 0) + ZEND_ME(reflection_class, newInstanceWithoutConstructor, arginfo_reflection_class_newInstanceWithoutConstructor, 0) ZEND_ME(reflection_class, newInstanceArgs, arginfo_reflection_class_newInstanceArgs, 0) ZEND_ME(reflection_class, getParentClass, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isSubclassOf, arginfo_reflection_class_isSubclassOf, 0) @@@ -5892,12 -5399,10 +5892,12 @@@ static const zend_function_entry reflec ZEND_ME(reflection_parameter, __toString, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getName, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isPassedByReference, arginfo_reflection__void, 0) + ZEND_ME(reflection_parameter, canBePassedByValue, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getDeclaringFunction, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getDeclaringClass, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getClass, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isArray, arginfo_reflection__void, 0) + ZEND_ME(reflection_parameter, isCallable, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, allowsNull, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getPosition, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isOptional, arginfo_reflection__void, 0) @@@ -5929,25 -5434,6 +5929,25 @@@ static const zend_function_entry reflec ZEND_ME(reflection_extension, getClassNames, arginfo_reflection__void, 0) ZEND_ME(reflection_extension, getDependencies, arginfo_reflection__void, 0) ZEND_ME(reflection_extension, info, arginfo_reflection__void, 0) + ZEND_ME(reflection_extension, isPersistent, arginfo_reflection__void, 0) + ZEND_ME(reflection_extension, isTemporary, arginfo_reflection__void, 0) + PHP_FE_END +}; + +ZEND_BEGIN_ARG_INFO(arginfo_reflection_zend_extension___construct, 0) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +static const zend_function_entry reflection_zend_extension_functions[] = { + ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) + ZEND_ME(reflection_zend_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) + ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_extension___construct, 0) + ZEND_ME(reflection_zend_extension, __toString, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getName, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getVersion, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getAuthor, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getURL, arginfo_reflection__void, 0) + ZEND_ME(reflection_zend_extension, getCopyright, arginfo_reflection__void, 0) PHP_FE_END }; /* }}} */ @@@ -5959,19 -5445,19 +5959,19 @@@ const zend_function_entry reflection_ex static zend_object_handlers *zend_std_obj_handlers; /* {{{ _reflection_write_property */ -static void _reflection_write_property(zval *object, zval *member, zval *value TSRMLS_DC) +static void _reflection_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) { if ((Z_TYPE_P(member) == IS_STRING) - && zend_hash_exists(&Z_OBJCE_P(object)->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) + && zend_hash_exists(&Z_OBJCE_P(object)->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1) && ((Z_STRLEN_P(member) == sizeof("name") - 1 && !memcmp(Z_STRVAL_P(member), "name", sizeof("name"))) || (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class"))))) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot set read-only property %s::$%s", Z_OBJCE_P(object)->name, Z_STRVAL_P(member)); } else { - zend_std_obj_handlers->write_property(object, member, value TSRMLS_CC); + zend_std_obj_handlers->write_property(object, member, value, key TSRMLS_CC); } } /* }}} */ @@@ -6058,12 -5544,6 +6058,12 @@@ PHP_MINIT_FUNCTION(reflection) /* {{{ * reflection_register_implement(reflection_extension_ptr, reflector_ptr TSRMLS_CC); zend_declare_property_string(reflection_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); + INIT_CLASS_ENTRY(_reflection_entry, "ReflectionZendExtension", reflection_zend_extension_functions); + _reflection_entry.create_object = reflection_objects_new; + reflection_zend_extension_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC); + reflection_register_implement(reflection_zend_extension_ptr, reflector_ptr TSRMLS_CC); + zend_declare_property_string(reflection_zend_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); + return SUCCESS; } /* }}} */ @@@ -6072,7 -5552,7 +6072,7 @@@ PHP_MINFO_FUNCTION(reflection) /* {{{ * php_info_print_table_start(); php_info_print_table_header(2, "Reflection", "enabled"); - php_info_print_table_row(2, "Version", "$Revision$"); + php_info_print_table_row(2, "Version", "$Id$"); php_info_print_table_end(); } /* }}} */ @@@ -6086,7 -5566,7 +6086,7 @@@ zend_module_entry reflection_module_ent NULL, NULL, PHP_MINFO(reflection), - "$Revision$", + "$Id$", STANDARD_MODULE_PROPERTIES }; /* }}} */ diff --combined ext/simplexml/simplexml.c index 334dcd4,a379111..455280f --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@@ -389,7 -389,7 +389,7 @@@ static zval * sxe_prop_dim_read(zval *o /* {{{ sxe_property_read() */ -static zval * sxe_property_read(zval *object, zval *member, int type TSRMLS_DC) +static zval * sxe_property_read(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) { return sxe_prop_dim_read(object, member, 1, 0, type TSRMLS_CC); } @@@ -680,7 -680,7 +680,7 @@@ next_iter /* {{{ sxe_property_write() */ -static void sxe_property_write(zval *object, zval *member, zval *value TSRMLS_DC) +static void sxe_property_write(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) { sxe_prop_dim_write(object, member, value, 1, 0, NULL TSRMLS_CC); } @@@ -694,7 -694,7 +694,7 @@@ static void sxe_dimension_write(zval *o } /* }}} */ -static zval** sxe_property_get_adr(zval *object, zval *member TSRMLS_DC) /* {{{ */ +static zval** sxe_property_get_adr(zval *object, zval *member, const zend_literal *key TSRMLS_DC) /* {{{ */ { php_sxe_object *sxe; xmlNodePtr node; @@@ -846,7 -846,7 +846,7 @@@ static int sxe_prop_dim_exists(zval *ob /* {{{ sxe_property_exists() */ -static int sxe_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC) +static int sxe_property_exists(zval *object, zval *member, int check_empty, const zend_literal *key TSRMLS_DC) { return sxe_prop_dim_exists(object, member, check_empty, 1, 0 TSRMLS_CC); } @@@ -971,7 -971,7 +971,7 @@@ next_iter /* {{{ sxe_property_delete() */ -static void sxe_property_delete(zval *object, zval *member TSRMLS_DC) +static void sxe_property_delete(zval *object, zval *member, const zend_literal *key TSRMLS_DC) { sxe_prop_dim_delete(object, member, 1, 0 TSRMLS_CC); } @@@ -1069,10 -1069,6 +1069,10 @@@ static HashTable * sxe_get_prop_hash(zv xmlAttrPtr attr; int namelen; int test; + char use_iter; + zval *iter_data; + + use_iter = 0; sxe = php_sxe_fetch_object(object TSRMLS_CC); @@@ -1126,7 -1122,6 +1126,7 @@@ GET_NODE(sxe, node); node = php_sxe_get_first_node(sxe, node TSRMLS_CC); + if (node && sxe->iter.type != SXE_ITER_ATTRLIST) { if (node->type == XML_ATTRIBUTE_NODE) { MAKE_STD_ZVAL(value); @@@ -1134,17 -1129,7 +1134,17 @@@ zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); node = NULL; } else if (sxe->iter.type != SXE_ITER_CHILD) { - node = node->children; + + if ( !node->children || !node->parent || node->children->next || node->children->children || node->parent->children == node->parent->last ) { + node = node->children; + } else { + iter_data = sxe->iter.data; + sxe->iter.data = NULL; + + node = php_sxe_reset_iterator(sxe, 0 TSRMLS_CC); + + use_iter = 1; + } } while (node) { @@@ -1176,25 -1161,10 +1176,25 @@@ _get_base_node_value(sxe, node, &value, sxe->iter.nsprefix, sxe->iter.isprefix TSRMLS_CC); - sxe_properties_add(rv, name, namelen, value TSRMLS_CC); + if ( use_iter ) { + zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); + } else { + sxe_properties_add(rv, name, namelen, value TSRMLS_CC); + } next_iter: - node = node->next; + if ( use_iter ) { + node = php_sxe_iterator_fetch(sxe, node->next, 0 TSRMLS_CC); + } else { + node = node->next; + } + } + } + + if ( use_iter ) { + if (sxe->iter.data) { + zval_ptr_dtor(&sxe->iter.data); } + sxe->iter.data = iter_data; } return rv; @@@ -1365,7 -1335,7 +1365,7 @@@ SXE_METHOD(asXML } if (ZEND_NUM_ARGS() == 1) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { RETURN_FALSE; } @@@ -2148,7 -2118,7 +2148,7 @@@ PHP_FUNCTION(simplexml_load_file zend_class_entry *ce= sxe_class_entry; zend_bool isprefix = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|C!lsb", &filename, &filename_len, &ce, &options, &ns, &ns_len, &isprefix) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|C!lsb", &filename, &filename_len, &ce, &options, &ns, &ns_len, &isprefix) == FAILURE) { return; } @@@ -2638,7 -2608,7 +2638,7 @@@ PHP_MINFO_FUNCTION(simplexml { php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision$"); + php_info_print_table_row(2, "Revision", "$Id$"); php_info_print_table_row(2, "Schema support", #ifdef LIBXML_SCHEMAS_ENABLED "enabled"); diff --combined ext/sysvmsg/sysvmsg.c index 9ba10cb,bf99fb0..6360183 --- a/ext/sysvmsg/sysvmsg.c +++ b/ext/sysvmsg/sysvmsg.c @@@ -145,7 -145,7 +145,7 @@@ PHP_MINFO_FUNCTION(sysvmsg { php_info_print_table_start(); php_info_print_table_row(2, "sysvmsg support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision$"); + php_info_print_table_row(2, "Revision", "$Id$"); php_info_print_table_end(); } /* }}} */ @@@ -271,7 -271,7 +271,7 @@@ PHP_FUNCTION(msg_get_queue RETURN_FALSE; } } - RETVAL_RESOURCE(zend_list_insert(mq, le_sysvmsg)); + RETVAL_RESOURCE(zend_list_insert(mq, le_sysvmsg TSRMLS_CC)); } /* }}} */ diff --combined sapi/continuity/capi.c index f6a2d06,cdf7283..96c3923 --- a/sapi/continuity/capi.c +++ b/sapi/continuity/capi.c @@@ -110,7 -110,7 +110,7 @@@ PHP_MSHUTDOWN_FUNCTION(continuity PHP_MINFO_FUNCTION(continuity) { php_info_print_table_start(); - php_info_print_table_row(2, "Continuity Module Revision", "$Revision$"); + php_info_print_table_row(2, "Continuity Module Revision", "$Id$"); php_info_print_table_row(2, "Server Version", conFget_build()); #ifdef CONTINUITY_CDPEXT php_info_print_table_row(2,"CDP Extensions", "enabled"); @@@ -343,8 -343,9 +343,8 @@@ static void sapi_capi_register_server_v } -static void capi_log_message(char *message) +static void capi_log_message(char *message TSRMLS_DC) { - TSRMLS_FETCH(); capi_request_context *rc = (capi_request_context *) SG(server_context); logFmsg(0, "mod/php: %s", message); } diff --combined sapi/nsapi/nsapi.c index 7e009df,202bf54..1579ef7 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@@ -312,7 -312,7 +312,7 @@@ PHP_MSHUTDOWN_FUNCTION(nsapi PHP_MINFO_FUNCTION(nsapi) { php_info_print_table_start(); - php_info_print_table_row(2, "NSAPI Module Revision", "$Revision$"); + php_info_print_table_row(2, "NSAPI Module Revision", "$Id$"); php_info_print_table_row(2, "Server Software", system_version()); php_info_print_table_row(2, "Sub-requests with nsapi_virtual()", (nsapi_servact_service)?((zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0))?"not supported with zlib.output_compression":"enabled"):"not supported on this platform" ); @@@ -347,7 -347,7 +347,7 @@@ PHP_FUNCTION(nsapi_virtual php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Sub-requests do not work with zlib.output_compression", uri); RETURN_FALSE; } else { - php_end_ob_buffers(1 TSRMLS_CC); + php_output_end_all(TSRMLS_C); php_header(TSRMLS_C); /* do the sub-request */ @@@ -414,7 -414,9 +414,7 @@@ PHP_FUNCTION(nsapi_request_headers for (i=0; i < rc->rq->headers->hsize; i++) { entry=rc->rq->headers->ht[i]; while (entry) { - if (!PG(safe_mode) || strncasecmp(entry->param->name, "authorization", 13)) { - add_assoc_string(return_value, entry->param->name, entry->param->value, 1); - } + add_assoc_string(return_value, entry->param->name, entry->param->value, 1); entry=entry->next; } } @@@ -674,22 -676,24 +674,22 @@@ static void sapi_nsapi_register_server_ for (i=0; i < rc->rq->headers->hsize; i++) { entry=rc->rq->headers->ht[i]; while (entry) { - if (!PG(safe_mode) || strncasecmp(entry->param->name, "authorization", 13)) { - if (strcasecmp(entry->param->name, "content-length")==0 || strcasecmp(entry->param->name, "content-type")==0) { - value=estrdup(entry->param->name); - pos = 0; - } else { - spprintf(&value, 0, "HTTP_%s", entry->param->name); - pos = 5; - } - if (value) { - for(p = value + pos; *p; p++) { - *p = toupper(*p); - if (!isalnum(*p)) { - *p = '_'; - } + if (strcasecmp(entry->param->name, "content-length")==0 || strcasecmp(entry->param->name, "content-type")==0) { + value=estrdup(entry->param->name); + pos = 0; + } else { + spprintf(&value, 0, "HTTP_%s", entry->param->name); + pos = 5; + } + if (value) { + for(p = value + pos; *p; p++) { + *p = toupper(*p); + if (!isalnum(*p)) { + *p = '_'; } - php_register_variable(value, entry->param->value, track_vars_array TSRMLS_CC); - efree(value); } + php_register_variable(value, entry->param->value, track_vars_array TSRMLS_CC); + efree(value); } entry=entry->next; } @@@ -775,8 -779,9 +775,8 @@@ } } -static void nsapi_log_message(char *message) +static void nsapi_log_message(char *message TSRMLS_DC) { - TSRMLS_FETCH(); nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); if (rc) { @@@ -786,7 -791,7 +786,7 @@@ } } -static time_t sapi_nsapi_get_request_time(TSRMLS_D) +static double sapi_nsapi_get_request_time(TSRMLS_D) { return REQ_TIME( ((nsapi_request_context *)SG(server_context))->rq ); } @@@ -1030,7 -1035,7 +1030,7 @@@ int NSAPI_PUBLIC php5_execute(pblock *p nsapi_php_ini_entries(NSLS_C TSRMLS_CC); - if (!PG(safe_mode)) php_handle_auth_data(pblock_findval("authorization", rq->headers) TSRMLS_CC); + php_handle_auth_data(pblock_findval("authorization", rq->headers) TSRMLS_CC); file_handle.type = ZEND_HANDLE_FILENAME; file_handle.filename = SG(request_info).path_translated;