From 3f3ac4de25486fabae99d1d648583d4bd852a592 Mon Sep 17 00:00:00 2001 From: Jorg Adam Sowa Date: Thu, 13 Mar 2025 13:14:31 +0100 Subject: [PATCH 1/6] [skip ci] Remove wrappers comments in session ext (#18017) --- ext/session/mod_user_class.c | 14 -- ext/session/session.c | 281 ++++++++++++----------------------- 2 files changed, 92 insertions(+), 203 deletions(-) diff --git a/ext/session/mod_user_class.c b/ext/session/mod_user_class.c index 853db659887be..22be2cd151949 100644 --- a/ext/session/mod_user_class.c +++ b/ext/session/mod_user_class.c @@ -34,7 +34,6 @@ RETURN_FALSE; \ } -/* {{{ Wraps the old open handler */ PHP_METHOD(SessionHandler, open) { char *save_path = NULL, *session_name = NULL; @@ -60,9 +59,7 @@ PHP_METHOD(SessionHandler, open) RETURN_BOOL(SUCCESS == ret); } -/* }}} */ -/* {{{ Wraps the old close handler */ PHP_METHOD(SessionHandler, close) { zend_result ret; @@ -84,9 +81,7 @@ PHP_METHOD(SessionHandler, close) RETURN_BOOL(SUCCESS == ret); } -/* }}} */ -/* {{{ Wraps the old read handler */ PHP_METHOD(SessionHandler, read) { zend_string *val; @@ -104,9 +99,7 @@ PHP_METHOD(SessionHandler, read) RETURN_STR(val); } -/* }}} */ -/* {{{ Wraps the old write handler */ PHP_METHOD(SessionHandler, write) { zend_string *key, *val; @@ -119,9 +112,7 @@ PHP_METHOD(SessionHandler, write) RETURN_BOOL(SUCCESS == PS(default_mod)->s_write(&PS(mod_data), key, val, PS(gc_maxlifetime))); } -/* }}} */ -/* {{{ Wraps the old destroy handler */ PHP_METHOD(SessionHandler, destroy) { zend_string *key; @@ -134,9 +125,7 @@ PHP_METHOD(SessionHandler, destroy) RETURN_BOOL(SUCCESS == PS(default_mod)->s_destroy(&PS(mod_data), key)); } -/* }}} */ -/* {{{ Wraps the old gc handler */ PHP_METHOD(SessionHandler, gc) { zend_long maxlifetime; @@ -153,9 +142,7 @@ PHP_METHOD(SessionHandler, gc) } RETURN_LONG(nrdels); } -/* }}} */ -/* {{{ Wraps the old create_sid handler */ PHP_METHOD(SessionHandler, create_sid) { zend_string *id; @@ -170,4 +157,3 @@ PHP_METHOD(SessionHandler, create_sid) RETURN_STR(id); } -/* }}} */ diff --git a/ext/session/session.c b/ext/session/session.c index ae6576856e48e..fd877483c0a6f 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -105,7 +105,7 @@ static zend_result php_session_abort(void); static int my_module_number = 0; /* Dispatched by RINIT and by php_session_destroy */ -static inline void php_rinit_session_globals(void) /* {{{ */ +static inline void php_rinit_session_globals(void) { /* Do NOT init PS(mod_user_names) here! */ /* TODO: These could be moved to MINIT and removed. These should be initialized by php_rshutdown_session_globals() always when execution is finished. */ @@ -120,9 +120,8 @@ static inline void php_rinit_session_globals(void) /* {{{ */ PS(module_number) = my_module_number; ZVAL_UNDEF(&PS(http_session_vars)); } -/* }}} */ -static inline void php_session_headers_already_sent_error(int severity, const char *message) { /* {{{ */ +static inline void php_session_headers_already_sent_error(int severity, const char *message) { const char *output_start_filename = php_output_get_start_filename(); int output_start_lineno = php_output_get_start_lineno(); if (output_start_filename != NULL) { @@ -131,9 +130,8 @@ static inline void php_session_headers_already_sent_error(int severity, const ch php_error_docref(NULL, severity, "%s", message); } } -/* }}} */ -static inline void php_session_session_already_started_error(int severity, const char *message) { /* {{{ */ +static inline void php_session_session_already_started_error(int severity, const char *message) { if (PS(session_started_filename) != NULL) { php_error_docref(NULL, severity, "%s (started from %s on line %"PRIu32")", message, ZSTR_VAL(PS(session_started_filename)), PS(session_started_lineno)); } else if (PS(auto_start)) { @@ -143,9 +141,8 @@ static inline void php_session_session_already_started_error(int severity, const php_error_docref(NULL, severity, "%s", message); } } -/* }}} */ -static inline void php_session_cleanup_filename(void) /* {{{ */ +static inline void php_session_cleanup_filename(void) { if (PS(session_started_filename)) { zend_string_release(PS(session_started_filename)); @@ -153,10 +150,9 @@ static inline void php_session_cleanup_filename(void) /* {{{ */ PS(session_started_lineno) = 0; } } -/* }}} */ /* Dispatched by RSHUTDOWN and by php_session_destroy */ -static void php_rshutdown_session_globals(void) /* {{{ */ +static void php_rshutdown_session_globals(void) { /* Do NOT destroy PS(mod_user_names) here! */ if (!Z_ISUNDEF(PS(http_session_vars))) { @@ -189,9 +185,8 @@ static void php_rshutdown_session_globals(void) /* {{{ */ /* Set session status to prevent error while restoring save handler INI value. */ PS(session_status) = php_session_none; } -/* }}} */ -PHPAPI zend_result php_session_destroy(void) /* {{{ */ +PHPAPI zend_result php_session_destroy(void) { zend_result retval = SUCCESS; @@ -212,9 +207,8 @@ PHPAPI zend_result php_session_destroy(void) /* {{{ */ return retval; } -/* }}} */ -PHPAPI void php_add_session_var(zend_string *name) /* {{{ */ +PHPAPI void php_add_session_var(zend_string *name) { IF_SESSION_VARS() { zval *sess_var = Z_REFVAL(PS(http_session_vars)); @@ -226,9 +220,8 @@ PHPAPI void php_add_session_var(zend_string *name) /* {{{ */ } } } -/* }}} */ -PHPAPI zval* php_set_session_var(zend_string *name, zval *state_val, php_unserialize_data_t *var_hash) /* {{{ */ +PHPAPI zval* php_set_session_var(zend_string *name, zval *state_val, php_unserialize_data_t *var_hash) { IF_SESSION_VARS() { zval *sess_var = Z_REFVAL(PS(http_session_vars)); @@ -237,16 +230,14 @@ PHPAPI zval* php_set_session_var(zend_string *name, zval *state_val, php_unseria } return NULL; } -/* }}} */ -PHPAPI zval* php_get_session_var(zend_string *name) /* {{{ */ +PHPAPI zval* php_get_session_var(zend_string *name) { IF_SESSION_VARS() { return zend_hash_find(Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars))), name); } return NULL; } -/* }}} */ PHPAPI zval* php_get_session_var_str(const char *name, size_t name_len) { @@ -256,7 +247,7 @@ PHPAPI zval* php_get_session_var_str(const char *name, size_t name_len) return NULL; } -static void php_session_track_init(void) /* {{{ */ +static void php_session_track_init(void) { zval session_vars; zend_string *var_name = ZSTR_INIT_LITERAL("_SESSION", 0); @@ -273,9 +264,8 @@ static void php_session_track_init(void) /* {{{ */ zend_hash_update_ind(&EG(symbol_table), var_name, &PS(http_session_vars)); zend_string_release_ex(var_name, 0); } -/* }}} */ -static zend_string *php_session_encode(void) /* {{{ */ +static zend_string *php_session_encode(void) { IF_SESSION_VARS() { ZEND_ASSERT(PS(serializer)); @@ -285,7 +275,6 @@ static zend_string *php_session_encode(void) /* {{{ */ } return NULL; } -/* }}} */ static ZEND_COLD void php_session_cancel_decode(void) { @@ -294,7 +283,7 @@ static ZEND_COLD void php_session_cancel_decode(void) php_error_docref(NULL, E_WARNING, "Failed to decode session object. Session has been destroyed"); } -static zend_result php_session_decode(zend_string *data) /* {{{ */ +static zend_result php_session_decode(zend_string *data) { ZEND_ASSERT(PS(serializer)); zend_result result = SUCCESS; @@ -309,7 +298,6 @@ static zend_result php_session_decode(zend_string *data) /* {{{ */ } zend_end_try(); return result; } -/* }}} */ /* * Note that we cannot use the BASE64 alphabet here, because @@ -319,7 +307,7 @@ static zend_result php_session_decode(zend_string *data) /* {{{ */ static const char hexconvtab[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,-"; -static void bin_to_readable(unsigned char *in, size_t inlen, char *out, size_t outlen, char nbits) /* {{{ */ +static void bin_to_readable(unsigned char *in, size_t inlen, char *out, size_t outlen, char nbits) { unsigned char *p, *q; unsigned short w; @@ -353,9 +341,8 @@ static void bin_to_readable(unsigned char *in, size_t inlen, char *out, size_t o *out = '\0'; } -/* }}} */ -PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */ +PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) { unsigned char rbuf[PS_MAX_SID_LENGTH]; zend_string *outid; @@ -374,12 +361,11 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */ return outid; } -/* }}} */ /* Default session id char validation function allowed by ps_modules. * If you change the logic here, please also update the error message in * ps_modules appropriately */ -PHPAPI zend_result php_session_valid_key(const char *key) /* {{{ */ +PHPAPI zend_result php_session_valid_key(const char *key) { size_t len; const char *p; @@ -406,10 +392,9 @@ PHPAPI zend_result php_session_valid_key(const char *key) /* {{{ */ return SUCCESS; } -/* }}} */ -static zend_long php_session_gc(bool immediate) /* {{{ */ +static zend_long php_session_gc(bool immediate) { zend_long num = -1; bool collect = immediate; @@ -425,9 +410,9 @@ static zend_long php_session_gc(bool immediate) /* {{{ */ } } return num; -} /* }}} */ +} -static zend_result php_session_initialize(void) /* {{{ */ +static zend_result php_session_initialize(void) { zend_string *val = NULL; @@ -520,9 +505,8 @@ static zend_result php_session_initialize(void) /* {{{ */ } return SUCCESS; } -/* }}} */ -static void php_session_save_current_state(int write) /* {{{ */ +static void php_session_save_current_state(int write) { zend_result ret = FAILURE; @@ -578,9 +562,8 @@ static void php_session_save_current_state(int write) /* {{{ */ PS(mod)->s_close(&PS(mod_data)); } } -/* }}} */ -static void php_session_normalize_vars(void) /* {{{ */ +static void php_session_normalize_vars(void) { PS_ENCODE_VARS; @@ -594,13 +577,12 @@ static void php_session_normalize_vars(void) /* {{{ */ ); } } -/* }}} */ /* ************************* * INI Settings/Handlers * ************************* */ -static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */ +static PHP_INI_MH(OnUpdateSaveHandler) { const ps_module *tmp; int err_type = E_ERROR; @@ -634,9 +616,8 @@ static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */ return SUCCESS; } -/* }}} */ -static PHP_INI_MH(OnUpdateSerializer) /* {{{ */ +static PHP_INI_MH(OnUpdateSerializer) { const ps_serializer *tmp; @@ -664,9 +645,8 @@ static PHP_INI_MH(OnUpdateSerializer) /* {{{ */ return SUCCESS; } -/* }}} */ -static PHP_INI_MH(OnUpdateSaveDir) /* {{{ */ +static PHP_INI_MH(OnUpdateSaveDir) { SESSION_CHECK_ACTIVE_STATE; SESSION_CHECK_OUTPUT_STATE; @@ -697,10 +677,9 @@ static PHP_INI_MH(OnUpdateSaveDir) /* {{{ */ return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } -/* }}} */ -static PHP_INI_MH(OnUpdateName) /* {{{ */ +static PHP_INI_MH(OnUpdateName) { SESSION_CHECK_ACTIVE_STATE; SESSION_CHECK_OUTPUT_STATE; @@ -729,10 +708,9 @@ static PHP_INI_MH(OnUpdateName) /* {{{ */ return OnUpdateStringUnempty(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } -/* }}} */ -static PHP_INI_MH(OnUpdateCookieLifetime) /* {{{ */ +static PHP_INI_MH(OnUpdateCookieLifetime) { SESSION_CHECK_ACTIVE_STATE; SESSION_CHECK_OUTPUT_STATE; @@ -751,37 +729,32 @@ static PHP_INI_MH(OnUpdateCookieLifetime) /* {{{ */ } return OnUpdateLongGEZero(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } -/* }}} */ -static PHP_INI_MH(OnUpdateSessionLong) /* {{{ */ +static PHP_INI_MH(OnUpdateSessionLong) { SESSION_CHECK_ACTIVE_STATE; SESSION_CHECK_OUTPUT_STATE; return OnUpdateLong(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } -/* }}} */ - -static PHP_INI_MH(OnUpdateSessionString) /* {{{ */ +static PHP_INI_MH(OnUpdateSessionString) { SESSION_CHECK_ACTIVE_STATE; SESSION_CHECK_OUTPUT_STATE; return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } -/* }}} */ -static PHP_INI_MH(OnUpdateSessionBool) /* {{{ */ +static PHP_INI_MH(OnUpdateSessionBool) { SESSION_CHECK_ACTIVE_STATE; SESSION_CHECK_OUTPUT_STATE; return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } -/* }}} */ -static PHP_INI_MH(OnUpdateSidLength) /* {{{ */ +static PHP_INI_MH(OnUpdateSidLength) { zend_long val; char *endptr = NULL; @@ -802,9 +775,8 @@ static PHP_INI_MH(OnUpdateSidLength) /* {{{ */ php_error_docref(NULL, E_WARNING, "session.configuration \"session.sid_length\" must be between 22 and 256"); return FAILURE; } -/* }}} */ -static PHP_INI_MH(OnUpdateSidBits) /* {{{ */ +static PHP_INI_MH(OnUpdateSidBits) { zend_long val; char *endptr = NULL; @@ -825,9 +797,8 @@ static PHP_INI_MH(OnUpdateSidBits) /* {{{ */ php_error_docref(NULL, E_WARNING, "session.configuration \"session.sid_bits_per_character\" must be between 4 and 6"); return FAILURE; } -/* }}} */ -static PHP_INI_MH(OnUpdateSessionGcProbability) /* {{{ */ +static PHP_INI_MH(OnUpdateSessionGcProbability) { SESSION_CHECK_ACTIVE_STATE; SESSION_CHECK_OUTPUT_STATE; @@ -844,9 +815,8 @@ static PHP_INI_MH(OnUpdateSessionGcProbability) /* {{{ */ return SUCCESS; } -/* }}} */ -static PHP_INI_MH(OnUpdateSessionDivisor) /* {{{ */ +static PHP_INI_MH(OnUpdateSessionDivisor) { SESSION_CHECK_ACTIVE_STATE; SESSION_CHECK_OUTPUT_STATE; @@ -863,9 +833,8 @@ static PHP_INI_MH(OnUpdateSessionDivisor) /* {{{ */ return SUCCESS; } -/* }}} */ -static PHP_INI_MH(OnUpdateRfc1867Freq) /* {{{ */ +static PHP_INI_MH(OnUpdateRfc1867Freq) { int tmp = ZEND_ATOL(ZSTR_VAL(new_value)); if(tmp < 0) { @@ -882,7 +851,7 @@ static PHP_INI_MH(OnUpdateRfc1867Freq) /* {{{ */ PS(rfc1867_freq) = tmp; } return SUCCESS; -} /* }}} */ +} static PHP_INI_MH(OnUpdateUseOnlyCookies) { @@ -918,7 +887,6 @@ static PHP_INI_MH(OnUpdateRefererCheck) return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } -/* {{{ PHP_INI */ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("session.save_path", "", PHP_INI_ALL, OnUpdateSaveDir, save_path, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.name", "PHPSESSID", PHP_INI_ALL, OnUpdateName, session_name, php_ps_globals, ps_globals) @@ -961,12 +929,11 @@ PHP_INI_BEGIN() /* Commented out until future discussion */ /* PHP_INI_ENTRY("session.encode_sources", "globals,track", PHP_INI_ALL, NULL) */ PHP_INI_END() -/* }}} */ /* *************** * Serializers * *************** */ -PS_SERIALIZER_ENCODE_FUNC(php_serialize) /* {{{ */ +PS_SERIALIZER_ENCODE_FUNC(php_serialize) { smart_str buf = {0}; php_serialize_data_t var_hash; @@ -978,9 +945,8 @@ PS_SERIALIZER_ENCODE_FUNC(php_serialize) /* {{{ */ } return buf.s; } -/* }}} */ -PS_SERIALIZER_DECODE_FUNC(php_serialize) /* {{{ */ +PS_SERIALIZER_DECODE_FUNC(php_serialize) { const char *endptr = val + vallen; zval session_vars; @@ -1010,13 +976,12 @@ PS_SERIALIZER_DECODE_FUNC(php_serialize) /* {{{ */ zend_string_release_ex(var_name, 0); return result || !vallen ? SUCCESS : FAILURE; } -/* }}} */ #define PS_BIN_NR_OF_BITS 8 #define PS_BIN_UNDEF (1<<(PS_BIN_NR_OF_BITS-1)) #define PS_BIN_MAX (PS_BIN_UNDEF-1) -PS_SERIALIZER_ENCODE_FUNC(php_binary) /* {{{ */ +PS_SERIALIZER_ENCODE_FUNC(php_binary) { smart_str buf = {0}; php_serialize_data_t var_hash; @@ -1036,9 +1001,8 @@ PS_SERIALIZER_ENCODE_FUNC(php_binary) /* {{{ */ return buf.s; } -/* }}} */ -PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */ +PS_SERIALIZER_DECODE_FUNC(php_binary) { const char *p; const char *endptr = val + vallen; @@ -1077,11 +1041,10 @@ PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */ return SUCCESS; } -/* }}} */ #define PS_DELIMITER '|' -PS_SERIALIZER_ENCODE_FUNC(php) /* {{{ */ +PS_SERIALIZER_ENCODE_FUNC(php) { smart_str buf = {0}; php_serialize_data_t var_hash; @@ -1111,9 +1074,8 @@ PS_SERIALIZER_ENCODE_FUNC(php) /* {{{ */ PHP_VAR_SERIALIZE_DESTROY(var_hash); return buf.s; } -/* }}} */ -PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */ +PS_SERIALIZER_DECODE_FUNC(php) { const char *p, *q; const char *endptr = val + vallen; @@ -1160,7 +1122,6 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */ return retval; } -/* }}} */ #define MAX_SERIALIZERS 32 #define PREDEFINED_SERIALIZERS 3 @@ -1171,7 +1132,7 @@ static ps_serializer ps_serializers[MAX_SERIALIZERS + 1] = { PS_SERIALIZER_ENTRY(php_binary) }; -PHPAPI zend_result php_session_register_serializer(const char *name, zend_string *(*encode)(PS_SERIALIZER_ENCODE_ARGS), zend_result (*decode)(PS_SERIALIZER_DECODE_ARGS)) /* {{{ */ +PHPAPI zend_result php_session_register_serializer(const char *name, zend_string *(*encode)(PS_SERIALIZER_ENCODE_ARGS), zend_result (*decode)(PS_SERIALIZER_DECODE_ARGS)) { zend_result ret = FAILURE; @@ -1187,7 +1148,6 @@ PHPAPI zend_result php_session_register_serializer(const char *name, zend_string } return ret; } -/* }}} */ /* ******************* * Storage Modules * @@ -1201,7 +1161,7 @@ static const ps_module *ps_modules[MAX_MODULES + 1] = { ps_user_ptr }; -PHPAPI zend_result php_session_register_module(const ps_module *ptr) /* {{{ */ +PHPAPI zend_result php_session_register_module(const ps_module *ptr) { int ret = FAILURE; @@ -1214,7 +1174,6 @@ PHPAPI zend_result php_session_register_module(const ps_module *ptr) /* {{{ */ } return ret; } -/* }}} */ /* Dummy PS module function */ /* We consider any ID valid (thus also implying that a session with such an ID exists), @@ -1253,7 +1212,7 @@ static const char *week_days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; -static inline void strcpy_gmt(char *ubuf, time_t *when) /* {{{ */ +static inline void strcpy_gmt(char *ubuf, time_t *when) { char buf[MAX_STR]; struct tm tm, *res; @@ -1274,9 +1233,8 @@ static inline void strcpy_gmt(char *ubuf, time_t *when) /* {{{ */ memcpy(ubuf, buf, n); ubuf[n] = '\0'; } -/* }}} */ -static inline void last_modified(void) /* {{{ */ +static inline void last_modified(void) { const char *path; zend_stat_t sb = {0}; @@ -1294,10 +1252,9 @@ static inline void last_modified(void) /* {{{ */ ADD_HEADER(buf); } } -/* }}} */ #define EXPIRES "Expires: " -CACHE_LIMITER_FUNC(public) /* {{{ */ +CACHE_LIMITER_FUNC(public) { char buf[MAX_STR + 1]; struct timeval tv; @@ -1314,9 +1271,8 @@ CACHE_LIMITER_FUNC(public) /* {{{ */ last_modified(); } -/* }}} */ -CACHE_LIMITER_FUNC(private_no_expire) /* {{{ */ +CACHE_LIMITER_FUNC(private_no_expire) { char buf[MAX_STR + 1]; @@ -1325,16 +1281,14 @@ CACHE_LIMITER_FUNC(private_no_expire) /* {{{ */ last_modified(); } -/* }}} */ -CACHE_LIMITER_FUNC(private) /* {{{ */ +CACHE_LIMITER_FUNC(private) { ADD_HEADER("Expires: Thu, 19 Nov 1981 08:52:00 GMT"); CACHE_LIMITER(private_no_expire)(); } -/* }}} */ -CACHE_LIMITER_FUNC(nocache) /* {{{ */ +CACHE_LIMITER_FUNC(nocache) { ADD_HEADER("Expires: Thu, 19 Nov 1981 08:52:00 GMT"); @@ -1344,7 +1298,6 @@ CACHE_LIMITER_FUNC(nocache) /* {{{ */ /* For HTTP/1.0 conforming clients */ ADD_HEADER("Pragma: no-cache"); } -/* }}} */ static const php_session_cache_limiter_t php_session_cache_limiters[] = { CACHE_LIMITER_ENTRY(public) @@ -1354,7 +1307,7 @@ static const php_session_cache_limiter_t php_session_cache_limiters[] = { {0} }; -static int php_session_cache_limiter(void) /* {{{ */ +static int php_session_cache_limiter(void) { const php_session_cache_limiter_t *lim; @@ -1376,7 +1329,6 @@ static int php_session_cache_limiter(void) /* {{{ */ return -1; } -/* }}} */ /* ********************* * Cookie Management * @@ -1425,7 +1377,7 @@ static void php_session_remove_cookie(void) { efree(session_cookie); } -static zend_result php_session_send_cookie(void) /* {{{ */ +static zend_result php_session_send_cookie(void) { smart_str ncookie = {0}; zend_string *date_fmt = NULL; @@ -1499,9 +1451,8 @@ static zend_result php_session_send_cookie(void) /* {{{ */ return SUCCESS; } -/* }}} */ -PHPAPI const ps_module *_php_find_ps_module(const char *name) /* {{{ */ +PHPAPI const ps_module *_php_find_ps_module(const char *name) { const ps_module *ret = NULL; const ps_module **mod; @@ -1515,9 +1466,8 @@ PHPAPI const ps_module *_php_find_ps_module(const char *name) /* {{{ */ } return ret; } -/* }}} */ -PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name) /* {{{ */ +PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name) { const ps_serializer *ret = NULL; const ps_serializer *mod; @@ -1530,7 +1480,6 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name) /* {{{ */ } return ret; } -/* }}} */ static void ppid2sid(zval *ppid) { ZVAL_DEREF(ppid); @@ -1544,7 +1493,7 @@ static void ppid2sid(zval *ppid) { } -PHPAPI zend_result php_session_reset_id(void) /* {{{ */ +PHPAPI zend_result php_session_reset_id(void) { int module_number = PS(module_number); zval *sid, *data, *ppid; @@ -1614,10 +1563,9 @@ PHPAPI zend_result php_session_reset_id(void) /* {{{ */ } return SUCCESS; } -/* }}} */ -PHPAPI zend_result php_session_start(void) /* {{{ */ +PHPAPI zend_result php_session_start(void) { zval *ppid; zval *data; @@ -1724,9 +1672,8 @@ PHPAPI zend_result php_session_start(void) /* {{{ */ return SUCCESS; } -/* }}} */ -PHPAPI zend_result php_session_flush(int write) /* {{{ */ +PHPAPI zend_result php_session_flush(int write) { if (PS(session_status) == php_session_active) { php_session_save_current_state(write); @@ -1735,14 +1682,13 @@ PHPAPI zend_result php_session_flush(int write) /* {{{ */ } return FAILURE; } -/* }}} */ PHPAPI php_session_status php_get_session_status(void) { return PS(session_status); } -static zend_result php_session_abort(void) /* {{{ */ +static zend_result php_session_abort(void) { if (PS(session_status) == php_session_active) { if (PS(mod_data) || PS(mod_user_implemented)) { @@ -1753,9 +1699,8 @@ static zend_result php_session_abort(void) /* {{{ */ } return FAILURE; } -/* }}} */ -static zend_result php_session_reset(void) /* {{{ */ +static zend_result php_session_reset(void) { if (PS(session_status) == php_session_active && php_session_initialize() == SUCCESS) { @@ -1763,26 +1708,22 @@ static zend_result php_session_reset(void) /* {{{ */ } return FAILURE; } -/* }}} */ /* This API is not used by any PHP modules including session currently. session_adapt_url() may be used to set Session ID to target url without starting "URL-Rewriter" output handler. */ -PHPAPI void session_adapt_url(const char *url, size_t url_len, char **new_url, size_t *new_len) /* {{{ */ +PHPAPI void session_adapt_url(const char *url, size_t url_len, char **new_url, size_t *new_len) { if (APPLY_TRANS_SID && (PS(session_status) == php_session_active)) { *new_url = php_url_scanner_adapt_single_url(url, url_len, PS(session_name), ZSTR_VAL(PS(id)), new_len, 1); } } -/* }}} */ /* ******************************** * Userspace exported functions * ******************************** */ -/* {{{ session_set_cookie_params(array options) - Set session cookie parameters */ PHP_FUNCTION(session_set_cookie_params) { HashTable *options_ht; @@ -1950,9 +1891,7 @@ PHP_FUNCTION(session_set_cookie_params) if (samesite) zend_string_release(samesite); } } -/* }}} */ -/* {{{ Return the session cookie parameters */ PHP_FUNCTION(session_get_cookie_params) { if (zend_parse_parameters_none() == FAILURE) { @@ -1968,9 +1907,8 @@ PHP_FUNCTION(session_get_cookie_params) add_assoc_bool(return_value, "httponly", PS(cookie_httponly)); add_assoc_string(return_value, "samesite", PS(cookie_samesite)); } -/* }}} */ -/* {{{ Return the current session name. If new name is given, the session name is replaced with new name */ +/* Return the current session name. If new name is given, the session name is replaced with new name */ PHP_FUNCTION(session_name) { zend_string *name = NULL; @@ -1998,9 +1936,8 @@ PHP_FUNCTION(session_name) zend_string_release_ex(ini_name, 0); } } -/* }}} */ -/* {{{ Return the current module name used for accessing session data. If newname is given, the module name is replaced with newname */ +/* Return the current module name used for accessing session data. If newname is given, the module name is replaced with newname */ PHP_FUNCTION(session_module_name) { zend_string *name = NULL; @@ -2048,7 +1985,6 @@ PHP_FUNCTION(session_module_name) zend_string_release_ex(ini_name, 0); } } -/* }}} */ static bool can_session_handler_be_changed(void) { if (PS(session_status) == php_session_active) { @@ -2108,7 +2044,6 @@ static inline void set_user_save_handler_ini(void) { SESSION_SET_USER_HANDLER_PROCEDURAL(struct_name, fci); \ } -/* {{{ Sets user-level functions */ PHP_FUNCTION(session_set_save_handler) { /* OOP Version */ @@ -2277,9 +2212,8 @@ PHP_FUNCTION(session_set_save_handler) RETURN_TRUE; } -/* }}} */ -/* {{{ Return the current save path passed to module_name. If newname is given, the save path is replaced with newname */ +/* Return the current save path passed to module_name. If newname is given, the save path is replaced with newname */ PHP_FUNCTION(session_save_path) { zend_string *name = NULL; @@ -2307,9 +2241,8 @@ PHP_FUNCTION(session_save_path) zend_string_release_ex(ini_name, 0); } } -/* }}} */ -/* {{{ Return the current session id. If newid is given, the session id is replaced with newid */ +/* Return the current session id. If newid is given, the session id is replaced with newid */ PHP_FUNCTION(session_id) { zend_string *name = NULL; @@ -2348,9 +2281,8 @@ PHP_FUNCTION(session_id) PS(id) = zend_string_copy(name); } } -/* }}} */ -/* {{{ Update the current session id with a newly generated one. If delete_old_session is set to true, remove the old session. */ +/* Update the current session id with a newly generated one. If delete_old_session is set to true, remove the old session. */ PHP_FUNCTION(session_regenerate_id) { bool del_ses = 0; @@ -2463,9 +2395,8 @@ PHP_FUNCTION(session_regenerate_id) RETURN_TRUE; } -/* }}} */ -/* {{{ Generate new session ID. Intended for user save handlers. */ +/* Generate new session ID. Intended for user save handlers. */ PHP_FUNCTION(session_create_id) { zend_string *prefix = NULL, *new_id; @@ -2519,9 +2450,8 @@ PHP_FUNCTION(session_create_id) } RETVAL_STR(smart_str_extract(&id)); } -/* }}} */ -/* {{{ Return the current cache limiter. If new_cache_limited is given, the current cache_limiter is replaced with new_cache_limiter */ +/* Return the current cache limiter. If new_cache_limited is given, the current cache_limiter is replaced with new_cache_limiter */ PHP_FUNCTION(session_cache_limiter) { zend_string *limiter = NULL; @@ -2549,9 +2479,8 @@ PHP_FUNCTION(session_cache_limiter) zend_string_release_ex(ini_name, 0); } } -/* }}} */ -/* {{{ Return the current cache expire. If new_cache_expire is given, the current cache_expire is replaced with new_cache_expire */ +/* Return the current cache expire. If new_cache_expire is given, the current cache_expire is replaced with new_cache_expire */ PHP_FUNCTION(session_cache_expire) { zend_long expires; @@ -2581,9 +2510,8 @@ PHP_FUNCTION(session_cache_expire) zend_string_release_ex(ini_value, 0); } } -/* }}} */ -/* {{{ Serializes the current setup and returns the serialized representation */ +/* Serializes the current setup and returns the serialized representation */ PHP_FUNCTION(session_encode) { zend_string *enc; @@ -2599,9 +2527,8 @@ PHP_FUNCTION(session_encode) RETURN_STR(enc); } -/* }}} */ -/* {{{ Deserializes data and reinitializes the variables */ +/* Deserializes data and reinitializes the variables */ PHP_FUNCTION(session_decode) { zend_string *str = NULL; @@ -2620,7 +2547,6 @@ PHP_FUNCTION(session_decode) } RETURN_TRUE; } -/* }}} */ static zend_result php_session_start_set_ini(zend_string *varname, zend_string *new_value) { zend_result ret; @@ -2634,7 +2560,6 @@ static zend_result php_session_start_set_ini(zend_string *varname, zend_string * return ret; } -/* {{{ Begin session */ PHP_FUNCTION(session_start) { zval *options = NULL; @@ -2722,9 +2647,7 @@ PHP_FUNCTION(session_start) RETURN_TRUE; } -/* }}} */ -/* {{{ Destroy the current session and all data associated with it */ PHP_FUNCTION(session_destroy) { if (zend_parse_parameters_none() == FAILURE) { @@ -2733,9 +2656,7 @@ PHP_FUNCTION(session_destroy) RETURN_BOOL(php_session_destroy() == SUCCESS); } -/* }}} */ -/* {{{ Unset all registered variables */ PHP_FUNCTION(session_unset) { if (zend_parse_parameters_none() == FAILURE) { @@ -2755,9 +2676,7 @@ PHP_FUNCTION(session_unset) } RETURN_TRUE; } -/* }}} */ -/* {{{ Perform GC and return number of deleted sessions */ PHP_FUNCTION(session_gc) { zend_long num; @@ -2778,10 +2697,8 @@ PHP_FUNCTION(session_gc) RETURN_LONG(num); } -/* }}} */ -/* {{{ Write session data and end session */ PHP_FUNCTION(session_write_close) { if (zend_parse_parameters_none() == FAILURE) { @@ -2794,9 +2711,8 @@ PHP_FUNCTION(session_write_close) php_session_flush(1); RETURN_TRUE; } -/* }}} */ -/* {{{ Abort session and end session. Session data will not be written */ +/* Abort session and end session. Session data will not be written */ PHP_FUNCTION(session_abort) { if (zend_parse_parameters_none() == FAILURE) { @@ -2809,9 +2725,8 @@ PHP_FUNCTION(session_abort) php_session_abort(); RETURN_TRUE; } -/* }}} */ -/* {{{ Reset session data from saved session data */ +/* Reset session data from saved session data */ PHP_FUNCTION(session_reset) { if (zend_parse_parameters_none() == FAILURE) { @@ -2824,9 +2739,7 @@ PHP_FUNCTION(session_reset) php_session_reset(); RETURN_TRUE; } -/* }}} */ -/* {{{ Returns the current session status */ PHP_FUNCTION(session_status) { if (zend_parse_parameters_none() == FAILURE) { @@ -2835,9 +2748,8 @@ PHP_FUNCTION(session_status) RETURN_LONG(PS(session_status)); } -/* }}} */ -/* {{{ Registers session_write_close() as a shutdown function */ +/* Registers session_write_close() as a shutdown function */ PHP_FUNCTION(session_register_shutdown) { php_shutdown_function_entry shutdown_function_entry = { @@ -2869,13 +2781,12 @@ PHP_FUNCTION(session_register_shutdown) php_error_docref(NULL, E_WARNING, "Session shutdown function cannot be registered"); } } -/* }}} */ /* ******************************** * Module Setup and Destruction * ******************************** */ -static zend_result php_rinit_session(bool auto_start) /* {{{ */ +static zend_result php_rinit_session(bool auto_start) { php_rinit_session_globals(); @@ -2909,13 +2820,12 @@ static zend_result php_rinit_session(bool auto_start) /* {{{ */ } return SUCCESS; -} /* }}} */ +} -static PHP_RINIT_FUNCTION(session) /* {{{ */ +static PHP_RINIT_FUNCTION(session) { return php_rinit_session(PS(auto_start)); } -/* }}} */ #define SESSION_FREE_USER_HANDLER(struct_name) \ if (!Z_ISUNDEF(PS(mod_user_names).struct_name)) { \ @@ -2924,7 +2834,7 @@ static PHP_RINIT_FUNCTION(session) /* {{{ */ } -static PHP_RSHUTDOWN_FUNCTION(session) /* {{{ */ +static PHP_RSHUTDOWN_FUNCTION(session) { if (PS(session_status) == php_session_active) { zend_try { @@ -2947,9 +2857,8 @@ static PHP_RSHUTDOWN_FUNCTION(session) /* {{{ */ return SUCCESS; } -/* }}} */ -static PHP_GINIT_FUNCTION(ps) /* {{{ */ +static PHP_GINIT_FUNCTION(ps) { #if defined(COMPILE_DL_SESSION) && defined(ZTS) ZEND_TSRMLS_CACHE_UPDATE(); @@ -2995,9 +2904,8 @@ static PHP_GINIT_FUNCTION(ps) /* {{{ */ } php_random_pcgoneseq128xslrr64_seed128(ps_globals->random.state, seed); } -/* }}} */ -static PHP_MINIT_FUNCTION(session) /* {{{ */ +static PHP_MINIT_FUNCTION(session) { zend_register_auto_global(zend_string_init_interned("_SESSION", sizeof("_SESSION") - 1, 1), 0, NULL); @@ -3027,9 +2935,8 @@ static PHP_MINIT_FUNCTION(session) /* {{{ */ return SUCCESS; } -/* }}} */ -static PHP_MSHUTDOWN_FUNCTION(session) /* {{{ */ +static PHP_MSHUTDOWN_FUNCTION(session) { UNREGISTER_INI_ENTRIES(); @@ -3048,9 +2955,8 @@ static PHP_MSHUTDOWN_FUNCTION(session) /* {{{ */ return SUCCESS; } -/* }}} */ -static PHP_MINFO_FUNCTION(session) /* {{{ */ +static PHP_MINFO_FUNCTION(session) { const ps_module **mod; ps_serializer *ser; @@ -3097,19 +3003,17 @@ static PHP_MINFO_FUNCTION(session) /* {{{ */ DISPLAY_INI_ENTRIES(); } -/* }}} */ -static const zend_module_dep session_deps[] = { /* {{{ */ +static const zend_module_dep session_deps[] = { ZEND_MOD_OPTIONAL("spl") ZEND_MOD_END }; -/* }}} */ /* ************************ * Upload hook handling * ************************ */ -static bool early_find_sid_in(zval *dest, int where, php_session_rfc1867_progress *progress) /* {{{ */ +static bool early_find_sid_in(zval *dest, int where, php_session_rfc1867_progress *progress) { zval *ppid; @@ -3125,9 +3029,9 @@ static bool early_find_sid_in(zval *dest, int where, php_session_rfc1867_progres } return 0; -} /* }}} */ +} -static void php_session_rfc1867_early_find_sid(php_session_rfc1867_progress *progress) /* {{{ */ +static void php_session_rfc1867_early_find_sid(php_session_rfc1867_progress *progress) { if (PS(use_cookies)) { @@ -3142,9 +3046,9 @@ static void php_session_rfc1867_early_find_sid(php_session_rfc1867_progress *pro } sapi_module.treat_data(PARSE_GET, NULL, NULL); early_find_sid_in(&progress->sid, TRACK_VARS_GET, progress); -} /* }}} */ +} -static bool php_check_cancel_upload(php_session_rfc1867_progress *progress) /* {{{ */ +static bool php_check_cancel_upload(php_session_rfc1867_progress *progress) { zval *progress_ary, *cancel_upload; @@ -3158,9 +3062,9 @@ static bool php_check_cancel_upload(php_session_rfc1867_progress *progress) /* { return 0; } return Z_TYPE_P(cancel_upload) == IS_TRUE; -} /* }}} */ +} -static void php_session_rfc1867_update(php_session_rfc1867_progress *progress, int force_update) /* {{{ */ +static void php_session_rfc1867_update(php_session_rfc1867_progress *progress, int force_update) { if (!force_update) { if (Z_LVAL_P(progress->post_bytes_processed) < progress->next_update) { @@ -3192,9 +3096,9 @@ static void php_session_rfc1867_update(php_session_rfc1867_progress *progress, i zend_hash_update(Z_ARRVAL_P(sess_var), progress->key.s, &progress->data); } php_session_flush(1); -} /* }}} */ +} -static void php_session_rfc1867_cleanup(php_session_rfc1867_progress *progress) /* {{{ */ +static void php_session_rfc1867_cleanup(php_session_rfc1867_progress *progress) { php_session_initialize(); PS(session_status) = php_session_active; @@ -3204,9 +3108,9 @@ static void php_session_rfc1867_cleanup(php_session_rfc1867_progress *progress) zend_hash_del(Z_ARRVAL_P(sess_var), progress->key.s); } php_session_flush(1); -} /* }}} */ +} -static zend_result php_session_rfc1867_callback(unsigned int event, void *event_data, void **extra) /* {{{ */ +static zend_result php_session_rfc1867_callback(unsigned int event, void *event_data, void **extra) { php_session_rfc1867_progress *progress; zend_result retval = SUCCESS; @@ -3388,8 +3292,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_ return FAILURE; } return retval; - -} /* }}} */ +} zend_module_entry session_module_entry = { STANDARD_MODULE_HEADER_EX, From 2a859abd331ceb2f6db8cdf63f488e756cb42e15 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 3 Mar 2025 23:04:40 +0000 Subject: [PATCH 2/6] Remove test dependency on resource/object IDs --- .../scalar_return_basic.phpt | 26 ++++++++--------- .../scalar_return_basic_64bit.phpt | 26 ++++++++--------- .../type_declarations/scalar_strict.phpt | 24 +++++++-------- .../scalar_strict_64bit.phpt | 26 ++++++++--------- ext/opcache/tests/jit/fetch_obj_001.phpt | 4 +-- .../tests/array/array_map_variation4.phpt | 15 ++++------ .../tests/array/array_reverse_variation4.phpt | 18 ++++-------- .../tests/array/array_unique_variation3.phpt | 13 +++------ ext/standard/tests/filters/bug54350.phpt | 2 +- .../tests/general_functions/bug73973.phpt | 2 +- .../tests/general_functions/floatval.phpt | 16 ++-------- .../floatval_variation1.phpt | 29 ++++--------------- 12 files changed, 79 insertions(+), 122 deletions(-) diff --git a/Zend/tests/type_declarations/scalar_return_basic.phpt b/Zend/tests/type_declarations/scalar_return_basic.phpt index 1fd3d26db6d8a..8f827600328ed 100644 --- a/Zend/tests/type_declarations/scalar_return_basic.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic.phpt @@ -44,7 +44,7 @@ $values = [ [], new StdClass, new StringCapable, - fopen("data:text/plain,foobar", "r") + STDERR, ]; foreach ($functions as $type => $function) { @@ -92,13 +92,13 @@ int(0) *** Trying array(0) { } *** Caught {closure:%s:%d}(): Return value must be of type int, array returned in %s on line %d -*** Trying object(stdClass)#6 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type int, stdClass returned in %s on line %d -*** Trying object(StringCapable)#7 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type int, StringCapable returned in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Return value must be of type int, resource returned in %s on line %d Testing 'float' type: @@ -129,13 +129,13 @@ float(0) *** Trying array(0) { } *** Caught {closure:%s:%d}(): Return value must be of type float, array returned in %s on line %d -*** Trying object(stdClass)#6 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type float, stdClass returned in %s on line %d -*** Trying object(StringCapable)#7 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type float, StringCapable returned in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Return value must be of type float, resource returned in %s on line %d Testing 'string' type: @@ -166,13 +166,13 @@ string(0) "" *** Trying array(0) { } *** Caught {closure:%s:%d}(): Return value must be of type string, array returned in %s on line %d -*** Trying object(stdClass)#6 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type string, stdClass returned in %s on line %d -*** Trying object(StringCapable)#7 (0) { +*** Trying object(StringCapable)#%d (0) { } string(6) "foobar" -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Return value must be of type string, resource returned in %s on line %d Testing 'bool' type: @@ -203,13 +203,13 @@ bool(false) *** Trying array(0) { } *** Caught {closure:%s:%d}(): Return value must be of type bool, array returned in %s on line %d -*** Trying object(stdClass)#6 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type bool, stdClass returned in %s on line %d -*** Trying object(StringCapable)#7 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type bool, StringCapable returned in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Return value must be of type bool, resource returned in %s on line %d Done diff --git a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt index da930b98d9b65..0a32dd3f16f23 100644 --- a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt @@ -44,7 +44,7 @@ $values = [ [], new StdClass, new StringCapable, - fopen("data:text/plain,foobar", "r") + STDERR, ]; foreach ($functions as $type => $function) { @@ -92,13 +92,13 @@ int(0) *** Trying array(0) { } *** Caught {closure:%s:%d}(): Return value must be of type int, array returned in %s on line %d -*** Trying object(stdClass)#6 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type int, stdClass returned in %s on line %d -*** Trying object(StringCapable)#7 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type int, StringCapable returned in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Return value must be of type int, resource returned in %s on line %d Testing 'float' type: @@ -129,13 +129,13 @@ float(0) *** Trying array(0) { } *** Caught {closure:%s:%d}(): Return value must be of type float, array returned in %s on line %d -*** Trying object(stdClass)#6 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type float, stdClass returned in %s on line %d -*** Trying object(StringCapable)#7 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type float, StringCapable returned in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Return value must be of type float, resource returned in %s on line %d Testing 'string' type: @@ -166,13 +166,13 @@ string(0) "" *** Trying array(0) { } *** Caught {closure:%s:%d}(): Return value must be of type string, array returned in %s on line %d -*** Trying object(stdClass)#6 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type string, stdClass returned in %s on line %d -*** Trying object(StringCapable)#7 (0) { +*** Trying object(StringCapable)#%d (0) { } string(6) "foobar" -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Return value must be of type string, resource returned in %s on line %d Testing 'bool' type: @@ -203,13 +203,13 @@ bool(false) *** Trying array(0) { } *** Caught {closure:%s:%d}(): Return value must be of type bool, array returned in %s on line %d -*** Trying object(stdClass)#6 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type bool, stdClass returned in %s on line %d -*** Trying object(StringCapable)#7 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Return value must be of type bool, StringCapable returned in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Return value must be of type bool, resource returned in %s on line %d Done diff --git a/Zend/tests/type_declarations/scalar_strict.phpt b/Zend/tests/type_declarations/scalar_strict.phpt index e89d18b2c86b3..626f322d8701f 100644 --- a/Zend/tests/type_declarations/scalar_strict.phpt +++ b/Zend/tests/type_declarations/scalar_strict.phpt @@ -96,15 +96,15 @@ int(2147483647) } *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, array given, called in %s on line %d -*** Trying object(stdClass)#5 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#6 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, StringCapable given, called in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, resource given, called in %s on line %d Testing 'float' type: @@ -149,15 +149,15 @@ float(NAN) } *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, array given, called in %s on line %d -*** Trying object(stdClass)#5 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#6 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, StringCapable given, called in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, resource given, called in %s on line %d Testing 'string' type: @@ -202,15 +202,15 @@ string(0) "" } *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, array given, called in %s on line %d -*** Trying object(stdClass)#5 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#6 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, StringCapable given, called in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, resource given, called in %s on line %d Testing 'bool' type: @@ -255,15 +255,15 @@ bool(false) } *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, array given, called in %s on line %d -*** Trying object(stdClass)#5 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#6 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, StringCapable given, called in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, resource given, called in %s on line %d Done diff --git a/Zend/tests/type_declarations/scalar_strict_64bit.phpt b/Zend/tests/type_declarations/scalar_strict_64bit.phpt index 6335e2d1acee4..b7f2ce0de4396 100644 --- a/Zend/tests/type_declarations/scalar_strict_64bit.phpt +++ b/Zend/tests/type_declarations/scalar_strict_64bit.phpt @@ -35,7 +35,7 @@ $values = [ [], new StdClass, new StringCapable, - fopen("data:text/plain,foobar", "r") + STDERR, ]; foreach ($functions as $type => $function) { @@ -96,15 +96,15 @@ int(9223372036854775807) } *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, array given, called in %s on line %d -*** Trying object(stdClass)#5 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#6 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, StringCapable given, called in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Argument #1 ($i) must be of type int, resource given, called in %s on line %d Testing 'float' type: @@ -149,15 +149,15 @@ float(NAN) } *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, array given, called in %s on line %d -*** Trying object(stdClass)#5 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#6 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, StringCapable given, called in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Argument #1 ($f) must be of type float, resource given, called in %s on line %d Testing 'string' type: @@ -202,15 +202,15 @@ string(0) "" } *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, array given, called in %s on line %d -*** Trying object(stdClass)#5 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#6 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, StringCapable given, called in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Argument #1 ($s) must be of type string, resource given, called in %s on line %d Testing 'bool' type: @@ -255,15 +255,15 @@ bool(false) } *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, array given, called in %s on line %d -*** Trying object(stdClass)#5 (0) { +*** Trying object(stdClass)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, stdClass given, called in %s on line %d -*** Trying object(StringCapable)#6 (0) { +*** Trying object(StringCapable)#%d (0) { } *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, StringCapable given, called in %s on line %d -*** Trying resource(5) of type (stream) +*** Trying resource(%d) of type (stream) *** Caught {closure:%s:%d}(): Argument #1 ($b) must be of type bool, resource given, called in %s on line %d Done diff --git a/ext/opcache/tests/jit/fetch_obj_001.phpt b/ext/opcache/tests/jit/fetch_obj_001.phpt index 0f68c1aae0991..ddc8dfafba648 100644 --- a/ext/opcache/tests/jit/fetch_obj_001.phpt +++ b/ext/opcache/tests/jit/fetch_obj_001.phpt @@ -96,7 +96,7 @@ object(stdClass)#%d (2) { } object(stdClass)#%d (2) { ["a"]=> - &resource(5) of type (stream) + &resource(%d) of type (stream) ["b"]=> array(0) { } @@ -122,7 +122,7 @@ object(stdClass)#%d (2) { } object(stdClass)#%d (2) { ["a"]=> - &resource(6) of type (stream) + &resource(%d) of type (stream) ["b"]=> array(0) { } diff --git a/ext/standard/tests/array/array_map_variation4.phpt b/ext/standard/tests/array/array_map_variation4.phpt index 4d6269b3617db..d75a0bcf26108 100644 --- a/ext/standard/tests/array/array_map_variation4.phpt +++ b/ext/standard/tests/array/array_map_variation4.phpt @@ -17,9 +17,6 @@ function callback($a) $unset_var = 10; unset ($unset_var); -// get a resource variable -$fp = fopen(__FILE__, "r"); - // get a class class classA{ public function __toString(){ @@ -49,11 +46,11 @@ $arrays = array ( array("hello", $heredoc => "string"), // heredoc // array with object, unset variable and resource variable - array(@$unset_var => "hello", $fp => 'resource'), + array(@$unset_var => "hello", STDERR => 'resource'), // array with mixed values /*11*/ array('hello' => 1, "fruit" => 2.2, - $fp => 'resource', 133 => "int", + STDERR => 'resource', 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); @@ -70,9 +67,9 @@ echo "Done"; --EXPECTF-- *** Testing array_map() : associative array with diff. keys for 'arr1' argument *** -Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d +Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line %d -Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d +Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line %d -- Iteration 1 -- array(0) { } @@ -131,7 +128,7 @@ array(2) { array(2) { [""]=> string(5) "hello" - [5]=> + [3]=> string(8) "resource" } -- Iteration 9 -- @@ -140,7 +137,7 @@ array(6) { int(1) ["fruit"]=> float(2.2) - [5]=> + [3]=> string(8) "resource" [133]=> string(3) "int" diff --git a/ext/standard/tests/array/array_reverse_variation4.phpt b/ext/standard/tests/array/array_reverse_variation4.phpt index 07454f5a1f261..4967f6e4dacb0 100644 --- a/ext/standard/tests/array/array_reverse_variation4.phpt +++ b/ext/standard/tests/array/array_reverse_variation4.phpt @@ -13,9 +13,6 @@ echo "*** Testing array_reverse() : usage variations ***\n"; $unset_var = 10; unset ($unset_var); -//get a resource variable -$fp = fopen(__FILE__, "r"); - //get a class class classA{ public function __toString(){ @@ -45,10 +42,10 @@ $arrays = array ( array("hello", $heredoc => "string"), // heredoc // array with object, unset variable and resource variable - array(@$unset_var => "hello", $fp => 'resource'), + array(@$unset_var => "hello", STDERR => 'resource'), // array with mixed values -/*11*/ array('hello' => 1, "fruit" => 2.2, $fp => 'resource', 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") +/*11*/ array('hello' => 1, "fruit" => 2.2, STDERR => 'resource', 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); // loop through the various elements of $arrays to test array_reverse() @@ -66,17 +63,14 @@ foreach($arrays as $array) { $iterator++; }; -// close the file resource used -fclose($fp); - echo "Done"; ?> --EXPECTF-- *** Testing array_reverse() : usage variations *** -Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d +Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line %d -Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d +Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line %d -- Iteration 1 -- - default argument - array(0) { @@ -259,7 +253,7 @@ array(2) { } - $preserve keys = true - array(2) { - [5]=> + [3]=> string(8) "resource" [""]=> string(5) "hello" @@ -295,7 +289,7 @@ array(6) { string(5) "unset" [133]=> string(3) "int" - [5]=> + [3]=> string(8) "resource" ["fruit"]=> float(2.2) diff --git a/ext/standard/tests/array/array_unique_variation3.phpt b/ext/standard/tests/array/array_unique_variation3.phpt index b412a19a422e5..91b551bb60402 100644 --- a/ext/standard/tests/array/array_unique_variation3.phpt +++ b/ext/standard/tests/array/array_unique_variation3.phpt @@ -13,9 +13,6 @@ echo "*** Testing array_unique() : assoc. array with diff. keys passed to \$inpu $unset_var = 10; unset ($unset_var); -// get a resource variable -$fp = fopen(__FILE__, "r"); - // get a class class classA { @@ -41,7 +38,7 @@ $inputs = array ( array("hello", $heredoc => "string", "string"), // array with object, unset variable and resource variable -/*8*/ array(@$unset_var => "hello", $fp => 'resource', 11, "hello"), +/*8*/ array(@$unset_var => "hello", STDERR => 'resource', 11, "hello"), ); // loop through each sub-array of $inputs to check the behavior of array_unique() @@ -52,14 +49,12 @@ foreach($inputs as $input) { $iterator++; } -fclose($fp); - echo "Done"; ?> --EXPECTF-- *** Testing array_unique() : assoc. array with diff. keys passed to $input argument *** -Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d +Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line %d -- Iteration 1 -- array(1) { [0]=> @@ -103,9 +98,9 @@ array(2) { array(3) { [""]=> string(5) "hello" - [5]=> + [3]=> string(8) "resource" - [6]=> + [4]=> int(11) } Done diff --git a/ext/standard/tests/filters/bug54350.phpt b/ext/standard/tests/filters/bug54350.phpt index a017893eed7bb..ae00762890857 100644 --- a/ext/standard/tests/filters/bug54350.phpt +++ b/ext/standard/tests/filters/bug54350.phpt @@ -22,5 +22,5 @@ fwrite($fd, "foo"); ?> --EXPECTF-- -Warning: fclose(): 5 is not a valid stream resource in %s on line %d +Warning: fclose(): %d is not a valid stream resource in %s on line %d fclose(): supplied resource is not a valid stream resource diff --git a/ext/standard/tests/general_functions/bug73973.phpt b/ext/standard/tests/general_functions/bug73973.phpt index 8bb4daaab094d..fccd8b5af9457 100644 --- a/ext/standard/tests/general_functions/bug73973.phpt +++ b/ext/standard/tests/general_functions/bug73973.phpt @@ -6,4 +6,4 @@ define('myerr', fopen('php://stderr', 'w')); debug_zval_dump(myerr); ?> --EXPECTF-- -resource(5) of type (stream) refcount(%d) +resource(%d) of type (stream) refcount(%d) diff --git a/ext/standard/tests/general_functions/floatval.phpt b/ext/standard/tests/general_functions/floatval.phpt index f9aa74e342d56..9ff49bb01084e 100644 --- a/ext/standard/tests/general_functions/floatval.phpt +++ b/ext/standard/tests/general_functions/floatval.phpt @@ -47,18 +47,11 @@ foreach ($valid_floats as $value ) { echo "\n*** Testing floatval() on non floating types ***\n"; -// get a resource type variable -$fp = fopen (__FILE__, "r"); -fclose($fp); -$dfp = opendir ( __DIR__ ); -closedir($dfp); - // other types in an array $not_float_types = array ( -2147483648, // max negative integer value 2147483648, // max positive integer value - $fp, // resource - $dfp, + STDERR, // resource "0.0", // string "1.0", "-1.3e3", @@ -89,7 +82,6 @@ foreach ($not_float_types as $type ) { echo "\nDone\n"; - ?> --EXPECTF-- *** Testing floatval() with valid float values *** @@ -145,8 +137,7 @@ Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d float(-2147483648) float(2147483648) -float(5) -float(6) +float(3) float(0) float(1) float(-1300) @@ -163,8 +154,7 @@ float(0) *** Testing doubleval() on non floating types *** float(-2147483648) float(2147483648) -float(5) -float(6) +float(3) float(0) float(1) float(-1300) diff --git a/ext/standard/tests/general_functions/floatval_variation1.phpt b/ext/standard/tests/general_functions/floatval_variation1.phpt index 856e4e31ebb0d..032d089b01c49 100644 --- a/ext/standard/tests/general_functions/floatval_variation1.phpt +++ b/ext/standard/tests/general_functions/floatval_variation1.phpt @@ -2,18 +2,12 @@ Testing floatval() and its alias doubleval() functions : usage variations - different data types as $y arg --FILE-- -2147483648, // max negative integer value "2147483647" => 2147483648, // max positive integer value - "file resoruce" => $fp, - "directory resource" => $dfp, + "stream resource" => STDERR, "\"0.0\"" => "0.0", // string "\"1.0\"" => "1.0", "\"-1.3e3\"" => "-1.3e3", @@ -24,7 +18,6 @@ $not_float_types = array ( "\"10.0 dollar\" + 1.0" => "10.0 dollar" + 1.0, "\"\"" => "", "true" => true, - "NULL" => NULL, "null" => null, ); /* loop through the $not_float_types to see working of @@ -57,11 +50,8 @@ float(-2147483648) -- Iteration : 2147483647 -- float(2147483648) --- Iteration : file resoruce -- -float(5) - --- Iteration : directory resource -- -float(6) +-- Iteration : stream resource -- +float(3) -- Iteration : "0.0" -- float(0) @@ -93,9 +83,6 @@ float(0) -- Iteration : true -- float(1) --- Iteration : NULL -- -float(0) - -- Iteration : null -- float(0) @@ -107,11 +94,8 @@ float(-2147483648) -- Iteration : 2147483647 -- float(2147483648) --- Iteration : file resoruce -- -float(5) - --- Iteration : directory resource -- -float(6) +-- Iteration : stream resource -- +float(3) -- Iteration : "0.0" -- float(0) @@ -143,8 +127,5 @@ float(0) -- Iteration : true -- float(1) --- Iteration : NULL -- -float(0) - -- Iteration : null -- float(0) From 83090b47054d49ef8834d4d3b426c982ca478a04 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Tue, 4 Mar 2025 02:20:34 +0000 Subject: [PATCH 3/6] Split print_r tests So that these aren't huge mega tests --- .../tests/general_functions/print_r.phpt | 1696 ---------------- .../general_functions/print_r_64bit.phpt | 1700 ----------------- .../print_r_array_circular.phpt | 22 + .../general_functions/print_r_arrays.phpt | 166 ++ .../print_r_arrays_whitespace_sensitive.phpt | 50 + .../general_functions/print_r_bools.phpt | 28 + .../general_functions/print_r_floats.phpt | 183 ++ .../tests/general_functions/print_r_ints.phpt | 131 ++ .../general_functions/print_r_ints_64bit.phpt | 45 + .../tests/general_functions/print_r_null.phpt | 18 + .../general_functions/print_r_object.phpt | 228 +++ .../print_r_object_circular.phpt | 26 + .../general_functions/print_r_resources.phpt | 23 + .../general_functions/print_r_strings.phpt | 61 + .../print_r_strings_nul_bytes.phpt | Bin 0 -> 916 bytes 15 files changed, 981 insertions(+), 3396 deletions(-) delete mode 100644 ext/standard/tests/general_functions/print_r.phpt delete mode 100644 ext/standard/tests/general_functions/print_r_64bit.phpt create mode 100644 ext/standard/tests/general_functions/print_r_array_circular.phpt create mode 100644 ext/standard/tests/general_functions/print_r_arrays.phpt create mode 100644 ext/standard/tests/general_functions/print_r_arrays_whitespace_sensitive.phpt create mode 100644 ext/standard/tests/general_functions/print_r_bools.phpt create mode 100644 ext/standard/tests/general_functions/print_r_floats.phpt create mode 100644 ext/standard/tests/general_functions/print_r_ints.phpt create mode 100644 ext/standard/tests/general_functions/print_r_ints_64bit.phpt create mode 100644 ext/standard/tests/general_functions/print_r_null.phpt create mode 100644 ext/standard/tests/general_functions/print_r_object.phpt create mode 100644 ext/standard/tests/general_functions/print_r_object_circular.phpt create mode 100644 ext/standard/tests/general_functions/print_r_resources.phpt create mode 100644 ext/standard/tests/general_functions/print_r_strings.phpt create mode 100644 ext/standard/tests/general_functions/print_r_strings_nul_bytes.phpt diff --git a/ext/standard/tests/general_functions/print_r.phpt b/ext/standard/tests/general_functions/print_r.phpt deleted file mode 100644 index 0ea60658aed7a..0000000000000 --- a/ext/standard/tests/general_functions/print_r.phpt +++ /dev/null @@ -1,1696 +0,0 @@ ---TEST-- -Test print_r() function ---INI-- -precision=14 ---FILE-- - 'One'), - array("test" => "is_array"), - array(0), - array(-1), - array(10.5, 5.6), - array("string", "test"), - array('string', 'test'), -); -/* calling check_printr() to display contents of $arrays */ -check_printr($arrays); - -echo "\n*** Testing print_r() on object variables ***\n"; -#[AllowDynamicProperties] -class object_class -{ - var $value; - public $public_var1 = 10; - private $private_var1 = 20; - private $private_var2; - protected $protected_var1 = "string_1"; - protected $protected_var2; - - function __construct() { - $this->value = 50; - $this->public_var2 = 11; - $this->private_var2 = 21; - $this->protected_var2 = "string_2"; - } - - public function foo1() { - echo "foo1() is called\n"; - } - protected function foo2() { - echo "foo2() is called\n"; - } - private function foo3() { - echo "foo3() is called\n"; - } -} -/* class with no member */ -class no_member_class { - // no members -} - -/* class with member as object of other class */ -#[AllowDynamicProperties] -class contains_object_class -{ - var $p = 30; - var $class_object1; - public $class_object2; - private $class_object3; - protected $class_object4; - var $no_member_class_object; - - public function func() { - echo "func() is called \n"; - } - - function __construct() { - $this->class_object1 = new object_class(); - $this->class_object2 = new object_class(); - $this->class_object3 = $this->class_object1; - $this->class_object4 = $this->class_object2; - $this->no_member_class_object = new no_member_class(); - $this->class_object5 = $this; //recursive reference - } -} - -/* objects of different classes */ -$obj = new contains_object_class; -$temp_class_obj = new object_class(); - -/* object which is unset */ -$unset_obj = new object_class(); -unset($unset_obj); - -$objects = array ( - new object_class, - new no_member_class, - new contains_object_class, - $obj, - $obj->class_object1, - $obj->class_object2, - $obj->no_member_class_object, - $temp_class_obj, - @$unset_obj -); -/* calling check_printr() to display contents of the objects using print_r() */ -check_printr($objects); - -echo "\n** Testing print_r() on objects having circular reference **\n"; -$recursion_obj1 = new object_class(); -$recursion_obj2 = new object_class(); -$recursion_obj1->obj = &$recursion_obj2; //circular reference -$recursion_obj2->obj = &$recursion_obj1; //circular reference -print_r($recursion_obj2); - -echo "\n*** Testing print_r() on resources ***\n"; -/* file type resource */ -$file_handle = fopen(__FILE__, "r"); - -/* directory type resource */ -$dir_handle = opendir( __DIR__ ); - -$resources = array ( - $file_handle, - $dir_handle -); -/* calling check_printr() to display the resource content type - using print_r() */ -check_printr($resources); - -echo "\n*** Testing print_r() on different combinations of scalar - and non-scalar variables ***\n"; -/* a variable which is unset */ -$unset_var = 10.5; -unset($unset_var); - -/* unset file type resource */ -unset($file_handle); - -$variations = array ( - array( 123, -1.2345, "a" ), - array( "d", array(1, 3, 5), true, null), - array( new no_member_class, array(), false, 0 ), - array( -0.00, "Where am I?", array(7,8,9), TRUE, 'A', 987654321 ), - array( @$unset_var, 2.E+10, 100-20.9, 000004.599998 ), //unusual data - array( "array(1,2,3,4)1.0000002TRUE", @$file_handle, 111333.00+45e5, '/00\7') -); -/* calling check_printr() to display combinations of scalar and - non-scalar variables using print_r() */ -check_printr($variations); - -echo "\n*** Testing print_r() on miscellaneous input arguments ***\n"; -$misc_values = array ( - @$unset_var, - NULL, // NULL argument - @$undef_variable, //undefined variable - null -); -/* calling check_printr() to display miscellaneous data using print_r() */ -check_printr($misc_values); - -/* closing resource handle used */ -closedir($dir_handle); - -echo "Done\n"; -?> ---EXPECTF-- -*** Testing print_r() on integer variables *** - --- Iteration 1 -- -0 -0 -0 --- Iteration 2 -- -83 -83 -83 --- Iteration 3 -- -123000000 -123000000 -123000000 --- Iteration 4 -- --83 --83 --83 --- Iteration 5 -- --12300000 --12300000 --12300000 --- Iteration 6 -- -Array -( - [0] => 1 - [1] => 2 - [2] => 3 - [3] => 4 - [4] => 5 - [5] => 6 - [6] => 7 - [7] => 8 - [8] => 9 - [9] => 10 -) - -Array -( - [0] => 1 - [1] => 2 - [2] => 3 - [3] => 4 - [4] => 5 - [5] => 6 - [6] => 7 - [7] => 8 - [8] => 9 - [9] => 10 -) - -Array -( - [0] => 1 - [1] => 2 - [2] => 3 - [3] => 4 - [4] => 5 - [5] => 6 - [6] => 7 - [7] => 8 - [8] => 9 - [9] => 10 -) - --- Iteration 7 -- -Array -( - [0] => -1 - [1] => -2 - [2] => -3 - [3] => -4 - [4] => -5 - [5] => -6 - [6] => -7 - [7] => -8 - [8] => -9 - [9] => -10 -) - -Array -( - [0] => -1 - [1] => -2 - [2] => -3 - [3] => -4 - [4] => -5 - [5] => -6 - [6] => -7 - [7] => -8 - [8] => -9 - [9] => -10 -) - -Array -( - [0] => -1 - [1] => -2 - [2] => -3 - [3] => -4 - [4] => -5 - [5] => -6 - [6] => -7 - [7] => -8 - [8] => -9 - [9] => -10 -) - --- Iteration 8 -- -2147483647 -2147483647 -2147483647 --- Iteration 9 -- -2147483648 -2147483648 -2147483648 --- Iteration 10 -- --2147483648 --2147483648 --2147483648 --- Iteration 11 -- --2147483647 --2147483647 --2147483647 --- Iteration 12 -- -2147483647 -2147483647 -2147483647 --- Iteration 13 -- --2147483648 --2147483648 --2147483648 --- Iteration 14 -- -2147483647 -2147483647 -2147483647 --- Iteration 15 -- --2147483648 --2147483648 --2147483648 -*** Testing print_r() on float variables *** - --- Iteration 1 -- --0 --0 --0 --- Iteration 2 -- -0 -0 -0 --- Iteration 3 -- -1.234 -1.234 -1.234 --- Iteration 4 -- --1.234 --1.234 --1.234 --- Iteration 5 -- --2 --2 --2 --- Iteration 6 -- -2 -2 -2 --- Iteration 7 -- --0.5 --0.5 --0.5 --- Iteration 8 -- -0.567 -0.567 -0.567 --- Iteration 9 -- --0.00067 --0.00067 --0.00067 --- Iteration 10 -- --670 --670 --670 --- Iteration 11 -- -670 -670 -670 --- Iteration 12 -- -670 -670 -670 --- Iteration 13 -- --0.00410003 --0.00410003 --0.00410003 --- Iteration 14 -- --4100.03 --4100.03 --4100.03 --- Iteration 15 -- -0.004100003 -0.004100003 -0.004100003 --- Iteration 16 -- -4100.003 -4100.003 -4100.003 --- Iteration 17 -- -100000 -100000 -100000 --- Iteration 18 -- --100000 --100000 --100000 --- Iteration 19 -- -1.0E-5 -1.0E-5 -1.0E-5 --- Iteration 20 -- --1.0E-5 --1.0E-5 --1.0E-5 --- Iteration 21 -- -100000 -100000 -100000 --- Iteration 22 -- --100000 --100000 --100000 --- Iteration 23 -- -100000 -100000 -100000 --- Iteration 24 -- --100000 --100000 --100000 --- Iteration 25 -- -100000 -100000 -100000 --- Iteration 26 -- --100000 --100000 --100000 --- Iteration 27 -- -1.0E-5 -1.0E-5 -1.0E-5 --- Iteration 28 -- --1.0E-5 --1.0E-5 --1.0E-5 --- Iteration 29 -- --2147483649 --2147483649 --2147483649 --- Iteration 30 -- -2147483649 -2147483649 -2147483649 --- Iteration 31 -- -2147483649 -2147483649 -2147483649 --- Iteration 32 -- --2147483649 --2147483649 --2147483649 -*** Testing print_r() on string variables *** - --- Iteration 1 -- - - - --- Iteration 2 -- - - - --- Iteration 3 -- - - - --- Iteration 4 -- - - - --- Iteration 5 -- -0 -0 -0 --- Iteration 6 -- -%0 -%0 -%0 --- Iteration 7 -- -\0 -\0 -\0 --- Iteration 8 -- - - - --- Iteration 9 -- -\t -\t -\t --- Iteration 10 -- -PHP -PHP -PHP --- Iteration 11 -- -PHP -PHP -PHP --- Iteration 12 -- -abcd%0n1234%005678%000efgh\xijkl -abcd%0n1234%005678%000efgh\xijkl -abcd%0n1234%005678%000efgh\xijkl --- Iteration 13 -- -abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz -abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz -abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz --- Iteration 14 -- -1234 -5678 - 9100"abcda -1234 -5678 - 9100"abcda -1234 -5678 - 9100"abcda -*** Testing print_r() on boolean variables *** - --- Iteration 1 -- -1 -1 -1 --- Iteration 2 -- - - - --- Iteration 3 -- -1 -1 -1 --- Iteration 4 -- - - -bool(true) - -bool(true) - -*** Testing print_r() on array variables *** - --- Iteration 1 -- -Array -( -) - -Array -( -) - -Array -( -) - --- Iteration 2 -- -Array -( - [0] => -) - -Array -( - [0] => -) - -Array -( - [0] => -) - --- Iteration 3 -- -Array -( - [0] => -) - -Array -( - [0] => -) - -Array -( - [0] => -) - --- Iteration 4 -- -Array -( - [0] => 1 -) - -Array -( - [0] => 1 -) - -Array -( - [0] => 1 -) - --- Iteration 5 -- -Array -( - [0] => -) - -Array -( - [0] => -) - -Array -( - [0] => -) - --- Iteration 6 -- -Array -( - [0] => -) - -Array -( - [0] => -) - -Array -( - [0] => -) - --- Iteration 7 -- -Array -( - [0] => Array - ( - ) - - [1] => Array - ( - ) - -) - -Array -( - [0] => Array - ( - ) - - [1] => Array - ( - ) - -) - -Array -( - [0] => Array - ( - ) - - [1] => Array - ( - ) - -) - --- Iteration 8 -- -Array -( - [0] => Array - ( - [0] => 1 - [1] => 2 - ) - - [1] => Array - ( - [0] => a - [1] => b - ) - -) - -Array -( - [0] => Array - ( - [0] => 1 - [1] => 2 - ) - - [1] => Array - ( - [0] => a - [1] => b - ) - -) - -Array -( - [0] => Array - ( - [0] => 1 - [1] => 2 - ) - - [1] => Array - ( - [0] => a - [1] => b - ) - -) - --- Iteration 9 -- -Array -( - [1] => One -) - -Array -( - [1] => One -) - -Array -( - [1] => One -) - --- Iteration 10 -- -Array -( - [test] => is_array -) - -Array -( - [test] => is_array -) - -Array -( - [test] => is_array -) - --- Iteration 11 -- -Array -( - [0] => 0 -) - -Array -( - [0] => 0 -) - -Array -( - [0] => 0 -) - --- Iteration 12 -- -Array -( - [0] => -1 -) - -Array -( - [0] => -1 -) - -Array -( - [0] => -1 -) - --- Iteration 13 -- -Array -( - [0] => 10.5 - [1] => 5.6 -) - -Array -( - [0] => 10.5 - [1] => 5.6 -) - -Array -( - [0] => 10.5 - [1] => 5.6 -) - --- Iteration 14 -- -Array -( - [0] => string - [1] => test -) - -Array -( - [0] => string - [1] => test -) - -Array -( - [0] => string - [1] => test -) - --- Iteration 15 -- -Array -( - [0] => string - [1] => test -) - -Array -( - [0] => string - [1] => test -) - -Array -( - [0] => string - [1] => test -) - -*** Testing print_r() on object variables *** - --- Iteration 1 -- -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - --- Iteration 2 -- -no_member_class Object -( -) - -no_member_class Object -( -) - -no_member_class Object -( -) - --- Iteration 3 -- -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - --- Iteration 4 -- -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - --- Iteration 5 -- -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - --- Iteration 6 -- -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - --- Iteration 7 -- -no_member_class Object -( -) - -no_member_class Object -( -) - -no_member_class Object -( -) - --- Iteration 8 -- -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - --- Iteration 9 -- - - - -** Testing print_r() on objects having circular reference ** -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - [obj] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - [obj] => object_class Object - *RECURSION* - ) - -) - -*** Testing print_r() on resources *** - --- Iteration 1 -- -Resource id #5 -Resource id #5 -Resource id #5 --- Iteration 2 -- -Resource id #6 -Resource id #6 -Resource id #6 -*** Testing print_r() on different combinations of scalar - and non-scalar variables *** - --- Iteration 1 -- -Array -( - [0] => 123 - [1] => -1.2345 - [2] => a -) - -Array -( - [0] => 123 - [1] => -1.2345 - [2] => a -) - -Array -( - [0] => 123 - [1] => -1.2345 - [2] => a -) - --- Iteration 2 -- -Array -( - [0] => d - [1] => Array - ( - [0] => 1 - [1] => 3 - [2] => 5 - ) - - [2] => 1 - [3] => -) - -Array -( - [0] => d - [1] => Array - ( - [0] => 1 - [1] => 3 - [2] => 5 - ) - - [2] => 1 - [3] => -) - -Array -( - [0] => d - [1] => Array - ( - [0] => 1 - [1] => 3 - [2] => 5 - ) - - [2] => 1 - [3] => -) - --- Iteration 3 -- -Array -( - [0] => no_member_class Object - ( - ) - - [1] => Array - ( - ) - - [2] => - [3] => 0 -) - -Array -( - [0] => no_member_class Object - ( - ) - - [1] => Array - ( - ) - - [2] => - [3] => 0 -) - -Array -( - [0] => no_member_class Object - ( - ) - - [1] => Array - ( - ) - - [2] => - [3] => 0 -) - --- Iteration 4 -- -Array -( - [0] => -0 - [1] => Where am I? - [2] => Array - ( - [0] => 7 - [1] => 8 - [2] => 9 - ) - - [3] => 1 - [4] => A - [5] => 987654321 -) - -Array -( - [0] => -0 - [1] => Where am I? - [2] => Array - ( - [0] => 7 - [1] => 8 - [2] => 9 - ) - - [3] => 1 - [4] => A - [5] => 987654321 -) - -Array -( - [0] => -0 - [1] => Where am I? - [2] => Array - ( - [0] => 7 - [1] => 8 - [2] => 9 - ) - - [3] => 1 - [4] => A - [5] => 987654321 -) - --- Iteration 5 -- -Array -( - [0] => - [1] => 20000000000 - [2] => 79.1 - [3] => 4.599998 -) - -Array -( - [0] => - [1] => 20000000000 - [2] => 79.1 - [3] => 4.599998 -) - -Array -( - [0] => - [1] => 20000000000 - [2] => 79.1 - [3] => 4.599998 -) - --- Iteration 6 -- -Array -( - [0] => array(1,2,3,4)1.0000002TRUE - [1] => - [2] => 4611333 - [3] => /00\7 -) - -Array -( - [0] => array(1,2,3,4)1.0000002TRUE - [1] => - [2] => 4611333 - [3] => /00\7 -) - -Array -( - [0] => array(1,2,3,4)1.0000002TRUE - [1] => - [2] => 4611333 - [3] => /00\7 -) - -*** Testing print_r() on miscellaneous input arguments *** - --- Iteration 1 -- - - - --- Iteration 2 -- - - - --- Iteration 3 -- - - - --- Iteration 4 -- - - -Done diff --git a/ext/standard/tests/general_functions/print_r_64bit.phpt b/ext/standard/tests/general_functions/print_r_64bit.phpt deleted file mode 100644 index 6026b959d7c4c..0000000000000 --- a/ext/standard/tests/general_functions/print_r_64bit.phpt +++ /dev/null @@ -1,1700 +0,0 @@ ---TEST-- -Test print_r() function ---SKIPIF-- - ---INI-- -precision=14 ---FILE-- - 'One'), - array("test" => "is_array"), - array(0), - array(-1), - array(10.5, 5.6), - array("string", "test"), - array('string', 'test'), -); -/* calling check_printr() to display contents of $arrays */ -check_printr($arrays); - -echo "\n*** Testing print_r() on object variables ***\n"; -#[AllowDynamicProperties] -class object_class -{ - var $value; - public $public_var1 = 10; - private $private_var1 = 20; - private $private_var2; - protected $protected_var1 = "string_1"; - protected $protected_var2; - - function __construct ( ) { - $this->value = 50; - $this->public_var2 = 11; - $this->private_var2 = 21; - $this->protected_var2 = "string_2"; - } - - public function foo1() { - echo "foo1() is called\n"; - } - protected function foo2() { - echo "foo2() is called\n"; - } - private function foo3() { - echo "foo3() is called\n"; - } -} -/* class with no member */ -class no_member_class { - // no members -} - -/* class with member as object of other class */ -#[AllowDynamicProperties] -class contains_object_class -{ - var $p = 30; - var $class_object1; - public $class_object2; - private $class_object3; - protected $class_object4; - var $no_member_class_object; - - public function func() { - echo "func() is called \n"; - } - - function __construct () { - $this->class_object1 = new object_class(); - $this->class_object2 = new object_class(); - $this->class_object3 = $this->class_object1; - $this->class_object4 = $this->class_object2; - $this->no_member_class_object = new no_member_class(); - $this->class_object5 = $this; //recursive reference - } -} - -/* objects of different classes */ -$obj = new contains_object_class; -$temp_class_obj = new object_class(); - -/* object which is unset */ -$unset_obj = new object_class(); -unset($unset_obj); - -$objects = array ( - new object_class, - new no_member_class, - new contains_object_class, - $obj, - $obj->class_object1, - $obj->class_object2, - $obj->no_member_class_object, - $temp_class_obj, - @$unset_obj -); -/* calling check_printr() to display contents of the objects using print_r() */ -check_printr($objects); - -echo "\n** Testing print_r() on objects having circular reference **\n"; -$recursion_obj1 = new object_class(); -$recursion_obj2 = new object_class(); -$recursion_obj1->obj = &$recursion_obj2; //circular reference -$recursion_obj2->obj = &$recursion_obj1; //circular reference -print_r($recursion_obj2); - -echo "\n*** Testing print_r() on resources ***\n"; -/* file type resource */ -$file_handle = fopen(__FILE__, "r"); - -/* directory type resource */ -$dir_handle = opendir( __DIR__ ); - -$resources = array ( - $file_handle, - $dir_handle -); -/* calling check_printr() to display the resource content type - using print_r() */ -check_printr($resources); - -echo "\n*** Testing print_r() on different combinations of scalar - and non-scalar variables ***\n"; -/* a variable which is unset */ -$unset_var = 10.5; -unset($unset_var); - -/* unset file type resource */ -unset($file_handle); - -$variations = array ( - array( 123, -1.2345, "a" ), - array( "d", array(1, 3, 5), true, null), - array( new no_member_class, array(), false, 0 ), - array( -0.00, "Where am I?", array(7,8,9), TRUE, 'A', 987654321 ), - array( @$unset_var, 2.E+10, 100-20.9, 000004.599998 ), //unusual data - array( "array(1,2,3,4)1.0000002TRUE", @$file_handle, 111333.00+45e5, '/00\7') -); -/* calling check_printr() to display combinations of scalar and - non-scalar variables using print_r() */ -check_printr($variations); - -echo "\n*** Testing print_r() on miscellaneous input arguments ***\n"; -$misc_values = array ( - @$unset_var, - NULL, // NULL argument - @$undef_variable, //undefined variable - null -); -/* calling check_printr() to display miscellaneous data using print_r() */ -check_printr($misc_values); - -/* closing resource handle used */ -closedir($dir_handle); - -echo "Done\n"; -?> ---EXPECTF-- -*** Testing print_r() on integer variables *** - --- Iteration 1 -- -0 -0 -0 --- Iteration 2 -- -83 -83 -83 --- Iteration 3 -- -123000000 -123000000 -123000000 --- Iteration 4 -- --83 --83 --83 --- Iteration 5 -- --12300000 --12300000 --12300000 --- Iteration 6 -- -Array -( - [0] => 1 - [1] => 2 - [2] => 3 - [3] => 4 - [4] => 5 - [5] => 6 - [6] => 7 - [7] => 8 - [8] => 9 - [9] => 10 -) - -Array -( - [0] => 1 - [1] => 2 - [2] => 3 - [3] => 4 - [4] => 5 - [5] => 6 - [6] => 7 - [7] => 8 - [8] => 9 - [9] => 10 -) - -Array -( - [0] => 1 - [1] => 2 - [2] => 3 - [3] => 4 - [4] => 5 - [5] => 6 - [6] => 7 - [7] => 8 - [8] => 9 - [9] => 10 -) - --- Iteration 7 -- -Array -( - [0] => -1 - [1] => -2 - [2] => -3 - [3] => -4 - [4] => -5 - [5] => -6 - [6] => -7 - [7] => -8 - [8] => -9 - [9] => -10 -) - -Array -( - [0] => -1 - [1] => -2 - [2] => -3 - [3] => -4 - [4] => -5 - [5] => -6 - [6] => -7 - [7] => -8 - [8] => -9 - [9] => -10 -) - -Array -( - [0] => -1 - [1] => -2 - [2] => -3 - [3] => -4 - [4] => -5 - [5] => -6 - [6] => -7 - [7] => -8 - [8] => -9 - [9] => -10 -) - --- Iteration 8 -- -2147483647 -2147483647 -2147483647 --- Iteration 9 -- -2147483648 -2147483648 -2147483648 --- Iteration 10 -- --2147483648 --2147483648 --2147483648 --- Iteration 11 -- --2147483647 --2147483647 --2147483647 --- Iteration 12 -- -2147483647 -2147483647 -2147483647 --- Iteration 13 -- --2147483648 --2147483648 --2147483648 --- Iteration 14 -- -2147483647 -2147483647 -2147483647 --- Iteration 15 -- --2147483648 --2147483648 --2147483648 -*** Testing print_r() on float variables *** - --- Iteration 1 -- --0 --0 --0 --- Iteration 2 -- -0 -0 -0 --- Iteration 3 -- -1.234 -1.234 -1.234 --- Iteration 4 -- --1.234 --1.234 --1.234 --- Iteration 5 -- --2 --2 --2 --- Iteration 6 -- -2 -2 -2 --- Iteration 7 -- --0.5 --0.5 --0.5 --- Iteration 8 -- -0.567 -0.567 -0.567 --- Iteration 9 -- --0.00067 --0.00067 --0.00067 --- Iteration 10 -- --670 --670 --670 --- Iteration 11 -- -670 -670 -670 --- Iteration 12 -- -670 -670 -670 --- Iteration 13 -- --0.00410003 --0.00410003 --0.00410003 --- Iteration 14 -- --4100.03 --4100.03 --4100.03 --- Iteration 15 -- -0.004100003 -0.004100003 -0.004100003 --- Iteration 16 -- -4100.003 -4100.003 -4100.003 --- Iteration 17 -- -100000 -100000 -100000 --- Iteration 18 -- --100000 --100000 --100000 --- Iteration 19 -- -1.0E-5 -1.0E-5 -1.0E-5 --- Iteration 20 -- --1.0E-5 --1.0E-5 --1.0E-5 --- Iteration 21 -- -100000 -100000 -100000 --- Iteration 22 -- --100000 --100000 --100000 --- Iteration 23 -- -100000 -100000 -100000 --- Iteration 24 -- --100000 --100000 --100000 --- Iteration 25 -- -100000 -100000 -100000 --- Iteration 26 -- --100000 --100000 --100000 --- Iteration 27 -- -1.0E-5 -1.0E-5 -1.0E-5 --- Iteration 28 -- --1.0E-5 --1.0E-5 --1.0E-5 --- Iteration 29 -- --2147483649 --2147483649 --2147483649 --- Iteration 30 -- -2147483649 -2147483649 -2147483649 --- Iteration 31 -- -2147483649 -2147483649 -2147483649 --- Iteration 32 -- --2147483649 --2147483649 --2147483649 -*** Testing print_r() on string variables *** - --- Iteration 1 -- - - - --- Iteration 2 -- - - - --- Iteration 3 -- - - - --- Iteration 4 -- - - - --- Iteration 5 -- -0 -0 -0 --- Iteration 6 -- -%0 -%0 -%0 --- Iteration 7 -- -\0 -\0 -\0 --- Iteration 8 -- - - - --- Iteration 9 -- -\t -\t -\t --- Iteration 10 -- -PHP -PHP -PHP --- Iteration 11 -- -PHP -PHP -PHP --- Iteration 12 -- -abcd%0n1234%005678%000efgh\xijkl -abcd%0n1234%005678%000efgh\xijkl -abcd%0n1234%005678%000efgh\xijkl --- Iteration 13 -- -abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz -abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz -abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz --- Iteration 14 -- -1234 -5678 - 9100"abcda -1234 -5678 - 9100"abcda -1234 -5678 - 9100"abcda -*** Testing print_r() on boolean variables *** - --- Iteration 1 -- -1 -1 -1 --- Iteration 2 -- - - - --- Iteration 3 -- -1 -1 -1 --- Iteration 4 -- - - -bool(true) - -bool(true) - -*** Testing print_r() on array variables *** - --- Iteration 1 -- -Array -( -) - -Array -( -) - -Array -( -) - --- Iteration 2 -- -Array -( - [0] => -) - -Array -( - [0] => -) - -Array -( - [0] => -) - --- Iteration 3 -- -Array -( - [0] => -) - -Array -( - [0] => -) - -Array -( - [0] => -) - --- Iteration 4 -- -Array -( - [0] => 1 -) - -Array -( - [0] => 1 -) - -Array -( - [0] => 1 -) - --- Iteration 5 -- -Array -( - [0] => -) - -Array -( - [0] => -) - -Array -( - [0] => -) - --- Iteration 6 -- -Array -( - [0] => -) - -Array -( - [0] => -) - -Array -( - [0] => -) - --- Iteration 7 -- -Array -( - [0] => Array - ( - ) - - [1] => Array - ( - ) - -) - -Array -( - [0] => Array - ( - ) - - [1] => Array - ( - ) - -) - -Array -( - [0] => Array - ( - ) - - [1] => Array - ( - ) - -) - --- Iteration 8 -- -Array -( - [0] => Array - ( - [0] => 1 - [1] => 2 - ) - - [1] => Array - ( - [0] => a - [1] => b - ) - -) - -Array -( - [0] => Array - ( - [0] => 1 - [1] => 2 - ) - - [1] => Array - ( - [0] => a - [1] => b - ) - -) - -Array -( - [0] => Array - ( - [0] => 1 - [1] => 2 - ) - - [1] => Array - ( - [0] => a - [1] => b - ) - -) - --- Iteration 9 -- -Array -( - [1] => One -) - -Array -( - [1] => One -) - -Array -( - [1] => One -) - --- Iteration 10 -- -Array -( - [test] => is_array -) - -Array -( - [test] => is_array -) - -Array -( - [test] => is_array -) - --- Iteration 11 -- -Array -( - [0] => 0 -) - -Array -( - [0] => 0 -) - -Array -( - [0] => 0 -) - --- Iteration 12 -- -Array -( - [0] => -1 -) - -Array -( - [0] => -1 -) - -Array -( - [0] => -1 -) - --- Iteration 13 -- -Array -( - [0] => 10.5 - [1] => 5.6 -) - -Array -( - [0] => 10.5 - [1] => 5.6 -) - -Array -( - [0] => 10.5 - [1] => 5.6 -) - --- Iteration 14 -- -Array -( - [0] => string - [1] => test -) - -Array -( - [0] => string - [1] => test -) - -Array -( - [0] => string - [1] => test -) - --- Iteration 15 -- -Array -( - [0] => string - [1] => test -) - -Array -( - [0] => string - [1] => test -) - -Array -( - [0] => string - [1] => test -) - -*** Testing print_r() on object variables *** - --- Iteration 1 -- -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - --- Iteration 2 -- -no_member_class Object -( -) - -no_member_class Object -( -) - -no_member_class Object -( -) - --- Iteration 3 -- -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - --- Iteration 4 -- -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - -contains_object_class Object -( - [p] => 30 - [class_object1] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object2] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object3:contains_object_class:private] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [class_object4:protected] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - ) - - [no_member_class_object] => no_member_class Object - ( - ) - - [class_object5] => contains_object_class Object - *RECURSION* -) - --- Iteration 5 -- -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - --- Iteration 6 -- -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - --- Iteration 7 -- -no_member_class Object -( -) - -no_member_class Object -( -) - -no_member_class Object -( -) - --- Iteration 8 -- -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 -) - --- Iteration 9 -- - - - -** Testing print_r() on objects having circular reference ** -object_class Object -( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - [obj] => object_class Object - ( - [value] => 50 - [public_var1] => 10 - [private_var1:object_class:private] => 20 - [private_var2:object_class:private] => 21 - [protected_var1:protected] => string_1 - [protected_var2:protected] => string_2 - [public_var2] => 11 - [obj] => object_class Object - *RECURSION* - ) - -) - -*** Testing print_r() on resources *** - --- Iteration 1 -- -Resource id #5 -Resource id #5 -Resource id #5 --- Iteration 2 -- -Resource id #6 -Resource id #6 -Resource id #6 -*** Testing print_r() on different combinations of scalar - and non-scalar variables *** - --- Iteration 1 -- -Array -( - [0] => 123 - [1] => -1.2345 - [2] => a -) - -Array -( - [0] => 123 - [1] => -1.2345 - [2] => a -) - -Array -( - [0] => 123 - [1] => -1.2345 - [2] => a -) - --- Iteration 2 -- -Array -( - [0] => d - [1] => Array - ( - [0] => 1 - [1] => 3 - [2] => 5 - ) - - [2] => 1 - [3] => -) - -Array -( - [0] => d - [1] => Array - ( - [0] => 1 - [1] => 3 - [2] => 5 - ) - - [2] => 1 - [3] => -) - -Array -( - [0] => d - [1] => Array - ( - [0] => 1 - [1] => 3 - [2] => 5 - ) - - [2] => 1 - [3] => -) - --- Iteration 3 -- -Array -( - [0] => no_member_class Object - ( - ) - - [1] => Array - ( - ) - - [2] => - [3] => 0 -) - -Array -( - [0] => no_member_class Object - ( - ) - - [1] => Array - ( - ) - - [2] => - [3] => 0 -) - -Array -( - [0] => no_member_class Object - ( - ) - - [1] => Array - ( - ) - - [2] => - [3] => 0 -) - --- Iteration 4 -- -Array -( - [0] => -0 - [1] => Where am I? - [2] => Array - ( - [0] => 7 - [1] => 8 - [2] => 9 - ) - - [3] => 1 - [4] => A - [5] => 987654321 -) - -Array -( - [0] => -0 - [1] => Where am I? - [2] => Array - ( - [0] => 7 - [1] => 8 - [2] => 9 - ) - - [3] => 1 - [4] => A - [5] => 987654321 -) - -Array -( - [0] => -0 - [1] => Where am I? - [2] => Array - ( - [0] => 7 - [1] => 8 - [2] => 9 - ) - - [3] => 1 - [4] => A - [5] => 987654321 -) - --- Iteration 5 -- -Array -( - [0] => - [1] => 20000000000 - [2] => 79.1 - [3] => 4.599998 -) - -Array -( - [0] => - [1] => 20000000000 - [2] => 79.1 - [3] => 4.599998 -) - -Array -( - [0] => - [1] => 20000000000 - [2] => 79.1 - [3] => 4.599998 -) - --- Iteration 6 -- -Array -( - [0] => array(1,2,3,4)1.0000002TRUE - [1] => - [2] => 4611333 - [3] => /00\7 -) - -Array -( - [0] => array(1,2,3,4)1.0000002TRUE - [1] => - [2] => 4611333 - [3] => /00\7 -) - -Array -( - [0] => array(1,2,3,4)1.0000002TRUE - [1] => - [2] => 4611333 - [3] => /00\7 -) - -*** Testing print_r() on miscellaneous input arguments *** - --- Iteration 1 -- - - - --- Iteration 2 -- - - - --- Iteration 3 -- - - - --- Iteration 4 -- - - -Done diff --git a/ext/standard/tests/general_functions/print_r_array_circular.phpt b/ext/standard/tests/general_functions/print_r_array_circular.phpt new file mode 100644 index 0000000000000..a8ee05d778853 --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_array_circular.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test print_r() function with circular array +--FILE-- + +--EXPECT-- +Array +( + [0] => Array + ( + [0] => Array + *RECURSION* + ) + +) diff --git a/ext/standard/tests/general_functions/print_r_arrays.phpt b/ext/standard/tests/general_functions/print_r_arrays.phpt new file mode 100644 index 0000000000000..edb4aee84291a --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_arrays.phpt @@ -0,0 +1,166 @@ +--TEST-- +Test print_r() function with arrays +--INI-- +precision=14 +--FILE-- + 'One'], + ["test" => "is_array"], + [0], + [-1], + [10.5, 5.6], + ['string', 'test'], +]; + +foreach ($values as $value) { + print_r($value, false); + // $ret_string captures the output + $ret_string = print_r($value, true); + echo "\n$ret_string\n"; +} + +?> +--EXPECT-- +Array +( +) + +Array +( +) + +Array +( + [0] => 1 +) + +Array +( + [0] => 1 +) + +Array +( + [0] => Array + ( + ) + + [1] => Array + ( + ) + +) + +Array +( + [0] => Array + ( + ) + + [1] => Array + ( + ) + +) + +Array +( + [0] => Array + ( + [0] => 1 + [1] => 2 + ) + + [1] => Array + ( + [0] => a + [1] => b + ) + +) + +Array +( + [0] => Array + ( + [0] => 1 + [1] => 2 + ) + + [1] => Array + ( + [0] => a + [1] => b + ) + +) + +Array +( + [1] => One +) + +Array +( + [1] => One +) + +Array +( + [test] => is_array +) + +Array +( + [test] => is_array +) + +Array +( + [0] => 0 +) + +Array +( + [0] => 0 +) + +Array +( + [0] => -1 +) + +Array +( + [0] => -1 +) + +Array +( + [0] => 10.5 + [1] => 5.6 +) + +Array +( + [0] => 10.5 + [1] => 5.6 +) + +Array +( + [0] => string + [1] => test +) + +Array +( + [0] => string + [1] => test +) diff --git a/ext/standard/tests/general_functions/print_r_arrays_whitespace_sensitive.phpt b/ext/standard/tests/general_functions/print_r_arrays_whitespace_sensitive.phpt new file mode 100644 index 0000000000000..87137712064d1 --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_arrays_whitespace_sensitive.phpt @@ -0,0 +1,50 @@ +--TEST-- +Test print_r() function with arrays, output has trailing whitespaces +--WHITESPACE_SENSITIVE-- +--FILE-- + null], + ['false' => false], + ['empty' => ''], +]; + +foreach ($values as $value) { + print_r($value, false); + // $ret_string captures the output + $ret_string = print_r($value, true); + echo "\n$ret_string\n"; +} + +?> +--EXPECT-- +Array +( + [null] => +) + +Array +( + [null] => +) + +Array +( + [false] => +) + +Array +( + [false] => +) + +Array +( + [empty] => +) + +Array +( + [empty] => +) diff --git a/ext/standard/tests/general_functions/print_r_bools.phpt b/ext/standard/tests/general_functions/print_r_bools.phpt new file mode 100644 index 0000000000000..f96060ac36eb0 --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_bools.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test print_r() function with booleans +--FILE-- + true, + 'false' => false, +]; + +foreach ($values as $key => $value) { + echo "$key:\n"; + print_r($value, false); + // $ret_string captures the output + $ret_string = print_r($value, true); + echo "\n$ret_string\n"; +} + +?> +DONE +--EXPECT-- +true: +1 +1 +false: + + +DONE diff --git a/ext/standard/tests/general_functions/print_r_floats.phpt b/ext/standard/tests/general_functions/print_r_floats.phpt new file mode 100644 index 0000000000000..5da055ce2cb7a --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_floats.phpt @@ -0,0 +1,183 @@ +--TEST-- +Test print_r() function with floats +--INI-- +precision=14 +--FILE-- + +--EXPECT-- +-- Iteration 1 -- +-0 +-0 + +-- Iteration 2 -- +0 +0 + +-- Iteration 3 -- +1.234 +1.234 + +-- Iteration 4 -- +-1.234 +-1.234 + +-- Iteration 5 -- +-2 +-2 + +-- Iteration 6 -- +2 +2 + +-- Iteration 7 -- +-0.5 +-0.5 + +-- Iteration 8 -- +0.567 +0.567 + +-- Iteration 9 -- +-0.00067 +-0.00067 + +-- Iteration 10 -- +-670 +-670 + +-- Iteration 11 -- +670 +670 + +-- Iteration 12 -- +670 +670 + +-- Iteration 13 -- +-0.00410003 +-0.00410003 + +-- Iteration 14 -- +-4100.03 +-4100.03 + +-- Iteration 15 -- +0.004100003 +0.004100003 + +-- Iteration 16 -- +4100.003 +4100.003 + +-- Iteration 17 -- +100000 +100000 + +-- Iteration 18 -- +-100000 +-100000 + +-- Iteration 19 -- +1.0E-5 +1.0E-5 + +-- Iteration 20 -- +-1.0E-5 +-1.0E-5 + +-- Iteration 21 -- +100000 +100000 + +-- Iteration 22 -- +-100000 +-100000 + +-- Iteration 23 -- +100000 +100000 + +-- Iteration 24 -- +-100000 +-100000 + +-- Iteration 25 -- +100000 +100000 + +-- Iteration 26 -- +-100000 +-100000 + +-- Iteration 27 -- +1.0E-5 +1.0E-5 + +-- Iteration 28 -- +-1.0E-5 +-1.0E-5 + +-- Iteration 29 -- +-2147483649 +-2147483649 + +-- Iteration 30 -- +2147483649 +2147483649 + +-- Iteration 31 -- +2147483649 +2147483649 + +-- Iteration 32 -- +-2147483649 +-2147483649 diff --git a/ext/standard/tests/general_functions/print_r_ints.phpt b/ext/standard/tests/general_functions/print_r_ints.phpt new file mode 100644 index 0000000000000..ba1eb9d96be24 --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_ints.phpt @@ -0,0 +1,131 @@ +--TEST-- +Test print_r() function with integers +--INI-- +precision=14 +--FILE-- + +--EXPECT-- +-- Iteration 1 -- +0 +0 + +-- Iteration 2 -- +83 +83 + +-- Iteration 3 -- +123000000 +123000000 + +-- Iteration 4 -- +-83 +-83 + +-- Iteration 5 -- +-12300000 +-12300000 + +-- Iteration 6 -- +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => 5 + [5] => 6 + [6] => 7 + [7] => 8 + [8] => 9 + [9] => 10 +) + +Array +( + [0] => 1 + [1] => 2 + [2] => 3 + [3] => 4 + [4] => 5 + [5] => 6 + [6] => 7 + [7] => 8 + [8] => 9 + [9] => 10 +) + + +-- Iteration 7 -- +Array +( + [0] => -1 + [1] => -2 + [2] => -3 + [3] => -4 + [4] => -5 + [5] => -6 + [6] => -7 + [7] => -8 + [8] => -9 + [9] => -10 +) + +Array +( + [0] => -1 + [1] => -2 + [2] => -3 + [3] => -4 + [4] => -5 + [5] => -6 + [6] => -7 + [7] => -8 + [8] => -9 + [9] => -10 +) + + +-- Iteration 8 -- +2147483647 +2147483647 + +-- Iteration 9 -- +2147483648 +2147483648 + +-- Iteration 10 -- +-2147483648 +-2147483648 + +-- Iteration 11 -- +-2147483647 +-2147483647 diff --git a/ext/standard/tests/general_functions/print_r_ints_64bit.phpt b/ext/standard/tests/general_functions/print_r_ints_64bit.phpt new file mode 100644 index 0000000000000..f6f8a56d60782 --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_ints_64bit.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test print_r() function with 64 bit integers +--INI-- +precision=14 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +-- Iteration 1 -- +2147483647 +2147483647 +-- Iteration 2 -- +-2147483648 +-2147483648 +-- Iteration 3 -- +2147483647 +2147483647 +-- Iteration 4 -- +-2147483648 +-2147483648 diff --git a/ext/standard/tests/general_functions/print_r_null.phpt b/ext/standard/tests/general_functions/print_r_null.phpt new file mode 100644 index 0000000000000..14a31b1bd8d8d --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_null.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test print_r() function with null +--FILE-- + +DONE +--EXPECT-- +null: + + +DONE diff --git a/ext/standard/tests/general_functions/print_r_object.phpt b/ext/standard/tests/general_functions/print_r_object.phpt new file mode 100644 index 0000000000000..3fe40bc22cfa0 --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_object.phpt @@ -0,0 +1,228 @@ +--TEST-- +Test print_r() function +--FILE-- +value = 50; + $this->public_var2 = 11; + $this->private_var2 = 21; + $this->protected_var2 = "string_2"; + } + + public function foo1() { + echo "foo1() is called\n"; + } + protected function foo2() { + echo "foo2() is called\n"; + } + private function foo3() { + echo "foo3() is called\n"; + } +} + +class no_member_class {} + +/* class with member as object of other class */ +#[AllowDynamicProperties] +class contains_object_class +{ + var $p = 30; + var $class_object1; + public $class_object2; + private $class_object3; + protected $class_object4; + var $no_member_class_object; + + public function func() { + echo "func() is called \n"; + } + + function __construct() { + $this->class_object1 = new object_class(); + $this->class_object2 = new object_class(); + $this->class_object3 = $this->class_object1; + $this->class_object4 = $this->class_object2; + $this->no_member_class_object = new no_member_class(); + $this->class_object5 = $this; //recursive reference + } +} + +$objects = [ + new object_class, + new no_member_class, + new contains_object_class, +]; +check_printr($objects); + +?> +--EXPECT-- +*** Testing print_r() on object variables *** + +-- Iteration 1 -- +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + +object_class Object +( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 +) + + +-- Iteration 2 -- +no_member_class Object +( +) + +no_member_class Object +( +) + + +-- Iteration 3 -- +contains_object_class Object +( + [p] => 30 + [class_object1] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object2] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object3:contains_object_class:private] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object4:protected] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [no_member_class_object] => no_member_class Object + ( + ) + + [class_object5] => contains_object_class Object + *RECURSION* +) + +contains_object_class Object +( + [p] => 30 + [class_object1] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object2] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object3:contains_object_class:private] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [class_object4:protected] => object_class Object + ( + [value] => 50 + [public_var1] => 10 + [private_var1:object_class:private] => 20 + [private_var2:object_class:private] => 21 + [protected_var1:protected] => string_1 + [protected_var2:protected] => string_2 + [public_var2] => 11 + ) + + [no_member_class_object] => no_member_class Object + ( + ) + + [class_object5] => contains_object_class Object + *RECURSION* +) diff --git a/ext/standard/tests/general_functions/print_r_object_circular.phpt b/ext/standard/tests/general_functions/print_r_object_circular.phpt new file mode 100644 index 0000000000000..2930f341ae76c --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_object_circular.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test print_r() function function with circular objects +--FILE-- +obj = $recursion_obj2; +$recursion_obj2->obj = $recursion_obj1; +print_r($recursion_obj2); + +?> +--EXPECT-- +Circular Object +( + [obj] => Circular Object + ( + [obj] => Circular Object + *RECURSION* + ) + +) diff --git a/ext/standard/tests/general_functions/print_r_resources.phpt b/ext/standard/tests/general_functions/print_r_resources.phpt new file mode 100644 index 0000000000000..7a8ea357ac40a --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_resources.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test print_r() function with resources +--FILE-- + +--EXPECT-- +Resource id #1 +Resource id #1 +Resource id #3 +Resource id #3 diff --git a/ext/standard/tests/general_functions/print_r_strings.phpt b/ext/standard/tests/general_functions/print_r_strings.phpt new file mode 100644 index 0000000000000..b01737978cd39 --- /dev/null +++ b/ext/standard/tests/general_functions/print_r_strings.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test print_r() function with strings +--WHITESPACE_SENSITIVE-- +--FILE-- + +--EXPECT-- +-- Iteration 1 -- + + +-- Iteration 2 -- + + +-- Iteration 3 -- +0 +0 +-- Iteration 4 -- +\0 +\0 +-- Iteration 5 -- + + +-- Iteration 6 -- +\t +\t +-- Iteration 7 -- +PHP +PHP +-- Iteration 8 -- +1234 +5678 + 9100"abcda +1234 +5678 + 9100"abcda diff --git a/ext/standard/tests/general_functions/print_r_strings_nul_bytes.phpt b/ext/standard/tests/general_functions/print_r_strings_nul_bytes.phpt new file mode 100644 index 0000000000000000000000000000000000000000..626e88e613b109b5d8e77ac7a066008591868f32 GIT binary patch literal 916 zcmaiyZ)@8y5XSXdpW-li(NK#hZTAPdtS^QKfl$Vp!eAajQRG^yD|wRKrW^h4J=wDx zL)q*X5~q6}-S2dat+T5&V|1;2fZAyjHtuK&MPp>p*1&@fCHQ~`Hy)%lL1=?}Fii#9 z$DllAY%Bvb2!ohA~*8i)bMRPsVbSbgnVE=N-yOp%9f< z)0dRl3?@#6#+k+X>vfh6nklxXs-Qaq9X!}3)J;f18y}R|fi1e^*e)Gflz3^h+jJd8 z##c%RuE7dmHapCeqQ)YyPoY$QZyFqX=7anZW{-b-+;Kh8CrT&%qb}e(Iwd(z(zuGP z+~s?2<|n6TxN`pH?YsBwhO6SH%=h}|ZIz^0-Y^#JjFf6Gb~pidqJqoo)oSqSWIW2E z&7HAzYxm3fkaOPLKkRYg{PFiIu2zQL@5ec%qv`1h@U`g0M;y8A+n4N99OlvE&jBL@ s|8e*vh9fL#QAx{5_yOd9PRDkqgI(+riL@l55*|58q$G&gdHy@)8UKkGw*UYD literal 0 HcmV?d00001 From 5dae1e1dc2ad5c2a9e33c4302175b3809273eeb1 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Tue, 4 Mar 2025 02:40:57 +0000 Subject: [PATCH 4/6] Split var_dump tests So that these aren't huge mega tests --- .../tests/general_functions/var_dump.phpt | 1549 ----------------- .../general_functions/var_dump_64bit.phpt | 1549 ----------------- .../var_dump_array_circular.phpt | 20 + .../general_functions/var_dump_arrays.phpt | 99 ++ .../general_functions/var_dump_bools.phpt | 23 + .../general_functions/var_dump_floats.phpt | 76 + .../general_functions/var_dump_ints.phpt | 92 + .../var_dump_ints_32bit.phpt | 33 + .../var_dump_ints_64bit.phpt | 45 + .../general_functions/var_dump_null.phpt | 12 + .../general_functions/var_dump_object.phpt | 181 ++ .../var_dump_object_circular.phpt | 24 + .../general_functions/var_dump_resources.phpt | 18 + .../general_functions/var_dump_strings.phpt | 48 + .../var_dump_strings_nul_bytes.phpt | Bin 0 -> 663 bytes 15 files changed, 671 insertions(+), 3098 deletions(-) delete mode 100644 ext/standard/tests/general_functions/var_dump.phpt delete mode 100644 ext/standard/tests/general_functions/var_dump_64bit.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_array_circular.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_arrays.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_bools.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_floats.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_ints.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_ints_32bit.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_ints_64bit.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_null.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_object.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_object_circular.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_resources.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_strings.phpt create mode 100644 ext/standard/tests/general_functions/var_dump_strings_nul_bytes.phpt diff --git a/ext/standard/tests/general_functions/var_dump.phpt b/ext/standard/tests/general_functions/var_dump.phpt deleted file mode 100644 index 0cbd1fce9c66c..0000000000000 --- a/ext/standard/tests/general_functions/var_dump.phpt +++ /dev/null @@ -1,1549 +0,0 @@ ---TEST-- -Test var_dump() function ---SKIPIF-- - ---INI-- -precision=14 ---FILE-- - 'One'), - array("test" => "is_array"), - array(0), - array(-1), - array(10.5, 5.6), - array("string", "test"), - array('string', 'test'), -); -/* calling check_vardump() to display contents of an array - using var_dump() */ -check_vardump($arrays); - -echo "\n*** Testing var_dump() on object variables ***\n"; -#[AllowDynamicProperties] -class object_class -{ - var $value; - public $public_var1 = 10; - private $private_var1 = 20; - private $private_var2; - protected $protected_var1 = "string_1"; - protected $protected_var2; - - function __construct() { - $this->value = 50; - $this->public_var2 = 11; - $this->private_var2 = 21; - $this->protected_var2 = "string_2"; - } - - public function foo1() { - echo "foo1() is called\n"; - } - protected function foo2() { - echo "foo2() is called\n"; - } - private function foo3() { - echo "foo3() is called\n"; - } -} -/* class with no member */ -class no_member_class { - // no members -} - -/* class with member as object of other class */ -#[AllowDynamicProperties] -class contains_object_class -{ - var $p = 30; - var $class_object1; - public $class_object2; - private $class_object3; - protected $class_object4; - var $no_member_class_object; - - public function func() { - echo "func() is called \n"; - } - - function __construct() { - $this->class_object1 = new object_class(); - $this->class_object2 = new object_class(); - $this->class_object3 = $this->class_object1; - $this->class_object4 = $this->class_object2; - $this->no_member_class_object = new no_member_class(); - $this->class_object5 = $this; //recursive reference - } -} - -/* objects of different classes */ -$obj = new contains_object_class; -$temp_class_obj = new object_class(); - -/* object which is unset */ -$unset_obj = new object_class(); -unset($unset_obj); - -$objects = array ( - new object_class, - new no_member_class, - new contains_object_class, - $obj, - $obj->class_object1, - $obj->class_object2, - $obj->no_member_class_object, - $temp_class_obj, - @$unset_obj -); -/* calling check_vardump() to display contents of the objects - using var_dump() */ -check_vardump($objects); - -echo "\n** Testing var_dump() on objects having circular reference **\n"; -$recursion_obj1 = new object_class(); -$recursion_obj2 = new object_class(); -$recursion_obj1->obj = &$recursion_obj2; //circular reference -$recursion_obj2->obj = &$recursion_obj1; //circular reference -var_dump($recursion_obj2); - -echo "\n*** Testing var_dump() on resources ***\n"; -/* file type resource */ -$file_handle = fopen(__FILE__, "r"); - -/* directory type resource */ -$dir_handle = opendir( __DIR__ ); - -$resources = array ( - $file_handle, - $dir_handle -); -/* calling check_vardump() to display the resource content type - using var_dump() */ -check_vardump($resources); - -echo "\n*** Testing var_dump() on different combinations of scalar - and non-scalar variables ***\n"; -/* a variable which is unset */ -$unset_var = 10.5; -unset($unset_var); - -/* unset file type resource */ -unset($file_handle); - -$variations = array ( - array( 123, -1.2345, "a" ), - array( "d", array(1, 3, 5), true, null), - array( new no_member_class, array(), false, 0 ), - array( -0.00, "Where am I?", array(7,8,9), TRUE, 'A', 987654321 ), - array( @$unset_var, 2.E+10, 100-20.9, 000004.599998 ), //unusual data - array( "array(1,2,3,4)1.0000002TRUE", @$file_handle, 111333.00+45e5, '/00\7') -); -/* calling check_vardump() to display combinations of scalar and - non-scalar variables using var_dump() */ -check_vardump($variations); - -echo "\n*** Testing var_dump() on miscellaneous input arguments ***\n"; -$misc_values = array ( - @$unset_var, - NULL, // NULL argument - @$undef_variable, //undefined variable - null -); -/* calling check_vardump() to display miscellaneous data using var_dump() */ -check_vardump($misc_values); - -echo "\n*** Testing var_dump() on multiple arguments ***\n"; -var_dump( $integers, $floats, $strings, $arrays, $booleans, $resources, - $objects, $misc_values, $variations ); - -/* closing resource handle used */ -closedir($dir_handle); - -echo "Done\n"; -?> ---EXPECTF-- -*** Testing var_dump() on integer variables *** --- Iteration 1 -- -int(0) --- Iteration 2 -- -int(83) --- Iteration 3 -- -int(123000000) --- Iteration 4 -- -int(-83) --- Iteration 5 -- -int(-12300000) --- Iteration 6 -- -array(10) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - [7]=> - int(8) - [8]=> - int(9) - [9]=> - int(10) -} --- Iteration 7 -- -array(10) { - [0]=> - int(-1) - [1]=> - int(-2) - [2]=> - int(-3) - [3]=> - int(-4) - [4]=> - int(-5) - [5]=> - int(-6) - [6]=> - int(-7) - [7]=> - int(-8) - [8]=> - int(-9) - [9]=> - int(-10) -} --- Iteration 8 -- -int(2147483647) --- Iteration 9 -- -float(2147483648) --- Iteration 10 -- -float(-2147483648) --- Iteration 11 -- -int(-2147483647) --- Iteration 12 -- -int(2147483647) --- Iteration 13 -- -float(-2147483648) --- Iteration 14 -- -int(2147483647) --- Iteration 15 -- -float(-2147483648) - -*** Testing var_dump() on float variables *** --- Iteration 1 -- -float(-0) --- Iteration 2 -- -float(0) --- Iteration 3 -- -float(1.234) --- Iteration 4 -- -float(-1.234) --- Iteration 5 -- -float(-2) --- Iteration 6 -- -float(2) --- Iteration 7 -- -float(-0.5) --- Iteration 8 -- -float(0.567) --- Iteration 9 -- -float(-0.00067) --- Iteration 10 -- -float(-670) --- Iteration 11 -- -float(670) --- Iteration 12 -- -float(670) --- Iteration 13 -- -float(-0.00410003) --- Iteration 14 -- -float(-4100.03) --- Iteration 15 -- -float(0.004100003) --- Iteration 16 -- -float(4100.003) --- Iteration 17 -- -float(100000) --- Iteration 18 -- -float(-100000) --- Iteration 19 -- -float(1.0E-5) --- Iteration 20 -- -float(-1.0E-5) --- Iteration 21 -- -float(100000) --- Iteration 22 -- -float(-100000) --- Iteration 23 -- -float(100000) --- Iteration 24 -- -float(-100000) --- Iteration 25 -- -float(100000) --- Iteration 26 -- -float(-100000) --- Iteration 27 -- -float(1.0E-5) --- Iteration 28 -- -float(-1.0E-5) --- Iteration 29 -- -float(-2147483649) --- Iteration 30 -- -float(2147483649) --- Iteration 31 -- -float(2147483649) --- Iteration 32 -- -float(-2147483649) - -*** Testing var_dump() on string variables *** --- Iteration 1 -- -string(0) "" --- Iteration 2 -- -string(0) "" --- Iteration 3 -- -string(1) " " --- Iteration 4 -- -string(1) " " --- Iteration 5 -- -string(1) "0" --- Iteration 6 -- -string(1) "%0" --- Iteration 7 -- -string(2) "\0" --- Iteration 8 -- -string(1) " " --- Iteration 9 -- -string(2) "\t" --- Iteration 10 -- -string(3) "PHP" --- Iteration 11 -- -string(3) "PHP" --- Iteration 12 -- -string(29) "abcd%0n1234%005678%000efgh\xijkl" --- Iteration 13 -- -string(34) "abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz" --- Iteration 14 -- -string(22) "1234 -5678 - 9100"abcda" - -*** Testing var_dump() on boolean variables *** --- Iteration 1 -- -bool(true) --- Iteration 2 -- -bool(false) --- Iteration 3 -- -bool(true) --- Iteration 4 -- -bool(false) - -*** Testing var_dump() on array variables *** --- Iteration 1 -- -array(0) { -} --- Iteration 2 -- -array(1) { - [0]=> - NULL -} --- Iteration 3 -- -array(1) { - [0]=> - NULL -} --- Iteration 4 -- -array(1) { - [0]=> - bool(true) -} --- Iteration 5 -- -array(1) { - [0]=> - string(0) "" -} --- Iteration 6 -- -array(1) { - [0]=> - string(0) "" -} --- Iteration 7 -- -array(2) { - [0]=> - array(0) { - } - [1]=> - array(0) { - } -} --- Iteration 8 -- -array(2) { - [0]=> - array(2) { - [0]=> - int(1) - [1]=> - int(2) - } - [1]=> - array(2) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - } -} --- Iteration 9 -- -array(1) { - [1]=> - string(3) "One" -} --- Iteration 10 -- -array(1) { - ["test"]=> - string(8) "is_array" -} --- Iteration 11 -- -array(1) { - [0]=> - int(0) -} --- Iteration 12 -- -array(1) { - [0]=> - int(-1) -} --- Iteration 13 -- -array(2) { - [0]=> - float(10.5) - [1]=> - float(5.6) -} --- Iteration 14 -- -array(2) { - [0]=> - string(6) "string" - [1]=> - string(4) "test" -} --- Iteration 15 -- -array(2) { - [0]=> - string(6) "string" - [1]=> - string(4) "test" -} - -*** Testing var_dump() on object variables *** --- Iteration 1 -- -object(object_class)#6 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) -} --- Iteration 2 -- -object(no_member_class)#7 (0) { -} --- Iteration 3 -- -object(contains_object_class)#8 (7) { - ["p"]=> - int(30) - ["class_object1"]=> - object(object_class)#9 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object2"]=> - object(object_class)#10 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object3":"contains_object_class":private]=> - object(object_class)#9 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object4":protected]=> - object(object_class)#10 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["no_member_class_object"]=> - object(no_member_class)#11 (0) { - } - ["class_object5"]=> - *RECURSION* -} --- Iteration 4 -- -object(contains_object_class)#1 (7) { - ["p"]=> - int(30) - ["class_object1"]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object2"]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object3":"contains_object_class":private]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object4":protected]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["no_member_class_object"]=> - object(no_member_class)#4 (0) { - } - ["class_object5"]=> - *RECURSION* -} --- Iteration 5 -- -object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) -} --- Iteration 6 -- -object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) -} --- Iteration 7 -- -object(no_member_class)#4 (0) { -} --- Iteration 8 -- -object(object_class)#5 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) -} --- Iteration 9 -- -NULL - -** Testing var_dump() on objects having circular reference ** -object(object_class)#13 (8) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - ["obj"]=> - &object(object_class)#12 (8) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - ["obj"]=> - *RECURSION* - } -} - -*** Testing var_dump() on resources *** --- Iteration 1 -- -resource(%d) of type (stream) --- Iteration 2 -- -resource(%d) of type (stream) - -*** Testing var_dump() on different combinations of scalar - and non-scalar variables *** --- Iteration 1 -- -array(3) { - [0]=> - int(123) - [1]=> - float(-1.2345) - [2]=> - string(1) "a" -} --- Iteration 2 -- -array(4) { - [0]=> - string(1) "d" - [1]=> - array(3) { - [0]=> - int(1) - [1]=> - int(3) - [2]=> - int(5) - } - [2]=> - bool(true) - [3]=> - NULL -} --- Iteration 3 -- -array(4) { - [0]=> - object(no_member_class)#14 (0) { - } - [1]=> - array(0) { - } - [2]=> - bool(false) - [3]=> - int(0) -} --- Iteration 4 -- -array(6) { - [0]=> - float(-0) - [1]=> - string(11) "Where am I?" - [2]=> - array(3) { - [0]=> - int(7) - [1]=> - int(8) - [2]=> - int(9) - } - [3]=> - bool(true) - [4]=> - string(1) "A" - [5]=> - int(987654321) -} --- Iteration 5 -- -array(4) { - [0]=> - NULL - [1]=> - float(20000000000) - [2]=> - float(79.1) - [3]=> - float(4.599998) -} --- Iteration 6 -- -array(4) { - [0]=> - string(27) "array(1,2,3,4)1.0000002TRUE" - [1]=> - NULL - [2]=> - float(4611333) - [3]=> - string(5) "/00\7" -} - -*** Testing var_dump() on miscellaneous input arguments *** --- Iteration 1 -- -NULL --- Iteration 2 -- -NULL --- Iteration 3 -- -NULL --- Iteration 4 -- -NULL - -*** Testing var_dump() on multiple arguments *** -array(15) { - [0]=> - int(0) - [1]=> - int(83) - [2]=> - int(123000000) - [3]=> - int(-83) - [4]=> - int(-12300000) - [5]=> - array(10) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - [7]=> - int(8) - [8]=> - int(9) - [9]=> - int(10) - } - [6]=> - array(10) { - [0]=> - int(-1) - [1]=> - int(-2) - [2]=> - int(-3) - [3]=> - int(-4) - [4]=> - int(-5) - [5]=> - int(-6) - [6]=> - int(-7) - [7]=> - int(-8) - [8]=> - int(-9) - [9]=> - int(-10) - } - [7]=> - int(2147483647) - [8]=> - float(2147483648) - [9]=> - float(-2147483648) - [10]=> - int(-2147483647) - [11]=> - int(2147483647) - [12]=> - float(-2147483648) - [13]=> - int(2147483647) - [14]=> - float(-2147483648) -} -array(32) { - [0]=> - float(-0) - [1]=> - float(0) - [2]=> - float(1.234) - [3]=> - float(-1.234) - [4]=> - float(-2) - [5]=> - float(2) - [6]=> - float(-0.5) - [7]=> - float(0.567) - [8]=> - float(-0.00067) - [9]=> - float(-670) - [10]=> - float(670) - [11]=> - float(670) - [12]=> - float(-0.00410003) - [13]=> - float(-4100.03) - [14]=> - float(0.004100003) - [15]=> - float(4100.003) - [16]=> - float(100000) - [17]=> - float(-100000) - [18]=> - float(1.0E-5) - [19]=> - float(-1.0E-5) - [20]=> - float(100000) - [21]=> - float(-100000) - [22]=> - float(100000) - [23]=> - float(-100000) - [24]=> - float(100000) - [25]=> - float(-100000) - [26]=> - float(1.0E-5) - [27]=> - float(-1.0E-5) - [28]=> - float(-2147483649) - [29]=> - float(2147483649) - [30]=> - float(2147483649) - [31]=> - float(-2147483649) -} -array(14) { - [0]=> - string(0) "" - [1]=> - string(0) "" - [2]=> - string(1) " " - [3]=> - string(1) " " - [4]=> - string(1) "0" - [5]=> - string(1) "%0" - [6]=> - string(2) "\0" - [7]=> - string(1) " " - [8]=> - string(2) "\t" - [9]=> - string(3) "PHP" - [10]=> - string(3) "PHP" - [11]=> - string(29) "abcd%0n1234%005678%000efgh\xijkl" - [12]=> - string(34) "abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz" - [13]=> - string(22) "1234 -5678 - 9100"abcda" -} -array(15) { - [0]=> - array(0) { - } - [1]=> - array(1) { - [0]=> - NULL - } - [2]=> - array(1) { - [0]=> - NULL - } - [3]=> - array(1) { - [0]=> - bool(true) - } - [4]=> - array(1) { - [0]=> - string(0) "" - } - [5]=> - array(1) { - [0]=> - string(0) "" - } - [6]=> - array(2) { - [0]=> - array(0) { - } - [1]=> - array(0) { - } - } - [7]=> - array(2) { - [0]=> - array(2) { - [0]=> - int(1) - [1]=> - int(2) - } - [1]=> - array(2) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - } - } - [8]=> - array(1) { - [1]=> - string(3) "One" - } - [9]=> - array(1) { - ["test"]=> - string(8) "is_array" - } - [10]=> - array(1) { - [0]=> - int(0) - } - [11]=> - array(1) { - [0]=> - int(-1) - } - [12]=> - array(2) { - [0]=> - float(10.5) - [1]=> - float(5.6) - } - [13]=> - array(2) { - [0]=> - string(6) "string" - [1]=> - string(4) "test" - } - [14]=> - array(2) { - [0]=> - string(6) "string" - [1]=> - string(4) "test" - } -} -array(4) { - [0]=> - bool(true) - [1]=> - bool(false) - [2]=> - bool(true) - [3]=> - bool(false) -} -array(2) { - [0]=> - resource(%d) of type (stream) - [1]=> - resource(%d) of type (stream) -} -array(9) { - [0]=> - object(object_class)#6 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - [1]=> - object(no_member_class)#7 (0) { - } - [2]=> - object(contains_object_class)#8 (7) { - ["p"]=> - int(30) - ["class_object1"]=> - object(object_class)#9 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object2"]=> - object(object_class)#10 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object3":"contains_object_class":private]=> - object(object_class)#9 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object4":protected]=> - object(object_class)#10 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["no_member_class_object"]=> - object(no_member_class)#11 (0) { - } - ["class_object5"]=> - *RECURSION* - } - [3]=> - object(contains_object_class)#1 (7) { - ["p"]=> - int(30) - ["class_object1"]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object2"]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object3":"contains_object_class":private]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object4":protected]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["no_member_class_object"]=> - object(no_member_class)#4 (0) { - } - ["class_object5"]=> - *RECURSION* - } - [4]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - [5]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - [6]=> - object(no_member_class)#4 (0) { - } - [7]=> - object(object_class)#5 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - [8]=> - NULL -} -array(4) { - [0]=> - NULL - [1]=> - NULL - [2]=> - NULL - [3]=> - NULL -} -array(6) { - [0]=> - array(3) { - [0]=> - int(123) - [1]=> - float(-1.2345) - [2]=> - string(1) "a" - } - [1]=> - array(4) { - [0]=> - string(1) "d" - [1]=> - array(3) { - [0]=> - int(1) - [1]=> - int(3) - [2]=> - int(5) - } - [2]=> - bool(true) - [3]=> - NULL - } - [2]=> - array(4) { - [0]=> - object(no_member_class)#14 (0) { - } - [1]=> - array(0) { - } - [2]=> - bool(false) - [3]=> - int(0) - } - [3]=> - array(6) { - [0]=> - float(-0) - [1]=> - string(11) "Where am I?" - [2]=> - array(3) { - [0]=> - int(7) - [1]=> - int(8) - [2]=> - int(9) - } - [3]=> - bool(true) - [4]=> - string(1) "A" - [5]=> - int(987654321) - } - [4]=> - array(4) { - [0]=> - NULL - [1]=> - float(20000000000) - [2]=> - float(79.1) - [3]=> - float(4.599998) - } - [5]=> - array(4) { - [0]=> - string(27) "array(1,2,3,4)1.0000002TRUE" - [1]=> - NULL - [2]=> - float(4611333) - [3]=> - string(5) "/00\7" - } -} -Done diff --git a/ext/standard/tests/general_functions/var_dump_64bit.phpt b/ext/standard/tests/general_functions/var_dump_64bit.phpt deleted file mode 100644 index cbf9c003bdb92..0000000000000 --- a/ext/standard/tests/general_functions/var_dump_64bit.phpt +++ /dev/null @@ -1,1549 +0,0 @@ ---TEST-- -Test var_dump() function ---SKIPIF-- - ---INI-- -precision=14 ---FILE-- - 'One'), - array("test" => "is_array"), - array(0), - array(-1), - array(10.5, 5.6), - array("string", "test"), - array('string', 'test'), -); -/* calling check_vardump() to display contents of an array - using var_dump() */ -check_vardump($arrays); - -echo "\n*** Testing var_dump() on object variables ***\n"; -#[AllowDynamicProperties] -class object_class -{ - var $value; - public $public_var1 = 10; - private $private_var1 = 20; - private $private_var2; - protected $protected_var1 = "string_1"; - protected $protected_var2; - - function __construct ( ) { - $this->value = 50; - $this->public_var2 = 11; - $this->private_var2 = 21; - $this->protected_var2 = "string_2"; - } - - public function foo1() { - echo "foo1() is called\n"; - } - protected function foo2() { - echo "foo2() is called\n"; - } - private function foo3() { - echo "foo3() is called\n"; - } -} -/* class with no member */ -class no_member_class { - // no members -} - -/* class with member as object of other class */ -#[AllowDynamicProperties] -class contains_object_class -{ - var $p = 30; - var $class_object1; - public $class_object2; - private $class_object3; - protected $class_object4; - var $no_member_class_object; - - public function func() { - echo "func() is called \n"; - } - - function __construct () { - $this->class_object1 = new object_class(); - $this->class_object2 = new object_class(); - $this->class_object3 = $this->class_object1; - $this->class_object4 = $this->class_object2; - $this->no_member_class_object = new no_member_class(); - $this->class_object5 = $this; //recursive reference - } -} - -/* objects of different classes */ -$obj = new contains_object_class; -$temp_class_obj = new object_class(); - -/* object which is unset */ -$unset_obj = new object_class(); -unset($unset_obj); - -$objects = array ( - new object_class, - new no_member_class, - new contains_object_class, - $obj, - $obj->class_object1, - $obj->class_object2, - $obj->no_member_class_object, - $temp_class_obj, - @$unset_obj -); -/* calling check_vardump() to display contents of the objects - using var_dump() */ -check_vardump($objects); - -echo "\n** Testing var_dump() on objects having circular reference **\n"; -$recursion_obj1 = new object_class(); -$recursion_obj2 = new object_class(); -$recursion_obj1->obj = &$recursion_obj2; //circular reference -$recursion_obj2->obj = &$recursion_obj1; //circular reference -var_dump($recursion_obj2); - -echo "\n*** Testing var_dump() on resources ***\n"; -/* file type resource */ -$file_handle = fopen(__FILE__, "r"); - -/* directory type resource */ -$dir_handle = opendir( __DIR__ ); - -$resources = array ( - $file_handle, - $dir_handle -); -/* calling check_vardump() to display the resource content type - using var_dump() */ -check_vardump($resources); - -echo "\n*** Testing var_dump() on different combinations of scalar - and non-scalar variables ***\n"; -/* a variable which is unset */ -$unset_var = 10.5; -unset($unset_var); - -/* unset file type resource */ -unset($file_handle); - -$variations = array ( - array( 123, -1.2345, "a" ), - array( "d", array(1, 3, 5), true, null), - array( new no_member_class, array(), false, 0 ), - array( -0.00, "Where am I?", array(7,8,9), TRUE, 'A', 987654321 ), - array( @$unset_var, 2.E+10, 100-20.9, 000004.599998 ), //unusual data - array( "array(1,2,3,4)1.0000002TRUE", @$file_handle, 111333.00+45e5, '/00\7') -); -/* calling check_vardump() to display combinations of scalar and - non-scalar variables using var_dump() */ -check_vardump($variations); - -echo "\n*** Testing var_dump() on miscellaneous input arguments ***\n"; -$misc_values = array ( - @$unset_var, - NULL, // NULL argument - @$undef_variable, //undefined variable - null -); -/* calling check_vardump() to display miscellaneous data using var_dump() */ -check_vardump($misc_values); - -echo "\n*** Testing var_dump() on multiple arguments ***\n"; -var_dump( $integers, $floats, $strings, $arrays, $booleans, $resources, - $objects, $misc_values, $variations ); - -/* closing resource handle used */ -closedir($dir_handle); - -echo "Done\n"; -?> ---EXPECTF-- -*** Testing var_dump() on integer variables *** --- Iteration 1 -- -int(0) --- Iteration 2 -- -int(83) --- Iteration 3 -- -int(123000000) --- Iteration 4 -- -int(-83) --- Iteration 5 -- -int(-12300000) --- Iteration 6 -- -array(10) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - [7]=> - int(8) - [8]=> - int(9) - [9]=> - int(10) -} --- Iteration 7 -- -array(10) { - [0]=> - int(-1) - [1]=> - int(-2) - [2]=> - int(-3) - [3]=> - int(-4) - [4]=> - int(-5) - [5]=> - int(-6) - [6]=> - int(-7) - [7]=> - int(-8) - [8]=> - int(-9) - [9]=> - int(-10) -} --- Iteration 8 -- -int(2147483647) --- Iteration 9 -- -int(2147483648) --- Iteration 10 -- -int(-2147483648) --- Iteration 11 -- -int(-2147483647) --- Iteration 12 -- -int(2147483647) --- Iteration 13 -- -int(-2147483648) --- Iteration 14 -- -int(2147483647) --- Iteration 15 -- -int(-2147483648) - -*** Testing var_dump() on float variables *** --- Iteration 1 -- -float(-0) --- Iteration 2 -- -float(0) --- Iteration 3 -- -float(1.234) --- Iteration 4 -- -float(-1.234) --- Iteration 5 -- -float(-2) --- Iteration 6 -- -float(2) --- Iteration 7 -- -float(-0.5) --- Iteration 8 -- -float(0.567) --- Iteration 9 -- -float(-0.00067) --- Iteration 10 -- -float(-670) --- Iteration 11 -- -float(670) --- Iteration 12 -- -float(670) --- Iteration 13 -- -float(-0.00410003) --- Iteration 14 -- -float(-4100.03) --- Iteration 15 -- -float(0.004100003) --- Iteration 16 -- -float(4100.003) --- Iteration 17 -- -float(100000) --- Iteration 18 -- -float(-100000) --- Iteration 19 -- -float(1.0E-5) --- Iteration 20 -- -float(-1.0E-5) --- Iteration 21 -- -float(100000) --- Iteration 22 -- -float(-100000) --- Iteration 23 -- -float(100000) --- Iteration 24 -- -float(-100000) --- Iteration 25 -- -float(100000) --- Iteration 26 -- -float(-100000) --- Iteration 27 -- -float(1.0E-5) --- Iteration 28 -- -float(-1.0E-5) --- Iteration 29 -- -int(-2147483649) --- Iteration 30 -- -int(2147483649) --- Iteration 31 -- -int(2147483649) --- Iteration 32 -- -int(-2147483649) - -*** Testing var_dump() on string variables *** --- Iteration 1 -- -string(0) "" --- Iteration 2 -- -string(0) "" --- Iteration 3 -- -string(1) " " --- Iteration 4 -- -string(1) " " --- Iteration 5 -- -string(1) "0" --- Iteration 6 -- -string(1) "%0" --- Iteration 7 -- -string(2) "\0" --- Iteration 8 -- -string(1) " " --- Iteration 9 -- -string(2) "\t" --- Iteration 10 -- -string(3) "PHP" --- Iteration 11 -- -string(3) "PHP" --- Iteration 12 -- -string(29) "abcd%0n1234%005678%000efgh\xijkl" --- Iteration 13 -- -string(34) "abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz" --- Iteration 14 -- -string(22) "1234 -5678 - 9100"abcda" - -*** Testing var_dump() on boolean variables *** --- Iteration 1 -- -bool(true) --- Iteration 2 -- -bool(false) --- Iteration 3 -- -bool(true) --- Iteration 4 -- -bool(false) - -*** Testing var_dump() on array variables *** --- Iteration 1 -- -array(0) { -} --- Iteration 2 -- -array(1) { - [0]=> - NULL -} --- Iteration 3 -- -array(1) { - [0]=> - NULL -} --- Iteration 4 -- -array(1) { - [0]=> - bool(true) -} --- Iteration 5 -- -array(1) { - [0]=> - string(0) "" -} --- Iteration 6 -- -array(1) { - [0]=> - string(0) "" -} --- Iteration 7 -- -array(2) { - [0]=> - array(0) { - } - [1]=> - array(0) { - } -} --- Iteration 8 -- -array(2) { - [0]=> - array(2) { - [0]=> - int(1) - [1]=> - int(2) - } - [1]=> - array(2) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - } -} --- Iteration 9 -- -array(1) { - [1]=> - string(3) "One" -} --- Iteration 10 -- -array(1) { - ["test"]=> - string(8) "is_array" -} --- Iteration 11 -- -array(1) { - [0]=> - int(0) -} --- Iteration 12 -- -array(1) { - [0]=> - int(-1) -} --- Iteration 13 -- -array(2) { - [0]=> - float(10.5) - [1]=> - float(5.6) -} --- Iteration 14 -- -array(2) { - [0]=> - string(6) "string" - [1]=> - string(4) "test" -} --- Iteration 15 -- -array(2) { - [0]=> - string(6) "string" - [1]=> - string(4) "test" -} - -*** Testing var_dump() on object variables *** --- Iteration 1 -- -object(object_class)#6 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) -} --- Iteration 2 -- -object(no_member_class)#7 (0) { -} --- Iteration 3 -- -object(contains_object_class)#8 (7) { - ["p"]=> - int(30) - ["class_object1"]=> - object(object_class)#9 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object2"]=> - object(object_class)#10 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object3":"contains_object_class":private]=> - object(object_class)#9 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object4":protected]=> - object(object_class)#10 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["no_member_class_object"]=> - object(no_member_class)#11 (0) { - } - ["class_object5"]=> - *RECURSION* -} --- Iteration 4 -- -object(contains_object_class)#1 (7) { - ["p"]=> - int(30) - ["class_object1"]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object2"]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object3":"contains_object_class":private]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object4":protected]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["no_member_class_object"]=> - object(no_member_class)#4 (0) { - } - ["class_object5"]=> - *RECURSION* -} --- Iteration 5 -- -object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) -} --- Iteration 6 -- -object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) -} --- Iteration 7 -- -object(no_member_class)#4 (0) { -} --- Iteration 8 -- -object(object_class)#5 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) -} --- Iteration 9 -- -NULL - -** Testing var_dump() on objects having circular reference ** -object(object_class)#13 (8) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - ["obj"]=> - &object(object_class)#12 (8) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - ["obj"]=> - *RECURSION* - } -} - -*** Testing var_dump() on resources *** --- Iteration 1 -- -resource(5) of type (stream) --- Iteration 2 -- -resource(6) of type (stream) - -*** Testing var_dump() on different combinations of scalar - and non-scalar variables *** --- Iteration 1 -- -array(3) { - [0]=> - int(123) - [1]=> - float(-1.2345) - [2]=> - string(1) "a" -} --- Iteration 2 -- -array(4) { - [0]=> - string(1) "d" - [1]=> - array(3) { - [0]=> - int(1) - [1]=> - int(3) - [2]=> - int(5) - } - [2]=> - bool(true) - [3]=> - NULL -} --- Iteration 3 -- -array(4) { - [0]=> - object(no_member_class)#14 (0) { - } - [1]=> - array(0) { - } - [2]=> - bool(false) - [3]=> - int(0) -} --- Iteration 4 -- -array(6) { - [0]=> - float(-0) - [1]=> - string(11) "Where am I?" - [2]=> - array(3) { - [0]=> - int(7) - [1]=> - int(8) - [2]=> - int(9) - } - [3]=> - bool(true) - [4]=> - string(1) "A" - [5]=> - int(987654321) -} --- Iteration 5 -- -array(4) { - [0]=> - NULL - [1]=> - float(20000000000) - [2]=> - float(79.1) - [3]=> - float(4.599998) -} --- Iteration 6 -- -array(4) { - [0]=> - string(27) "array(1,2,3,4)1.0000002TRUE" - [1]=> - NULL - [2]=> - float(4611333) - [3]=> - string(5) "/00\7" -} - -*** Testing var_dump() on miscellaneous input arguments *** --- Iteration 1 -- -NULL --- Iteration 2 -- -NULL --- Iteration 3 -- -NULL --- Iteration 4 -- -NULL - -*** Testing var_dump() on multiple arguments *** -array(15) { - [0]=> - int(0) - [1]=> - int(83) - [2]=> - int(123000000) - [3]=> - int(-83) - [4]=> - int(-12300000) - [5]=> - array(10) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - [3]=> - int(4) - [4]=> - int(5) - [5]=> - int(6) - [6]=> - int(7) - [7]=> - int(8) - [8]=> - int(9) - [9]=> - int(10) - } - [6]=> - array(10) { - [0]=> - int(-1) - [1]=> - int(-2) - [2]=> - int(-3) - [3]=> - int(-4) - [4]=> - int(-5) - [5]=> - int(-6) - [6]=> - int(-7) - [7]=> - int(-8) - [8]=> - int(-9) - [9]=> - int(-10) - } - [7]=> - int(2147483647) - [8]=> - int(2147483648) - [9]=> - int(-2147483648) - [10]=> - int(-2147483647) - [11]=> - int(2147483647) - [12]=> - int(-2147483648) - [13]=> - int(2147483647) - [14]=> - int(-2147483648) -} -array(32) { - [0]=> - float(-0) - [1]=> - float(0) - [2]=> - float(1.234) - [3]=> - float(-1.234) - [4]=> - float(-2) - [5]=> - float(2) - [6]=> - float(-0.5) - [7]=> - float(0.567) - [8]=> - float(-0.00067) - [9]=> - float(-670) - [10]=> - float(670) - [11]=> - float(670) - [12]=> - float(-0.00410003) - [13]=> - float(-4100.03) - [14]=> - float(0.004100003) - [15]=> - float(4100.003) - [16]=> - float(100000) - [17]=> - float(-100000) - [18]=> - float(1.0E-5) - [19]=> - float(-1.0E-5) - [20]=> - float(100000) - [21]=> - float(-100000) - [22]=> - float(100000) - [23]=> - float(-100000) - [24]=> - float(100000) - [25]=> - float(-100000) - [26]=> - float(1.0E-5) - [27]=> - float(-1.0E-5) - [28]=> - int(-2147483649) - [29]=> - int(2147483649) - [30]=> - int(2147483649) - [31]=> - int(-2147483649) -} -array(14) { - [0]=> - string(0) "" - [1]=> - string(0) "" - [2]=> - string(1) " " - [3]=> - string(1) " " - [4]=> - string(1) "0" - [5]=> - string(1) "%0" - [6]=> - string(2) "\0" - [7]=> - string(1) " " - [8]=> - string(2) "\t" - [9]=> - string(3) "PHP" - [10]=> - string(3) "PHP" - [11]=> - string(29) "abcd%0n1234%005678%000efgh\xijkl" - [12]=> - string(34) "abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz" - [13]=> - string(22) "1234 -5678 - 9100"abcda" -} -array(15) { - [0]=> - array(0) { - } - [1]=> - array(1) { - [0]=> - NULL - } - [2]=> - array(1) { - [0]=> - NULL - } - [3]=> - array(1) { - [0]=> - bool(true) - } - [4]=> - array(1) { - [0]=> - string(0) "" - } - [5]=> - array(1) { - [0]=> - string(0) "" - } - [6]=> - array(2) { - [0]=> - array(0) { - } - [1]=> - array(0) { - } - } - [7]=> - array(2) { - [0]=> - array(2) { - [0]=> - int(1) - [1]=> - int(2) - } - [1]=> - array(2) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - } - } - [8]=> - array(1) { - [1]=> - string(3) "One" - } - [9]=> - array(1) { - ["test"]=> - string(8) "is_array" - } - [10]=> - array(1) { - [0]=> - int(0) - } - [11]=> - array(1) { - [0]=> - int(-1) - } - [12]=> - array(2) { - [0]=> - float(10.5) - [1]=> - float(5.6) - } - [13]=> - array(2) { - [0]=> - string(6) "string" - [1]=> - string(4) "test" - } - [14]=> - array(2) { - [0]=> - string(6) "string" - [1]=> - string(4) "test" - } -} -array(4) { - [0]=> - bool(true) - [1]=> - bool(false) - [2]=> - bool(true) - [3]=> - bool(false) -} -array(2) { - [0]=> - resource(5) of type (stream) - [1]=> - resource(6) of type (stream) -} -array(9) { - [0]=> - object(object_class)#6 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - [1]=> - object(no_member_class)#7 (0) { - } - [2]=> - object(contains_object_class)#8 (7) { - ["p"]=> - int(30) - ["class_object1"]=> - object(object_class)#9 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object2"]=> - object(object_class)#10 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object3":"contains_object_class":private]=> - object(object_class)#9 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object4":protected]=> - object(object_class)#10 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["no_member_class_object"]=> - object(no_member_class)#11 (0) { - } - ["class_object5"]=> - *RECURSION* - } - [3]=> - object(contains_object_class)#1 (7) { - ["p"]=> - int(30) - ["class_object1"]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object2"]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object3":"contains_object_class":private]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["class_object4":protected]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - ["no_member_class_object"]=> - object(no_member_class)#4 (0) { - } - ["class_object5"]=> - *RECURSION* - } - [4]=> - object(object_class)#2 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - [5]=> - object(object_class)#3 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - [6]=> - object(no_member_class)#4 (0) { - } - [7]=> - object(object_class)#5 (7) { - ["value"]=> - int(50) - ["public_var1"]=> - int(10) - ["private_var1":"object_class":private]=> - int(20) - ["private_var2":"object_class":private]=> - int(21) - ["protected_var1":protected]=> - string(8) "string_1" - ["protected_var2":protected]=> - string(8) "string_2" - ["public_var2"]=> - int(11) - } - [8]=> - NULL -} -array(4) { - [0]=> - NULL - [1]=> - NULL - [2]=> - NULL - [3]=> - NULL -} -array(6) { - [0]=> - array(3) { - [0]=> - int(123) - [1]=> - float(-1.2345) - [2]=> - string(1) "a" - } - [1]=> - array(4) { - [0]=> - string(1) "d" - [1]=> - array(3) { - [0]=> - int(1) - [1]=> - int(3) - [2]=> - int(5) - } - [2]=> - bool(true) - [3]=> - NULL - } - [2]=> - array(4) { - [0]=> - object(no_member_class)#14 (0) { - } - [1]=> - array(0) { - } - [2]=> - bool(false) - [3]=> - int(0) - } - [3]=> - array(6) { - [0]=> - float(-0) - [1]=> - string(11) "Where am I?" - [2]=> - array(3) { - [0]=> - int(7) - [1]=> - int(8) - [2]=> - int(9) - } - [3]=> - bool(true) - [4]=> - string(1) "A" - [5]=> - int(987654321) - } - [4]=> - array(4) { - [0]=> - NULL - [1]=> - float(20000000000) - [2]=> - float(79.1) - [3]=> - float(4.599998) - } - [5]=> - array(4) { - [0]=> - string(27) "array(1,2,3,4)1.0000002TRUE" - [1]=> - NULL - [2]=> - float(4611333) - [3]=> - string(5) "/00\7" - } -} -Done diff --git a/ext/standard/tests/general_functions/var_dump_array_circular.phpt b/ext/standard/tests/general_functions/var_dump_array_circular.phpt new file mode 100644 index 0000000000000..5bee8eb481358 --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_array_circular.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test var_dump() function with circular array +--FILE-- + +--EXPECT-- +array(1) { + [0]=> + &array(1) { + [0]=> + *RECURSION* + } +} diff --git a/ext/standard/tests/general_functions/var_dump_arrays.phpt b/ext/standard/tests/general_functions/var_dump_arrays.phpt new file mode 100644 index 0000000000000..7b75e75e07cca --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_arrays.phpt @@ -0,0 +1,99 @@ +--TEST-- +Test var_dump() function with arrays +--INI-- +precision=14 +--FILE-- + 'One'], + ["test" => "is_array"], + [0], + [-1], + [10.5, 5.6], + ['string', 'test'], +]; + +foreach ($values as $value) { + var_dump($value); +} + +?> +--EXPECT-- +array(0) { +} +array(1) { + [0]=> + NULL +} +array(1) { + [0]=> + bool(false) +} +array(1) { + [0]=> + bool(true) +} +array(1) { + [0]=> + string(0) "" +} +array(2) { + [0]=> + array(0) { + } + [1]=> + array(0) { + } +} +array(2) { + [0]=> + array(2) { + [0]=> + int(1) + [1]=> + int(2) + } + [1]=> + array(2) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + } +} +array(1) { + [1]=> + string(3) "One" +} +array(1) { + ["test"]=> + string(8) "is_array" +} +array(1) { + [0]=> + int(0) +} +array(1) { + [0]=> + int(-1) +} +array(2) { + [0]=> + float(10.5) + [1]=> + float(5.6) +} +array(2) { + [0]=> + string(6) "string" + [1]=> + string(4) "test" +} diff --git a/ext/standard/tests/general_functions/var_dump_bools.phpt b/ext/standard/tests/general_functions/var_dump_bools.phpt new file mode 100644 index 0000000000000..034a8d7a2af48 --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_bools.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test var_dump() function with booleans +--FILE-- + true, + 'false' => false, +]; + +foreach ($values as $key => $value) { + echo "$key:\n"; + var_dump($value); +} + +?> +DONE +--EXPECT-- +true: +bool(true) +false: +bool(false) +DONE diff --git a/ext/standard/tests/general_functions/var_dump_floats.phpt b/ext/standard/tests/general_functions/var_dump_floats.phpt new file mode 100644 index 0000000000000..9ded48b1d3b17 --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_floats.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test var_dump() function with floats +--INI-- +precision=14 +--FILE-- + +--EXPECT-- +-- Iteration 1 -- +float(-0) +-- Iteration 2 -- +float(0) +-- Iteration 3 -- +float(1.234) +-- Iteration 4 -- +float(-1.234) +-- Iteration 5 -- +float(-2) +-- Iteration 6 -- +float(2) +-- Iteration 7 -- +float(-0.5) +-- Iteration 8 -- +float(0.567) +-- Iteration 9 -- +float(-0.00067) +-- Iteration 10 -- +float(670) +-- Iteration 11 -- +float(-0.00410003) +-- Iteration 12 -- +float(0.004100003) +-- Iteration 13 -- +float(100000) +-- Iteration 14 -- +float(-100000) +-- Iteration 15 -- +float(1.0E-5) +-- Iteration 16 -- +float(-1.0E-5) +-- Iteration 17 -- +float(100000) +-- Iteration 18 -- +float(-100000) diff --git a/ext/standard/tests/general_functions/var_dump_ints.phpt b/ext/standard/tests/general_functions/var_dump_ints.phpt new file mode 100644 index 0000000000000..b9146c10b2aa0 --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_ints.phpt @@ -0,0 +1,92 @@ +--TEST-- +Test var_dump() function with integers +--INI-- +precision=14 +--FILE-- + +--EXPECT-- +-- Iteration 1 -- +int(0) +-- Iteration 2 -- +int(83) +-- Iteration 3 -- +int(123000000) +-- Iteration 4 -- +int(-83) +-- Iteration 5 -- +int(-12300000) +-- Iteration 6 -- +array(10) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) + [6]=> + int(7) + [7]=> + int(8) + [8]=> + int(9) + [9]=> + int(10) +} +-- Iteration 7 -- +array(10) { + [0]=> + int(-1) + [1]=> + int(-2) + [2]=> + int(-3) + [3]=> + int(-4) + [4]=> + int(-5) + [5]=> + int(-6) + [6]=> + int(-7) + [7]=> + int(-8) + [8]=> + int(-9) + [9]=> + int(-10) +} +-- Iteration 8 -- +int(2147483647) +-- Iteration 9 -- +int(-2147483647) diff --git a/ext/standard/tests/general_functions/var_dump_ints_32bit.phpt b/ext/standard/tests/general_functions/var_dump_ints_32bit.phpt new file mode 100644 index 0000000000000..7cc818cfb22eb --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_ints_32bit.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test var_dump() function with 32 bit integers +--INI-- +precision=14 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +-- Iteration 1 -- +float(2147483648) +-- Iteration 2 -- +float(-2147483648) diff --git a/ext/standard/tests/general_functions/var_dump_ints_64bit.phpt b/ext/standard/tests/general_functions/var_dump_ints_64bit.phpt new file mode 100644 index 0000000000000..cb01803c163bc --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_ints_64bit.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test var_dump() function with 64 bit integers +--INI-- +precision=14 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +-- Iteration 1 -- +int(2147483647) +-- Iteration 2 -- +int(-2147483648) +-- Iteration 3 -- +int(2147483647) +-- Iteration 4 -- +int(-2147483648) +-- Iteration 5 -- +int(2147483648) +-- Iteration 6 -- +int(-2147483648) diff --git a/ext/standard/tests/general_functions/var_dump_null.phpt b/ext/standard/tests/general_functions/var_dump_null.phpt new file mode 100644 index 0000000000000..e98b74eca930b --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_null.phpt @@ -0,0 +1,12 @@ +--TEST-- +Test var_dump() function with null +--FILE-- + +DONE +--EXPECT-- +NULL +DONE diff --git a/ext/standard/tests/general_functions/var_dump_object.phpt b/ext/standard/tests/general_functions/var_dump_object.phpt new file mode 100644 index 0000000000000..467272574de26 --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_object.phpt @@ -0,0 +1,181 @@ +--TEST-- +Test var_dump() function +--FILE-- +value = 50; + $this->public_var2 = 11; + $this->private_var2 = 21; + $this->protected_var2 = "string_2"; + } + + public function foo1() { + echo "foo1() is called\n"; + } + protected function foo2() { + echo "foo2() is called\n"; + } + private function foo3() { + echo "foo3() is called\n"; + } +} + +class no_member_class {} + +/* class with member as object of other class */ +#[AllowDynamicProperties] +class contains_object_class +{ + var $p = 30; + var $class_object1; + public $class_object2; + private $class_object3; + protected $class_object4; + var $no_member_class_object; + + public function func() { + echo "func() is called \n"; + } + + function __construct() { + $this->class_object1 = new object_class(); + $this->class_object2 = new object_class(); + $this->class_object3 = $this->class_object1; + $this->class_object4 = $this->class_object2; + $this->no_member_class_object = new no_member_class(); + $this->class_object5 = $this; //recursive reference + } +} + +$objects = [ + new object_class, + new no_member_class, + new contains_object_class, +]; +check_var_dump($objects); + +?> +--EXPECT-- +*** Testing var_dump() on object variables *** + +-- Iteration 1 -- +object(object_class)#1 (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) +} + +-- Iteration 2 -- +object(no_member_class)#2 (0) { +} + +-- Iteration 3 -- +object(contains_object_class)#3 (7) { + ["p"]=> + int(30) + ["class_object1"]=> + object(object_class)#4 (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object2"]=> + object(object_class)#5 (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object3":"contains_object_class":private]=> + object(object_class)#4 (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["class_object4":protected]=> + object(object_class)#5 (7) { + ["value"]=> + int(50) + ["public_var1"]=> + int(10) + ["private_var1":"object_class":private]=> + int(20) + ["private_var2":"object_class":private]=> + int(21) + ["protected_var1":protected]=> + string(8) "string_1" + ["protected_var2":protected]=> + string(8) "string_2" + ["public_var2"]=> + int(11) + } + ["no_member_class_object"]=> + object(no_member_class)#6 (0) { + } + ["class_object5"]=> + *RECURSION* +} diff --git a/ext/standard/tests/general_functions/var_dump_object_circular.phpt b/ext/standard/tests/general_functions/var_dump_object_circular.phpt new file mode 100644 index 0000000000000..5670346a4bb99 --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_object_circular.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test var_dump() function function with circular objects +--FILE-- +obj = $recursion_obj2; +$recursion_obj2->obj = $recursion_obj1; +var_dump($recursion_obj2); + +?> +--EXPECT-- +object(Circular)#2 (1) { + ["obj"]=> + object(Circular)#1 (1) { + ["obj"]=> + *RECURSION* + } +} diff --git a/ext/standard/tests/general_functions/var_dump_resources.phpt b/ext/standard/tests/general_functions/var_dump_resources.phpt new file mode 100644 index 0000000000000..facdc83d42c8d --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_resources.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test var_dump() function with resources +--FILE-- + +--EXPECT-- +resource(1) of type (stream) +resource(3) of type (stream) diff --git a/ext/standard/tests/general_functions/var_dump_strings.phpt b/ext/standard/tests/general_functions/var_dump_strings.phpt new file mode 100644 index 0000000000000..88436318badac --- /dev/null +++ b/ext/standard/tests/general_functions/var_dump_strings.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test var_dump() function with strings +--WHITESPACE_SENSITIVE-- +--FILE-- + +--EXPECT-- +-- Iteration 1 -- +string(0) "" +-- Iteration 2 -- +string(1) " " +-- Iteration 3 -- +string(1) "0" +-- Iteration 4 -- +string(2) "\0" +-- Iteration 5 -- +string(1) " " +-- Iteration 6 -- +string(2) "\t" +-- Iteration 7 -- +string(3) "PHP" +-- Iteration 8 -- +string(22) "1234 +5678 + 9100"abcda" diff --git a/ext/standard/tests/general_functions/var_dump_strings_nul_bytes.phpt b/ext/standard/tests/general_functions/var_dump_strings_nul_bytes.phpt new file mode 100644 index 0000000000000000000000000000000000000000..20f06e11cd1f8e29fadba93f346fc03e76940ef3 GIT binary patch literal 663 zcmZuu-)q7!5YBV{ilg{o(O|0X7tZ-GIuK+G=3uZ6i80#Fns#kE>xTdPl6I}SEiZSu zyYJ(^?+BT?k5fYMRHO<%STb8=o49GiGLu{dk%Voad`MLi$W;nFl8OaV=OD8X<~t=) zOvv4M;%biTQS8SU*HG>YzMj>j4V?vS9*We4FAVxMc$7&c5*UIrC@RY+5sdpyI1B?z z4?n1&1}?ZCfkg<6H3uuUtr-dNq*Zd7(Z5UBhh_z8waVHa?=fyvnuqYBSF=27wM}Gm zzVLD?oo=tMBc*5O7nems#d76)dGNLltu}NzwQGfizR1}^@L7YP-kNitnC5`4l%q|@ x1`AoI{q9k}d!+}A2dHoW74i{1)_w}^9f5oO3T&)GMlv#b5jA3wk&28?{0-9k$f^JU literal 0 HcmV?d00001 From ac5e72e2803a192ac4a62c0a078616a856956fb2 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Tue, 4 Mar 2025 02:44:27 +0000 Subject: [PATCH 5/6] Add missing clean sections --- ext/standard/tests/file/file_get_contents_basic.phpt | 1 + ext/standard/tests/general_functions/proc_open-mb0.phpt | 4 ++++ ext/standard/tests/general_functions/proc_open-mb1.phpt | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/ext/standard/tests/file/file_get_contents_basic.phpt b/ext/standard/tests/file/file_get_contents_basic.phpt index 96f74c7611917..cf5e4ba6165d8 100644 --- a/ext/standard/tests/file/file_get_contents_basic.phpt +++ b/ext/standard/tests/file/file_get_contents_basic.phpt @@ -29,6 +29,7 @@ echo "\n*** Done ***"; $file_path = __DIR__; include($file_path."/file.inc"); delete_files($file_path, 1); +@unlink($file_path."/file_get_contents_basic1.tmp"); ?> --EXPECT-- *** Testing the basic functionality of the file_get_contents() function *** diff --git a/ext/standard/tests/general_functions/proc_open-mb0.phpt b/ext/standard/tests/general_functions/proc_open-mb0.phpt index 545f087574edb..90ad5533f8240 100644 --- a/ext/standard/tests/general_functions/proc_open-mb0.phpt +++ b/ext/standard/tests/general_functions/proc_open-mb0.phpt @@ -38,6 +38,10 @@ proc_close($p); echo $out; +?> +--CLEAN-- + --EXPECTF-- array(4) { diff --git a/ext/standard/tests/general_functions/proc_open-mb1.phpt b/ext/standard/tests/general_functions/proc_open-mb1.phpt index 057979e604c76..bb220a024804b 100644 --- a/ext/standard/tests/general_functions/proc_open-mb1.phpt +++ b/ext/standard/tests/general_functions/proc_open-mb1.phpt @@ -35,6 +35,10 @@ proc_close($p); echo $out; +?> +--CLEAN-- + --EXPECTF-- array(4) { From 00ebd2d7f25c521a10feae6c8217f6be0825f84d Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 13 Mar 2025 13:01:53 +0100 Subject: [PATCH 6/6] Fix flaky connection count in mysqli test Use connection ID instead of count to check whether we're using a persistent connection. This allows the test to be run in parallel with the other tests, but also protects against the possibility that some other service connects to the mysql server. Closes GH-18040 --- ext/mysqli/tests/bug73462.phpt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ext/mysqli/tests/bug73462.phpt b/ext/mysqli/tests/bug73462.phpt index c4d68ca4f5935..318b8dd24b34d 100644 --- a/ext/mysqli/tests/bug73462.phpt +++ b/ext/mysqli/tests/bug73462.phpt @@ -5,13 +5,6 @@ mysqli --SKIPIF-- --FILE-- query("SHOW STATUS LIKE 'Connections'"); + $result = $mysql_1->query("SELECT CONNECTION_ID()"); $c1 = $result->fetch_row(); $result->free(); $mysql_1->close(); @@ -35,7 +28,7 @@ if (gethostname() == "php-ci-ppc64be") { /* Re-use persistent connection */ $mysql_3 = new mysqli('p:'.$host, $user, $passwd, $db, $port); $error = mysqli_connect_errno(); - $result = $mysql_3->query("SHOW STATUS LIKE 'Connections'"); + $result = $mysql_3->query("SELECT CONNECTION_ID()"); $c3 = $result->fetch_row(); $result->free(); $mysql_3->close();