php: version 0.3.3

This commit is contained in:
advect 2010-12-27 11:09:14 +09:00
parent 4b36340474
commit 0acf6ec150
76 changed files with 6549 additions and 372 deletions

View File

@ -1,5 +1,14 @@
msgpack extension changelog
Version 0.3.3
-------------
* Update msgpack header files.
* Fix unpack internal processing.
Version 0.3.2
-------------
* Version PHP 5 or newer.
Version 0.3.1
-------------
* Fix class MessagePackUnpacker.

View File

@ -1,6 +1,4 @@
<?php
require_once 'Benchmark/Timer.php';
$loop = 10000;
$retry = 10;
$value_display = false;
@ -87,24 +85,23 @@ foreach ($types as $type)
//default (serialize)
$pack = null;
$unpack = null;
$t = new Benchmark_Timer;
$t->start();
$start = microtime(true);
for ($i = 0; $i < $loop; $i++)
{
$pack = serialize($value);
}
$t->setMarker('serialize');
$end = microtime(true);
$serialize_pack += ($end - $start);
$start = microtime(true);
for ($i = 0; $i < $loop; $i++)
{
$unpack = unserialize($pack);
}
$t->stop();
//$t->display();
$profiling = $t->getProfiling();
unset($t);
$end = microtime(true);
$serialize_unpack += ($end - $start);
$serialize_pack += $profiling[1]['diff'];
$serialize_unpack += $profiling[2]['diff'];
$serialize_size += strlen($pack);
if ($unpack === $value ||
(is_object($value) && $unpack == $value))
@ -120,24 +117,22 @@ foreach ($types as $type)
{
$opt = true;
}
$t = new Benchmark_Timer;
$t->start();
$start = microtime(true);
for ($i = 0; $i < $loop; $i++)
{
$pack = json_encode($value);
}
$t->setMarker('json_encode');
$end = microtime(true);
$json_pack += ($end - $start);
$start = microtime(true);
for ($i = 0; $i < $loop; $i++)
{
$unpack = json_decode($pack, $opt);
}
$t->stop();
//$t->display();
$profiling = $t->getProfiling();
unset($t);
$end = microtime(true);
$json_unpack += ($end - $start);
$json_pack += $profiling[1]['diff'];
$json_unpack += $profiling[2]['diff'];
$json_size += strlen($pack);
if ($unpack === $value ||
(is_object($value) && $unpack == $value) ||
@ -153,24 +148,22 @@ foreach ($types as $type)
{
$pack = null;
$unpack = null;
$t = new Benchmark_Timer;
$t->start();
$start = microtime(true);
for ($i = 0; $i < $loop; $i++)
{
$pack = igbinary_serialize($value);
}
$t->setMarker('igbinary_serialize');
$end = microtime(true);
$igbinary_pack += ($end - $start);
$start = microtime(true);
for ($i = 0; $i < $loop; $i++)
{
$unpack = igbinary_unserialize($pack);
}
$t->stop();
//$t->display();
$profiling = $t->getProfiling();
unset($t);
$end = microtime(true);
$igbinary_unpack += ($end - $start);
$igbinary_pack += $profiling[1]['diff'];
$igbinary_unpack += $profiling[2]['diff'];
$igbinary_size += strlen($pack);
if ($unpack === $value ||
(is_object($value) && $unpack == $value))
@ -182,24 +175,22 @@ foreach ($types as $type)
//msgpack
$pack = null;
$unpack = null;
$t = new Benchmark_Timer;
$t->start();
$start = microtime(true);
for ($i = 0; $i < $loop; $i++)
{
$pack = msgpack_serialize($value);
}
$t->setMarker('msgpack_serialize');
$end = microtime(true);
$msgpack_pack += ($end - $start);
$start = microtime(true);
for ($i = 0; $i < $loop; $i++)
{
$unpack = msgpack_unserialize($pack);
}
$t->stop();
//$t->display();
$profiling = $t->getProfiling();
unset($t);
$end = microtime(true);
$msgpack_unpack += ($end - $start);
$msgpack_pack += $profiling[1]['diff'];
$msgpack_unpack += $profiling[2]['diff'];
$msgpack_size += strlen($pack);
if ($unpack === $value ||
(is_object($value) && $unpack == $value))

View File

@ -8,12 +8,12 @@ dnl Check PHP version:
AC_MSG_CHECKING(PHP version)
AC_TRY_COMPILE([#include "php/main/php_version.h"], [
#if PHP_MAJOR_VERSION < 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2)
#error this extension requires at least PHP version 5.2.0
#if PHP_MAJOR_VERSION < 5
#error this extension requires at least PHP version 5 or newer
#endif
],
[AC_MSG_RESULT(ok)],
[AC_MSG_ERROR([need at least PHP 5.2.0])])
[AC_MSG_ERROR([need at least PHP 5 or newer])])
dnl If your extension references something external, use with:
@ -24,5 +24,10 @@ Make sure that the comment is aligned:
if test "$PHP_MSGPACK" != "no"; then
PHP_NEW_EXTENSION(msgpack, msgpack.c msgpack_pack.c msgpack_unpack.c msgpack_class.c, $ext_shared)
PHP_INSTALL_HEADERS([ext/msgpack], [php_msgpack.h])
ifdef([PHP_INSTALL_HEADERS],
[
PHP_INSTALL_HEADERS([ext/msgpack], [php_msgpack.h])
], [
PHP_ADD_MAKEFILE_FRAGMENT
])
fi

View File

@ -77,6 +77,12 @@ static ZEND_MINIT_FUNCTION(msgpack)
msgpack_init_class();
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 1)
REGISTER_LONG_CONSTANT(
"MESSAGEPACK_OPT_PHPONLY", MSGPACK_CLASS_OPT_PHPONLY,
CONST_CS | CONST_PERSISTENT);
#endif
return SUCCESS;
}
@ -164,33 +170,41 @@ PS_SERIALIZER_DECODE_FUNC(msgpack)
msgpack_unserialize_var_init(&var_hash);
(&mp)->user.retval = (zval *)tmp;
(&mp)->user.var_hash = (php_unserialize_data_t *)&var_hash;
mp.user.retval = (zval *)tmp;
mp.user.var_hash = (php_unserialize_data_t *)&var_hash;
ret = template_execute(&mp, (char *)val, (size_t)vallen, &off);
msgpack_unserialize_var_destroy(&var_hash);
tmp_hash = HASH_OF(tmp);
zend_hash_internal_pointer_reset_ex(tmp_hash, &tmp_hash_pos);
while (zend_hash_get_current_data_ex(
tmp_hash, (void *)&value, &tmp_hash_pos) == SUCCESS)
if (ret == MSGPACK_UNPACK_EXTRA_BYTES || ret == MSGPACK_UNPACK_SUCCESS)
{
ret = zend_hash_get_current_key_ex(
tmp_hash, &key_str, &key_len, &key_long, 0, &tmp_hash_pos);
switch (ret)
msgpack_unserialize_var_destroy(&var_hash, 0);
tmp_hash = HASH_OF(tmp);
zend_hash_internal_pointer_reset_ex(tmp_hash, &tmp_hash_pos);
while (zend_hash_get_current_data_ex(
tmp_hash, (void *)&value, &tmp_hash_pos) == SUCCESS)
{
case HASH_KEY_IS_LONG:
/* ??? */
break;
case HASH_KEY_IS_STRING:
php_set_session_var(
key_str, key_len - 1, *value, NULL TSRMLS_CC);
php_add_session_var(key_str, key_len - 1 TSRMLS_CC);
break;
ret = zend_hash_get_current_key_ex(
tmp_hash, &key_str, &key_len, &key_long, 0, &tmp_hash_pos);
switch (ret)
{
case HASH_KEY_IS_LONG:
/* ??? */
break;
case HASH_KEY_IS_STRING:
php_set_session_var(
key_str, key_len - 1, *value, NULL TSRMLS_CC);
php_add_session_var(key_str, key_len - 1 TSRMLS_CC);
break;
}
zend_hash_move_forward_ex(tmp_hash, &tmp_hash_pos);
}
zend_hash_move_forward_ex(tmp_hash, &tmp_hash_pos);
}
else
{
msgpack_unserialize_var_destroy(&var_hash, 1);
}
zval_ptr_dtor(&tmp);
@ -226,43 +240,49 @@ PHP_MSGPACK_API void php_msgpack_unserialize(
msgpack_unserialize_var_init(&var_hash);
(&mp)->user.retval = (zval *)return_value;
(&mp)->user.var_hash = (php_unserialize_data_t *)&var_hash;
mp.user.retval = (zval *)return_value;
mp.user.var_hash = (php_unserialize_data_t *)&var_hash;
ret = template_execute(&mp, str, (size_t)str_len, &off);
msgpack_unserialize_var_destroy(&var_hash);
switch (ret)
{
case MSGPACK_UNPACK_PARSE_ERROR:
{
msgpack_unserialize_var_destroy(&var_hash, 1);
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (php_msgpack_unserialize) Parse error");
"[msgpack] (%s) Parse error", __FUNCTION__);
}
break;
}
case MSGPACK_UNPACK_CONTINUE:
{
msgpack_unserialize_var_destroy(&var_hash, 1);
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (php_msgpack_unserialize) "
"Insufficient data for unserializing");
"[msgpack] (%s) Insufficient data for unserializing",
__FUNCTION__);
}
break;
}
case MSGPACK_UNPACK_EXTRA_BYTES:
case MSGPACK_UNPACK_SUCCESS:
msgpack_unserialize_var_destroy(&var_hash, 0);
if (off < (size_t)str_len && MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (php_msgpack_unserialize) Extra bytes");
"[msgpack] (%s) Extra bytes", __FUNCTION__);
}
break;
default:
msgpack_unserialize_var_destroy(&var_hash, 0);
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (php_msgpack_unserialize) Unknown result");
"[msgpack] (%s) Unknown result", __FUNCTION__);
}
break;
}

View File

@ -69,7 +69,7 @@ do { \
} else { \
/* unsigned 16 */ \
unsigned char buf[3]; \
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
msgpack_pack_append_buffer(x, buf, 3); \
} \
} while(0)
@ -89,12 +89,12 @@ do { \
if(d < (1<<16)) { \
/* unsigned 16 */ \
unsigned char buf[3]; \
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
msgpack_pack_append_buffer(x, buf, 3); \
} else { \
/* unsigned 32 */ \
unsigned char buf[5]; \
buf[0] = 0xce; _msgpack_store32(&buf[1], d); \
buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
msgpack_pack_append_buffer(x, buf, 5); \
} \
} \
@ -103,7 +103,7 @@ do { \
#define msgpack_pack_real_uint64(x, d) \
do { \
if(d < (1ULL<<8)) { \
if(d < (1<<7)) { \
if(d < (1ULL<<7)) { \
/* fixnum */ \
msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \
} else { \
@ -115,12 +115,12 @@ do { \
if(d < (1ULL<<16)) { \
/* unsigned 16 */ \
unsigned char buf[3]; \
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
msgpack_pack_append_buffer(x, buf, 3); \
} else if(d < (1ULL<<32)) { \
/* unsigned 32 */ \
unsigned char buf[5]; \
buf[0] = 0xce; _msgpack_store32(&buf[1], d); \
buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
msgpack_pack_append_buffer(x, buf, 5); \
} else { \
/* unsigned 64 */ \
@ -149,7 +149,7 @@ do { \
if(d < -(1<<7)) { \
/* signed 16 */ \
unsigned char buf[3]; \
buf[0] = 0xd1; _msgpack_store16(&buf[1], d); \
buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
msgpack_pack_append_buffer(x, buf, 3); \
} else { \
/* signed 8 */ \
@ -167,7 +167,7 @@ do { \
} else { \
/* unsigned 16 */ \
unsigned char buf[3]; \
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
msgpack_pack_append_buffer(x, buf, 3); \
} \
} \
@ -179,12 +179,12 @@ do { \
if(d < -(1<<15)) { \
/* signed 32 */ \
unsigned char buf[5]; \
buf[0] = 0xd2; _msgpack_store32(&buf[1], d); \
buf[0] = 0xd2; _msgpack_store32(&buf[1], (int32_t)d); \
msgpack_pack_append_buffer(x, buf, 5); \
} else if(d < -(1<<7)) { \
/* signed 16 */ \
unsigned char buf[3]; \
buf[0] = 0xd1; _msgpack_store16(&buf[1], d); \
buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
msgpack_pack_append_buffer(x, buf, 3); \
} else { \
/* signed 8 */ \
@ -202,12 +202,12 @@ do { \
} else if(d < (1<<16)) { \
/* unsigned 16 */ \
unsigned char buf[3]; \
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
msgpack_pack_append_buffer(x, buf, 3); \
} else { \
/* unsigned 32 */ \
unsigned char buf[5]; \
buf[0] = 0xce; _msgpack_store32(&buf[1], d); \
buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
msgpack_pack_append_buffer(x, buf, 5); \
} \
} \
@ -225,14 +225,14 @@ do { \
} else { \
/* signed 32 */ \
unsigned char buf[5]; \
buf[0] = 0xd2; _msgpack_store32(&buf[1], d); \
buf[0] = 0xd2; _msgpack_store32(&buf[1], (int32_t)d); \
msgpack_pack_append_buffer(x, buf, 5); \
} \
} else { \
if(d < -(1<<7)) { \
/* signed 16 */ \
unsigned char buf[3]; \
buf[0] = 0xd1; _msgpack_store16(&buf[1], d); \
buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
msgpack_pack_append_buffer(x, buf, 3); \
} else { \
/* signed 8 */ \
@ -252,14 +252,14 @@ do { \
} else { \
/* unsigned 16 */ \
unsigned char buf[3]; \
buf[0] = 0xcd; _msgpack_store16(&buf[1], d); \
buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
msgpack_pack_append_buffer(x, buf, 3); \
} \
} else { \
if(d < (1LL<<32)) { \
/* unsigned 32 */ \
unsigned char buf[5]; \
buf[0] = 0xce; _msgpack_store32(&buf[1], d); \
buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
msgpack_pack_append_buffer(x, buf, 5); \
} else { \
/* unsigned 64 */ \
@ -690,11 +690,11 @@ msgpack_pack_inline_func(_array)(msgpack_pack_user x, unsigned int n)
msgpack_pack_append_buffer(x, &d, 1);
} else if(n < 65536) {
unsigned char buf[3];
buf[0] = 0xdc; _msgpack_store16(&buf[1], n);
buf[0] = 0xdc; _msgpack_store16(&buf[1], (uint16_t)n);
msgpack_pack_append_buffer(x, buf, 3);
} else {
unsigned char buf[5];
buf[0] = 0xdd; _msgpack_store32(&buf[1], n);
buf[0] = 0xdd; _msgpack_store32(&buf[1], (uint32_t)n);
msgpack_pack_append_buffer(x, buf, 5);
}
}
@ -711,11 +711,11 @@ msgpack_pack_inline_func(_map)(msgpack_pack_user x, unsigned int n)
msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
} else if(n < 65536) {
unsigned char buf[3];
buf[0] = 0xde; _msgpack_store16(&buf[1], n);
buf[0] = 0xde; _msgpack_store16(&buf[1], (uint16_t)n);
msgpack_pack_append_buffer(x, buf, 3);
} else {
unsigned char buf[5];
buf[0] = 0xdf; _msgpack_store32(&buf[1], n);
buf[0] = 0xdf; _msgpack_store32(&buf[1], (uint32_t)n);
msgpack_pack_append_buffer(x, buf, 5);
}
}
@ -732,11 +732,11 @@ msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l)
msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
} else if(l < 65536) {
unsigned char buf[3];
buf[0] = 0xda; _msgpack_store16(&buf[1], l);
buf[0] = 0xda; _msgpack_store16(&buf[1], (uint16_t)l);
msgpack_pack_append_buffer(x, buf, 3);
} else {
unsigned char buf[5];
buf[0] = 0xdb; _msgpack_store32(&buf[1], l);
buf[0] = 0xdb; _msgpack_store32(&buf[1], (uint32_t)l);
msgpack_pack_append_buffer(x, buf, 5);
}
}

View File

@ -18,8 +18,9 @@
#ifndef MSGPACK_SYSDEP_H__
#define MSGPACK_SYSDEP_H__
#ifdef _MSC_VER
#include <stdlib.h>
#include <stddef.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
typedef __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
@ -28,8 +29,9 @@ typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#elif defined(_MSC_VER) // && _MSC_VER >= 1600
#include <stdint.h>
#else
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#endif
@ -76,7 +78,7 @@ typedef unsigned int _msgpack_atomic_counter_t;
#define _msgpack_be16(x) ntohs(x)
#define _msgpack_be32(x) ntohl(x)
#if defined(_byteswap_uint64)
#if defined(_byteswap_uint64) || _MSC_VER >= 1400
# define _msgpack_be64(x) (_byteswap_uint64(x))
#elif defined(bswap_64)
# define _msgpack_be64(x) bswap_64(x)

View File

@ -20,6 +20,7 @@ typedef struct {
php_unserialize_data_t var_hash;
long php_only;
zend_bool finished;
int error;
} php_msgpack_unpacker_t;
#if ZEND_MODULE_API_NO >= 20060613
@ -40,16 +41,25 @@ typedef struct {
# define POP_EO_PARAM() (void)zend_ptr_stack_pop(&EG(argument_stack))
#endif
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0)
#define MSGPACK_METHOD_HELPER(classname, name, retval, thisptr, num, param) \
PUSH_PARAM(param); PUSH_PARAM((void*)num); \
PUSH_EO_PARAM(); \
MSGPACK_METHOD_BASE(classname, name)(num, retval, NULL, thisptr, 0 TSRMLS_CC); \
POP_EO_PARAM(); \
POP_PARAM(); \
POP_PARAM();
POP_PARAM(); POP_PARAM();
#define MSGPACK_METHOD(classname, name, retval, thisptr) \
MSGPACK_METHOD_BASE(classname, name)(0, retval, NULL, thisptr, 0 TSRMLS_CC)
#else
#define MSGPACK_METHOD_HELPER(classname, name, retval, thisptr, num, param) \
PUSH_PARAM(param); PUSH_PARAM((void*)num); \
PUSH_EO_PARAM(); \
MSGPACK_METHOD_BASE(classname, name)(num, retval, thisptr, 0 TSRMLS_CC); \
POP_EO_PARAM(); \
POP_PARAM(); POP_PARAM();
#define MSGPACK_METHOD(classname, name, retval, thisptr) \
MSGPACK_METHOD_BASE(classname, name)(0, retval, thisptr, 0 TSRMLS_CC)
#endif
#define MSGPACK_METHOD1(classname, name, retval, thisptr, param1) \
MSGPACK_METHOD_HELPER(classname, name, retval, thisptr, 1, param1);
@ -62,8 +72,6 @@ typedef struct {
php_msgpack_unpacker_t *unpacker; \
unpacker = (php_msgpack_unpacker_t *)zend_object_store_get_object(getThis() TSRMLS_CC);
#define MSGPACK_CLASS_OPT_PHPONLY -1001
/* MessagePack */
static zend_class_entry *msgpack_ce = NULL;
@ -161,7 +169,15 @@ static const zend_function_entry msgpack_unpacker_methods[] = {
static void php_msgpack_base_free(php_msgpack_base_t *base TSRMLS_DC)
{
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0)
zend_object_std_dtor(&base->object TSRMLS_CC);
#else
if (base->object.properties)
{
zend_hash_destroy(base->object.properties);
FREE_HASHTABLE(base->object.properties);
}
#endif
efree(base);
}
@ -173,7 +189,13 @@ static zend_object_value php_msgpack_base_new(zend_class_entry *ce TSRMLS_DC)
base = emalloc(sizeof(php_msgpack_base_t));
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0)
zend_object_std_init(&base->object, ce TSRMLS_CC);
#else
ALLOC_HASHTABLE(base->object.properties);
zend_hash_init(base->object.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
base->object.ce = ce;
#endif
zend_hash_copy(
base->object.properties, &ce->default_properties,
@ -191,7 +213,15 @@ static zend_object_value php_msgpack_base_new(zend_class_entry *ce TSRMLS_DC)
static void php_msgpack_unpacker_free(
php_msgpack_unpacker_t *unpacker TSRMLS_DC)
{
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0)
zend_object_std_dtor(&unpacker->object TSRMLS_CC);
#else
if (unpacker->object.properties)
{
zend_hash_destroy(unpacker->object.properties);
FREE_HASHTABLE(unpacker->object.properties);
}
#endif
efree(unpacker);
}
@ -204,7 +234,13 @@ static zend_object_value php_msgpack_unpacker_new(
unpacker = emalloc(sizeof(php_msgpack_unpacker_t));
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0)
zend_object_std_init(&unpacker->object, ce TSRMLS_CC);
#else
ALLOC_HASHTABLE(unpacker->object.properties);
zend_hash_init(unpacker->object.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
unpacker->object.ce = ce;
#endif
zend_hash_copy(
unpacker->object.properties, &ce->default_properties,
@ -350,6 +386,7 @@ static ZEND_METHOD(msgpack_unpacker, __construct)
unpacker->retval = NULL;
unpacker->offset = 0;
unpacker->finished = 0;
unpacker->error = 0;
template_init(&unpacker->mp);
@ -370,7 +407,7 @@ static ZEND_METHOD(msgpack_unpacker, __destruct)
zval_ptr_dtor(&unpacker->retval);
}
msgpack_unserialize_var_destroy(&unpacker->var_hash);
msgpack_unserialize_var_destroy(&unpacker->var_hash, unpacker->error);
}
static ZEND_METHOD(msgpack_unpacker, setOption)
@ -447,6 +484,17 @@ static ZEND_METHOD(msgpack_unpacker, execute)
if (str != NULL)
{
if (ZEND_NUM_ARGS() < 2)
{
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (MessagePackUnpacker::execute) "
"expects exactly 2 parameters");
}
RETURN_FALSE;
}
data = (char *)str;
len = (size_t)str_len;
off = Z_LVAL_P(offset);
@ -466,8 +514,8 @@ static ZEND_METHOD(msgpack_unpacker, execute)
{
zval_ptr_dtor(&unpacker->retval);
msgpack_unserialize_var_destroy(&unpacker->var_hash);
msgpack_unserialize_var_destroy(&unpacker->var_hash, unpacker->error);
unpacker->error = 0;
ALLOC_INIT_ZVAL(unpacker->retval);
@ -502,8 +550,10 @@ static ZEND_METHOD(msgpack_unpacker, execute)
case MSGPACK_UNPACK_EXTRA_BYTES:
case MSGPACK_UNPACK_SUCCESS:
unpacker->finished = 1;
unpacker->error = 0;
RETURN_TRUE;
default:
unpacker->error = 1;
RETURN_FALSE;
}
}
@ -556,7 +606,8 @@ static ZEND_METHOD(msgpack_unpacker, reset)
unpacker->retval = NULL;
}
msgpack_unserialize_var_destroy(&unpacker->var_hash);
msgpack_unserialize_var_destroy(&unpacker->var_hash, unpacker->error);
unpacker->error = 0;
template_init(&unpacker->mp);
@ -577,9 +628,11 @@ void msgpack_init_class()
msgpack_ce = zend_register_internal_class(&ce TSRMLS_CC);
msgpack_ce->create_object = php_msgpack_base_new;
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0)
zend_declare_class_constant_long(
msgpack_ce, ZEND_STRS("OPT_PHPONLY") - 1,
MSGPACK_CLASS_OPT_PHPONLY TSRMLS_CC);
#endif
/* unpacker */
INIT_CLASS_ENTRY(ce, "MessagePackUnpacker", msgpack_unpacker_methods);

View File

@ -2,6 +2,8 @@
#ifndef MSGPACK_CLASS_H
#define MSGPACK_CLASS_H
#define MSGPACK_CLASS_OPT_PHPONLY -1001
void msgpack_init_class();
#endif

View File

@ -38,11 +38,15 @@ inline static int msgpack_var_add(
+ (long)Z_OBJ_HANDLE_P(var));
len = id + sizeof(id) - 1 - p;
}
else
else if (Z_TYPE_P(var) == IS_ARRAY)
{
p = smart_str_print_long(id + sizeof(id) - 1, (long)var);
len = id + sizeof(id) - 1 - p;
}
else
{
return FAILURE;
}
if (var_old && zend_hash_find(var_hash, p, len, var_old) == SUCCESS)
{
@ -122,10 +126,11 @@ inline static void msgpack_serialize_class(
if (MSGPACK_G(error_display))
{
zend_error(E_NOTICE,
"[msgpack] (msgpack_serialize_class) "
"[msgpack] (%s) "
"__sleep should return an array only "
"containing the names of "
"instance-variables to serialize.");
"instance-variables to serialize.",
__FUNCTION__);
}
continue;
}
@ -199,10 +204,10 @@ inline static void msgpack_serialize_class(
if (MSGPACK_G(error_display))
{
zend_error(E_NOTICE,
"[msgpack] (msgpack_serialize_class) "
"[msgpack] (%s) "
"\"%s\" returned as member variable from "
"__sleep() but does not exist",
Z_STRVAL_PP(name));
__FUNCTION__, Z_STRVAL_PP(name));
}
msgpack_serialize_string(
@ -339,8 +344,9 @@ inline static void msgpack_serialize_array(
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (msgpack_serialize_array) "
"key is not string nor array");
"[msgpack] (%s) "
"key is not string nor array",
__FUNCTION__);
}
break;
}
@ -361,6 +367,8 @@ inline static void msgpack_serialize_array(
Z_ARRVAL_PP(data)->nApplyCount++;
}
//php_var_dump(data, 1 TSRMLS_CC); //hoge
msgpack_serialize_zval(buf, *data, var_hash TSRMLS_CC);
if (Z_TYPE_PP(data) == IS_ARRAY)
@ -386,6 +394,7 @@ inline static void msgpack_serialize_object(
ce = Z_OBJCE_P(val);
}
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0)
if (ce && ce->serialize != NULL)
{
unsigned char *serialized_data = NULL;
@ -418,6 +427,7 @@ inline static void msgpack_serialize_object(
return;
}
#endif
if (ce && ce != PHP_IC_ENTRY &&
zend_hash_exists(&ce->function_table, "__sleep", sizeof("__sleep")))
@ -441,10 +451,11 @@ inline static void msgpack_serialize_object(
if (MSGPACK_G(error_display))
{
zend_error(E_NOTICE,
"[msgpack] (msgpack_serialize_object) "
"[msgpack] (%s) "
"__sleep should return an array only "
"containing the names of instance-variables "
"to serialize");
"to serialize",
__FUNCTION__);
}
msgpack_pack_nil(buf);
}
@ -548,8 +559,8 @@ void msgpack_serialize_zval(
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (php_msgpack_serialize) "
"type is unsupported, encoded as null");
"[msgpack] (%s) type is unsupported, encoded as null",
__FUNCTION__);
}
msgpack_pack_nil(buf);
break;

View File

@ -19,52 +19,42 @@ typedef struct
{
zval *data[VAR_ENTRIES_MAX];
long used_slots;
long value_slots;
long access_slots[VAR_ENTRIES_MAX];
bool alloc_slots[VAR_ENTRIES_MAX];
void *next;
} var_entries;
#define MSGPACK_UNSERIALIZE_ALLOC(_unpack) \
if (_unpack->deps <= 0) { \
*obj = _unpack->retval; \
msgpack_var_push(_unpack->var_hash, obj, true, false); \
} else { \
ALLOC_INIT_ZVAL(*obj); \
msgpack_var_push(_unpack->var_hash, obj, false, true); \
#define MSGPACK_UNSERIALIZE_ALLOC_STACK(_unpack) \
if (_unpack->deps <= 0) { \
*obj = _unpack->retval; \
msgpack_stack_push(_unpack->var_hash, obj, false); \
} else { \
ALLOC_INIT_ZVAL(*obj); \
msgpack_stack_push(_unpack->var_hash, obj, true); \
}
#define MSGPACK_UNSERIALIZE_ALLOC_VALUE(_unpack) \
if (_unpack->deps <= 0) { \
*obj = _unpack->retval; \
msgpack_var_push(_unpack->var_hash, obj, true, false); \
} else { \
ALLOC_INIT_ZVAL(*obj); \
msgpack_var_push(_unpack->var_hash, obj, true, true); \
#define MSGPACK_UNSERIALIZE_ALLOC_VALUE(_unpack) \
if (_unpack->deps <= 0) { \
*obj = _unpack->retval; \
msgpack_var_push(_unpack->var_hash, obj); \
} else { \
ALLOC_INIT_ZVAL(*obj); \
msgpack_var_push(_unpack->var_hash, obj); \
}
#define MSGPACK_UNSERIALIZE_PUSH_ITEM(_unpack, _count, _val) \
msgpack_var_alloc(_unpack->var_hash, _count); \
if (Z_TYPE_P(_val) != IS_ARRAY && Z_TYPE_P(_val) != IS_OBJECT) { \
msgpack_var_push(_unpack->var_hash, &_val, true, false); \
}
#define MSGPACK_UNSERIALIZE_FINISH_ITEM(_unpack) \
long deps = _unpack->deps - 1; \
_unpack->stack[deps]--; \
if (_unpack->stack[deps] == 0) { \
_unpack->deps--; \
#define MSGPACK_UNSERIALIZE_FINISH_ITEM(_unpack, _count) \
msgpack_stack_pop(_unpack->var_hash, _count); \
long deps = _unpack->deps - 1; \
_unpack->stack[deps]--; \
if (_unpack->stack[deps] == 0) { \
_unpack->deps--; \
}
#define MSGPACK_UNSERIALIZE_FINISH_MAP_ITEM(_unpack, _key, _val) \
zval_ptr_dtor(&_key); \
zval_ptr_dtor(&_val); \
msgpack_var_alloc(_unpack->var_hash, 2); \
MSGPACK_UNSERIALIZE_FINISH_ITEM(_unpack);
MSGPACK_UNSERIALIZE_FINISH_ITEM(_unpack, 2);
inline static void msgpack_var_push(
php_unserialize_data_t *var_hashx, zval **rval, bool value, bool alloc)
php_unserialize_data_t *var_hashx, zval **rval)
{
var_entries *var_hash, *prev = NULL;
@ -85,7 +75,6 @@ inline static void msgpack_var_push(
{
var_hash = emalloc(sizeof(var_entries));
var_hash->used_slots = 0;
var_hash->value_slots = 0;
var_hash->next = 0;
if (!var_hashx->first)
@ -98,45 +87,9 @@ inline static void msgpack_var_push(
}
}
var_hash->alloc_slots[var_hash->used_slots] = alloc;
if (value)
{
var_hash->access_slots[var_hash->value_slots++] = var_hash->used_slots;
}
var_hash->data[var_hash->used_slots++] = *rval;
}
inline static void msgpack_var_alloc(
php_unserialize_data_t *var_hashx, long count)
{
long i;
var_entries *var_hash = var_hashx->first;
while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX)
{
var_hash = var_hash->next;
}
if (!var_hash || count <= 0)
{
return;
}
for (i = var_hash->used_slots - 1; i >= 0; i--)
{
if (var_hash->alloc_slots[i])
{
var_hash->alloc_slots[i] = false;
if (--count <= 0)
{
break;
}
}
}
}
inline static int msgpack_var_access(
php_unserialize_data_t *var_hashx, long id, zval ***store)
{
@ -154,13 +107,6 @@ inline static int msgpack_var_access(
return !SUCCESS;
}
if (id < 0 || id >= var_hash->value_slots)
{
return !SUCCESS;
}
id = var_hash->access_slots[id];
if (id < 0 || id >= var_hash->used_slots)
{
return !SUCCESS;
@ -171,6 +117,82 @@ inline static int msgpack_var_access(
return SUCCESS;
}
inline static void msgpack_stack_push(
php_unserialize_data_t *var_hashx, zval **rval, bool save)
{
var_entries *var_hash, *prev = NULL;
if (!var_hashx)
{
return;
}
var_hash = var_hashx->first_dtor;
while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX)
{
prev = var_hash;
var_hash = var_hash->next;
}
if (!var_hash)
{
var_hash = emalloc(sizeof(var_entries));
var_hash->used_slots = 0;
var_hash->next = 0;
if (!var_hashx->first_dtor)
{
var_hashx->first_dtor = var_hash;
}
else
{
prev->next = var_hash;
}
}
if (save)
{
var_hash->data[var_hash->used_slots++] = *rval;
}
else
{
var_hash->data[var_hash->used_slots++] = NULL;
}
}
inline static void msgpack_stack_pop(
php_unserialize_data_t *var_hashx, long count)
{
long i;
var_entries *var_hash = var_hashx->first_dtor;
while (var_hash && var_hash->used_slots == VAR_ENTRIES_MAX)
{
var_hash = var_hash->next;
}
if (!var_hash || count <= 0)
{
return;
}
for (i = count; i > 0; i--)
{
var_hash->used_slots--;
if (var_hash->used_slots < 0)
{
var_hash->used_slots = 0;
var_hash->data[var_hash->used_slots] = NULL;
break;
}
else
{
var_hash->data[var_hash->used_slots] = NULL;
}
}
}
inline static zend_class_entry* msgpack_unserialize_class(
zval **container, char *class_name, size_t name_len)
{
@ -210,8 +232,8 @@ inline static zend_class_entry* msgpack_unserialize_class(
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (msgpack_unserialize_class) "
"defined (%s) but not found", class_name);
"[msgpack] (%s) defined (%s) but not found",
__FUNCTION__, class_name);
}
incomplete_class = 1;
@ -235,9 +257,9 @@ inline static zend_class_entry* msgpack_unserialize_class(
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (msgpack_unserialize_class) "
"[msgpack] (%s) "
"Function %s() hasn't defined the class "
"it was called for", class_name);
"it was called for", __FUNCTION__, class_name);
}
incomplete_class = true;
@ -254,8 +276,7 @@ inline static zend_class_entry* msgpack_unserialize_class(
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (msgpack_unserialize_class) "
"Exception error");
"[msgpack] (%s) Exception error", __FUNCTION__);
}
return NULL;
@ -278,7 +299,7 @@ void msgpack_unserialize_var_init(php_unserialize_data_t *var_hashx)
var_hashx->first_dtor = 0;
}
void msgpack_unserialize_var_destroy(php_unserialize_data_t *var_hashx)
void msgpack_unserialize_var_destroy(php_unserialize_data_t *var_hashx, bool err)
{
void *next;
long i;
@ -286,9 +307,29 @@ void msgpack_unserialize_var_destroy(php_unserialize_data_t *var_hashx)
while (var_hash)
{
for (i = 0; i < var_hash->used_slots; i++)
if (err)
{
if (var_hash->alloc_slots[i] && var_hash->data[i])
for (i = var_hash->used_slots - 1; i > 0; i--)
{
if (var_hash->data[i])
{
zval_ptr_dtor(&var_hash->data[i]);
}
}
}
next = var_hash->next;
efree(var_hash);
var_hash = next;
}
var_hash = var_hashx->first_dtor;
while (var_hash)
{
for (i = var_hash->used_slots - 1; i >= 0; i--)
{
if (var_hash->data[i])
{
zval_ptr_dtor(&var_hash->data[i]);
}
@ -298,21 +339,6 @@ void msgpack_unserialize_var_destroy(php_unserialize_data_t *var_hashx)
efree(var_hash);
var_hash = next;
}
/*
var_hash = var_hashx->first_dtor;
while (var_hash)
{
for (i = 0; i < var_hash->used_slots; i++)
{
zval_ptr_dtor(&var_hash->data[i]);
}
next = var_hash->next;
efree(var_hash);
var_hash = next;
}
*/
}
void msgpack_unserialize_init(msgpack_unserialize_data *unpack)
@ -324,7 +350,7 @@ void msgpack_unserialize_init(msgpack_unserialize_data *unpack)
int msgpack_unserialize_uint8(
msgpack_unserialize_data *unpack, uint8_t data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_LONG(*obj, data);
@ -334,7 +360,7 @@ int msgpack_unserialize_uint8(
int msgpack_unserialize_uint16(
msgpack_unserialize_data *unpack, uint16_t data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_LONG(*obj, data);
@ -344,7 +370,7 @@ int msgpack_unserialize_uint16(
int msgpack_unserialize_uint32(
msgpack_unserialize_data *unpack, uint32_t data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_LONG(*obj, data);
@ -354,7 +380,7 @@ int msgpack_unserialize_uint32(
int msgpack_unserialize_uint64(
msgpack_unserialize_data *unpack, uint64_t data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_LONG(*obj, data);
@ -364,7 +390,7 @@ int msgpack_unserialize_uint64(
int msgpack_unserialize_int8(
msgpack_unserialize_data *unpack, int8_t data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_LONG(*obj, data);
@ -374,7 +400,7 @@ int msgpack_unserialize_int8(
int msgpack_unserialize_int16(
msgpack_unserialize_data *unpack, int16_t data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_LONG(*obj, data);
@ -384,7 +410,7 @@ int msgpack_unserialize_int16(
int msgpack_unserialize_int32(
msgpack_unserialize_data *unpack, int32_t data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_LONG(*obj, data);
@ -394,7 +420,7 @@ int msgpack_unserialize_int32(
int msgpack_unserialize_int64(
msgpack_unserialize_data *unpack, int64_t data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_LONG(*obj, data);
@ -404,7 +430,7 @@ int msgpack_unserialize_int64(
int msgpack_unserialize_float(
msgpack_unserialize_data *unpack, float data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_DOUBLE(*obj, data);
@ -414,7 +440,7 @@ int msgpack_unserialize_float(
int msgpack_unserialize_double(
msgpack_unserialize_data *unpack, double data, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_DOUBLE(*obj, data);
@ -423,7 +449,7 @@ int msgpack_unserialize_double(
int msgpack_unserialize_nil(msgpack_unserialize_data *unpack, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_NULL(*obj);
@ -432,7 +458,7 @@ int msgpack_unserialize_nil(msgpack_unserialize_data *unpack, zval **obj)
int msgpack_unserialize_true(msgpack_unserialize_data *unpack, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_BOOL(*obj, 1);
@ -441,7 +467,7 @@ int msgpack_unserialize_true(msgpack_unserialize_data *unpack, zval **obj)
int msgpack_unserialize_false(msgpack_unserialize_data *unpack, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
ZVAL_BOOL(*obj, 0);
@ -452,7 +478,7 @@ int msgpack_unserialize_raw(
msgpack_unserialize_data *unpack, const char* base,
const char* data, unsigned int len, zval **obj)
{
MSGPACK_UNSERIALIZE_ALLOC(unpack);
MSGPACK_UNSERIALIZE_ALLOC_STACK(unpack);
if (len == 0)
{
@ -481,11 +507,9 @@ int msgpack_unserialize_array(
int msgpack_unserialize_array_item(
msgpack_unserialize_data *unpack, zval **container, zval *obj)
{
MSGPACK_UNSERIALIZE_PUSH_ITEM(unpack, 1, obj);
add_next_index_zval(*container, obj);
MSGPACK_UNSERIALIZE_FINISH_ITEM(unpack);
MSGPACK_UNSERIALIZE_FINISH_ITEM(unpack, 1);
return 0;
}
@ -561,14 +585,15 @@ int msgpack_unserialize_map_item(
return 0;
}
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0)
/* implementing Serializable */
if (ce->unserialize == NULL)
{
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (msgpack_unserialize_map_item) "
"Class %s has no unserializer", ce->name);
"[msgpack] (%s) Class %s has no unserializer",
__FUNCTION__, ce->name);
}
MSGPACK_UNSERIALIZE_FINISH_MAP_ITEM(unpack, key, val);
@ -580,6 +605,7 @@ int msgpack_unserialize_map_item(
container, ce,
(const unsigned char *)Z_STRVAL_P(val), Z_STRLEN_P(val) + 1,
NULL TSRMLS_CC);
#endif
MSGPACK_UNSERIALIZE_FINISH_MAP_ITEM(unpack, key, val);
@ -590,16 +616,14 @@ int msgpack_unserialize_map_item(
zval **rval;
unpack->type = MSGPACK_SERIALIZE_TYPE_NONE;
if (msgpack_var_access(
unpack->var_hash, Z_LVAL_P(val) - 1, &rval) != SUCCESS)
{
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (msgpack_unserialize_map_item) "
"Invalid references value: %ld",
Z_LVAL_P(val) - 1);
"[msgpack] (%s) Invalid references value: %ld",
__FUNCTION__, Z_LVAL_P(val) - 1);
}
MSGPACK_UNSERIALIZE_FINISH_MAP_ITEM(unpack, key, val);
@ -622,8 +646,6 @@ int msgpack_unserialize_map_item(
}
}
MSGPACK_UNSERIALIZE_PUSH_ITEM(unpack, 2, val);
if (Z_TYPE_PP(container) != IS_ARRAY && Z_TYPE_PP(container) != IS_OBJECT)
{
array_init(*container);
@ -640,8 +662,9 @@ int msgpack_unserialize_map_item(
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (msgpack_unserialize_map_item) "
"illegal offset type, skip this decoding");
"[msgpack] (%s) "
"illegal offset type, skip this decoding",
__FUNCTION__);
}
}
break;
@ -654,8 +677,9 @@ int msgpack_unserialize_map_item(
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (msgpack_unserialize_map_item) "
"illegal offset type, skip this decoding");
"[msgpack] (%s) "
"illegal offset type, skip this decoding",
__FUNCTION__);
}
}
break;
@ -664,13 +688,15 @@ int msgpack_unserialize_map_item(
if (MSGPACK_G(error_display))
{
zend_error(E_WARNING,
"[msgpack] (msgpack_unserialize_map_item) "
"illegal offset type, skip this decoding");
"[msgpack] (%s) "
"illegal offset type, skip this decoding",
__FUNCTION__);
}
break;
}
zval_ptr_dtor(&key);
msgpack_stack_pop(unpack->var_hash, 2);
long deps = unpack->deps - 1;
unpack->stack[deps]--;

View File

@ -25,7 +25,8 @@ typedef struct {
} msgpack_unserialize_data;
void msgpack_unserialize_var_init(php_unserialize_data_t *var_hashx);
void msgpack_unserialize_var_destroy(php_unserialize_data_t *var_hashx);
void msgpack_unserialize_var_destroy(
php_unserialize_data_t *var_hashx, bool err);
void msgpack_unserialize_init(msgpack_unserialize_data *unpack);

View File

@ -10,11 +10,11 @@
<email>advect@gmail.com</email>
<active>yes</active>
</lead>
<date>2010-10-26</date>
<time>13:44:47</time>
<date>2010-12-27</date>
<time>10:30:54</time>
<version>
<release>0.3.1</release>
<api>0.3.1</api>
<release>0.3.3</release>
<api>0.3.3</api>
</version>
<stability>
<release>beta</release>
@ -26,20 +26,24 @@
<dir name="/">
<file md5sum="12b9d8867e5fde4af426c134283e2082" name="LICENSE" role="doc" />
<file md5sum="8daeb22744f11b57da9d0966608e2fc1" name="README" role="doc" />
<file md5sum="52329b794aab67446540c4c2b5537076" name="config.m4" role="src" />
<file md5sum="dc485aa81a31fc9f42b2b42b3554b41b" name="msgpack.c" role="src" />
<file md5sum="2a27ea5a6c13c65802dcd715e00c4646" name="msgpack_class.c" role="src" />
<file md5sum="f58d228c0b7ace35fc85178f1aa2fb22" name="msgpack_class.h" role="src" />
<file md5sum="177fdfa077b5d23bc22553ad6e051ec2" name="msgpack_pack.c" role="src" />
<file md5sum="c40d516627022a54003ac2b74a82688a" name="CREDITS" role="doc" />
<file md5sum="7eec74d33cff6f8aaeb158bd049a3998" name="ChangeLog" role="doc" />
<file md5sum="d41d8cd98f00b204e9800998ecf8427e" name="EXPERIMENTAL" role="doc" />
<file md5sum="8cc392f13f5a89d033cf73e612377b95" name="config.m4" role="src" />
<file md5sum="712ddaf861db6e52a7cf4885c6eced70" name="config.w32" role="src" />
<file md5sum="c9216741b72004ddf1a1347398220433" name="msgpack.c" role="src" />
<file md5sum="55455423c25b0a13946809aa5345a160" name="msgpack_class.c" role="src" />
<file md5sum="b8eadd32c3eafb67645bb4ffe16f687c" name="msgpack_class.h" role="src" />
<file md5sum="20c46a37124113e6f6a45df46e5496ba" name="msgpack_pack.c" role="src" />
<file md5sum="eae6797621ca53f8a7b0c2d9cb8a4d21" name="msgpack_pack.h" role="src" />
<file md5sum="1a832b3cbc1d41a2ec1a68584339c868" name="msgpack_unpack.c" role="src" />
<file md5sum="ed466f04f0608165701a5273a587de1c" name="msgpack_unpack.h" role="src" />
<file md5sum="61bcd8356b18d070efae7c490d00ded5" name="php_msgpack.h" role="src" />
<file md5sum="b965b77a1732e78361a9037ad46ac976" name="msgpack_unpack.c" role="src" />
<file md5sum="57657b955720eedcad10c2e510f2c825" name="msgpack_unpack.h" role="src" />
<file md5sum="714bca7f7e5e1ef9e6d190e72ca04cad" name="php_msgpack.h" role="src" />
<file md5sum="82079e9a298ecdda2122757ddfbf576e" name="msgpack/pack_define.h" role="src" />
<file md5sum="3f77e3df310b5c40a11ce7fee9cd6424" name="msgpack/pack_template.h" role="src" />
<file md5sum="634c90d15cba0aa0cb0bd7f4fbef114d" name="msgpack/pack_template.h" role="src" />
<file md5sum="09510085da29090ea0f3919c2e708f46" name="msgpack/unpack_define.h" role="src" />
<file md5sum="cf387b1971d55b529593fcbc7972ced4" name="msgpack/unpack_template.h" role="src" />
<file md5sum="7cd2e6f11b405521454e1092854cbaab" name="msgpack/sysdep.h" role="src" />
<file md5sum="5eea4af1097495efab534b174c16d939" name="msgpack/sysdep.h" role="src" />
<file md5sum="2e346ebe243e8b770ed01f56d9f886ba" name="msgpack/version.h" role="src" />
<file md5sum="237eda031928a5546bdb92a34815830f" name="tests/001.phpt" role="test" />
<file md5sum="11d3a17e404ec4938eff1d0b0e724e5f" name="tests/002.phpt" role="test" />
@ -49,61 +53,83 @@
<file md5sum="e0488f07f26c74d1c918634c39555d6e" name="tests/006.phpt" role="test" />
<file md5sum="9574605f18eef124b55ede353d255511" name="tests/007.phpt" role="test" />
<file md5sum="dc3584b04311da2a627c6a271a782d2c" name="tests/008.phpt" role="test" />
<file md5sum="72fdd3007ec537174e1a0418c2e289d9" name="tests/009.phpt" role="test" />
<file md5sum="1fad34de86c39785c2928f93db79fee6" name="tests/009b.phpt" role="test" />
<file md5sum="e16926de566700cac0086472adf728c3" name="tests/009.phpt" role="test" />
<file md5sum="05bd0e0989f34098514286c8964f9aff" name="tests/009b.phpt" role="test" />
<file md5sum="ddb421cd083baaca3ce3a5263f731dcd" name="tests/010.phpt" role="test" />
<file md5sum="6a24b3b12778e2935722c97c95c9e393" name="tests/012.phpt" role="test" />
<file md5sum="5d5ecd404959caea3ee96c48e6765669" name="tests/012.phpt" role="test" />
<file md5sum="049a4b38ad7fa71228d0092171bf9ef2" name="tests/012c.phpt" role="test" />
<file md5sum="377f261d48b4f7fc78689aae481ac952" name="tests/013.phpt" role="test" />
<file md5sum="31758388a32df170cc497291d1e4385d" name="tests/014.phpt" role="test" />
<file md5sum="6c26963e7a3d5723f585d672e2e09bc1" name="tests/015.phpt" role="test" />
<file md5sum="a61e2fe43719dc9d3fafe26b170cdce2" name="tests/015b.phpt" role="test" />
<file md5sum="f35a9f6ce6c68c9ce06276fcb5aeb177" name="tests/016.phpt" role="test" />
<file md5sum="266edf8fd821d58adcfebef1d9beb045" name="tests/015.phpt" role="test" />
<file md5sum="beb07e05272c62ec81dad284fa5b36ce" name="tests/015b.phpt" role="test" />
<file md5sum="abc8ed11d14cf131b8d40be510c36e6b" name="tests/015d.phpt" role="test" />
<file md5sum="28356690ba2a5f85c3b6fbfd745a6f96" name="tests/015e.phpt" role="test" />
<file md5sum="d2d6872cb086b769017af3cfaf5e0f52" name="tests/015f.phpt" role="test" />
<file md5sum="fb152ceb5208b0298684eba0a33f992b" name="tests/016.phpt" role="test" />
<file md5sum="4133eed2d1416ae3eb581daf4d08d309" name="tests/016c.phpt" role="test" />
<file md5sum="c143aa78b84c8d7a7189d754592613e0" name="tests/017.phpt" role="test" />
<file md5sum="527491d7441baa77188026e21a0af80b" name="tests/018.phpt" role="test" />
<file md5sum="375d39f1da5efb3067c326a636fa1d88" name="tests/019.phpt" role="test" />
<file md5sum="3d9e08a86a9c1f53af0a86cce5c42d6d" name="tests/020.phpt" role="test" />
<file md5sum="40e429c52cbff763df7a7cdc27c2df2c" name="tests/021.phpt" role="test" />
<file md5sum="af470d224342fa2f24212e73a1aca1ca" name="tests/021.phpt" role="test" />
<file md5sum="23a30dd1eca67eaaf5b640d2153c8c5f" name="tests/022.phpt" role="test" />
<file md5sum="2ccb3302060dbd9395879e215c9b2072" name="tests/023.phpt" role="test" />
<file md5sum="9c8a79da44818eb545aeec7e37e208b3" name="tests/024.phpt" role="test" />
<file md5sum="44e691093efc5f4dd93e512bf15df9f5" name="tests/024b.phpt" role="test" />
<file md5sum="5c2921e615f38d922cff04689aa61b7d" name="tests/025.phpt" role="test" />
<file md5sum="1af2f7e41cee1553b2bdecbccf6dd574" name="tests/026.phpt" role="test" />
<file md5sum="0d4bbab97b4b6a288c5d140ab6ba5b4c" name="tests/026b.phpt" role="test" />
<file md5sum="445c65386d71ed17e1180a3fd6e608d7" name="tests/027.phpt" role="test" />
<file md5sum="f9a2b53540d751f8d2e918758e964968" name="tests/028.phpt" role="test" />
<file md5sum="355cbc6cebfdd4dbd4c47ae1a8947826" name="tests/028b.phpt" role="test" />
<file md5sum="7fad3357febe18a1db8abca7c50614d1" name="tests/023.phpt" role="test" />
<file md5sum="94a334cf86fea8f68b2ff7f3eb56e253" name="tests/024.phpt" role="test" />
<file md5sum="83176fa1d4422fee304ea8aea15cac44" name="tests/024b.phpt" role="test" />
<file md5sum="a9e1ad0f198191cbe559fc9eff740c7d" name="tests/024c.phpt" role="test" />
<file md5sum="c48c256fc9a61eda85149df4da56a116" name="tests/025.phpt" role="test" />
<file md5sum="3a034382e2e40ea9adcfbb1443e22a87" name="tests/025c.phpt" role="test" />
<file md5sum="ee2fb07b3c06aacb1286d6274c75300c" name="tests/026.phpt" role="test" />
<file md5sum="e623ea72bed886b3667c1773ba5b64dc" name="tests/026b.phpt" role="test" />
<file md5sum="7128b56e93a8de75dda938b4fab661fd" name="tests/026d.phpt" role="test" />
<file md5sum="282e770306a16651c6157942c65be644" name="tests/027.phpt" role="test" />
<file md5sum="c8eadc5b775edb2451b895f89ec1fc41" name="tests/027d.phpt" role="test" />
<file md5sum="a79c2460a3164cac53df7fab35b99280" name="tests/028.phpt" role="test" />
<file md5sum="c25e25c0b159fe98d3f3124466756067" name="tests/028b.phpt" role="test" />
<file md5sum="ae8e5e84e50ab051ea58fadd365cd66d" name="tests/028c.phpt" role="test" />
<file md5sum="63ef8435656b9c23bf1f24aad607f8c1" name="tests/028d.phpt" role="test" />
<file md5sum="f380a42cf429a8fb72c50f9d38228109" name="tests/029.phpt" role="test" />
<file md5sum="7de90bedec2c170da12144bb3399dfe5" name="tests/030.phpt" role="test" />
<file md5sum="7ca67b854f69837658cc741ce42b8ed8" name="tests/031.phpt" role="test" />
<file md5sum="3f37b5f1f4da46a1afeafea516d56490" name="tests/031.phpt" role="test" />
<file md5sum="170dfcb82fd1e097fffc6b57a7e9764a" name="tests/032.phpt" role="test" />
<file md5sum="0e96b2ebf8c37c1c4c13de4d2d5dae95" name="tests/033.phpt" role="test" />
<file md5sum="38a296986d384118800b03bb1a4f24a9" name="tests/034.phpt" role="test" />
<file md5sum="661553a8ccd9b83c95772dd9ad68d82b" name="tests/035.phpt" role="test" />
<file md5sum="2418498403672bfce1087c4b4d277d1d" name="tests/040.phpt" role="test" />
<file md5sum="3914d56c32ca243221c8eecc767b3056" name="tests/040.phpt" role="test" />
<file md5sum="8b49472a24bf5fbe9e90276b5f4b076a" name="tests/040b.phpt" role="test" />
<file md5sum="f15fd3c44f570deb4e918b0e04ceb735" name="tests/040c.phpt" role="test" />
<file md5sum="d760724f22120bf81776b564c3bb69ab" name="tests/040d.phpt" role="test" />
<file md5sum="011672f35987ed8e52b7c9afde98bb8d" name="tests/041.phpt" role="test" />
<file md5sum="1073706e82b72a1c845d09273d95b256" name="tests/042.phpt" role="test" />
<file md5sum="57478f4e95bd000bf73a8331e9e19cba" name="tests/050.phpt" role="test" />
<file md5sum="3067fa10e2d27c2823b648d0452c8c46" name="tests/060.phpt" role="test" />
<file md5sum="b42eb220260d4fe1e840d314b53a1add" name="tests/060b.phpt" role="test" />
<file md5sum="c1e8716a879b568185e7eb38ee7dc76c" name="tests/061.phpt" role="test" />
<file md5sum="0d9597d63ca6fcb5040e0994049766b1" name="tests/061b.phpt" role="test" />
<file md5sum="6ee4b49e6e82289e7ea7bf2e37a14212" name="tests/060.phpt" role="test" />
<file md5sum="4b5a8bd201c8b27bbf392f42586a98ca" name="tests/060b.phpt" role="test" />
<file md5sum="e245df195174210507fe6e3f02b97144" name="tests/060c.phpt" role="test" />
<file md5sum="9abfe03959d99d2999f8124983c6a393" name="tests/061.phpt" role="test" />
<file md5sum="77a0522b5d46ed73799a86f4ab2ca844" name="tests/061b.phpt" role="test" />
<file md5sum="33138f031180da877490240503128e81" name="tests/061c.phpt" role="test" />
<file md5sum="187689f3d1d8fe3636ea7d6188e7e559" name="tests/062.phpt" role="test" />
<file md5sum="9c91266595d01080b813fb2a056fca82" name="tests/063.phpt" role="test" />
<file md5sum="3bd5fc0384a9628064ae34886de6dcab" name="tests/064.phpt" role="test" />
<file md5sum="7077fa1fbf3290e8fdf8d963fd2c7d97" name="tests/064b.phpt" role="test" />
<file md5sum="c0ba5f5b4d8c7751a4643cd9946fe9da" name="tests/065.phpt" role="test" />
<file md5sum="1b3763cd9ed063eb733c5e18d726273e" name="tests/065b.phpt" role="test" />
<file md5sum="9d05c3bfd49ad9c7cf00b9b056552c69" name="tests/064.phpt" role="test" />
<file md5sum="8db3eeb829880716d4630b6e448877f5" name="tests/064b.phpt" role="test" />
<file md5sum="0019c5df7135bcb1fa5f7d38a99cd099" name="tests/064c.phpt" role="test" />
<file md5sum="e2f1f67b1f2aba44747f1abef8899275" name="tests/065.phpt" role="test" />
<file md5sum="4bc30d5c195413b44e4223b45e66c819" name="tests/065b.phpt" role="test" />
<file md5sum="e89f1fc1240c2737d16bea70d93b33f5" name="tests/065c.phpt" role="test" />
<file md5sum="bad0c2dee56d9f7a8dd0161ed863915e" name="tests/066.phpt" role="test" />
<file md5sum="d15e923a2bca68f5fb7e285da725c248" name="tests/067.phpt" role="test" />
<file md5sum="337d4cd9d5fe8f903ab093131028a7e7" name="tests/070.phpt" role="test" />
<file md5sum="39fcd79bf09d3edb0c66c301ec5c9095" name="tests/070b.phpt" role="test" />
<file md5sum="f36922baf1228fbb306b1a1104d5b1d2" name="tests/071.phpt" role="test" />
<file md5sum="c75ab77ffcd25d21d31a3889b2f6fa3f" name="tests/071b.phpt" role="test" />
<file md5sum="0ffca7b01df0131c7093c870f30afd60" name="tests/072.phpt" role="test" />
<file md5sum="82c166252f9b775316b22e0082b6354e" name="tests/072b.phpt" role="test" />
<file md5sum="4050391dae2825de90a836828ac21ea9" name="tests/073.phpt" role="test" />
<file md5sum="0dc3daedec3e152ec08db132e28c6015" name="tests/073b.phpt" role="test" />
<file md5sum="a64f3db62c391e1c18356d47aeccbe64" name="tests/070.phpt" role="test" />
<file md5sum="b348c6c26395f6a1439b4bec33549059" name="tests/070b.phpt" role="test" />
<file md5sum="c55954bc5e6fea7d800e3e6349d2536c" name="tests/070c.phpt" role="test" />
<file md5sum="9d3022d964b1e9cc1966b4777e1c986a" name="tests/071.phpt" role="test" />
<file md5sum="2ec2bcdc412bfe52b2e50a6a36000994" name="tests/071b.phpt" role="test" />
<file md5sum="f84d6495c3655b8839adbc9b679bd238" name="tests/071c.phpt" role="test" />
<file md5sum="82d0ded38b3ed2445c23f2ddb4c1a23e" name="tests/072.phpt" role="test" />
<file md5sum="8a23366b9c309d5c7c6e6f9927fb6b13" name="tests/072b.phpt" role="test" />
<file md5sum="74f12ecea570b682bd8de68d60146443" name="tests/072c.phpt" role="test" />
<file md5sum="9ed0bcbc7830c1e716c0ab26ab7a46d0" name="tests/073.phpt" role="test" />
<file md5sum="092e33b2f560df3110f3c21bdcb5c823" name="tests/073b.phpt" role="test" />
<file md5sum="19231469eb0ecb68c424fa3db6720998" name="tests/073c.phpt" role="test" />
<file md5sum="50ef1b19cea2b81bcb7cf3f3ff1d040b" name="tests/080.phpt" role="test" />
<file md5sum="5ee3dfab84acdee232622aae101ec146" name="tests/081.phpt" role="test" />
<file md5sum="c7f9bb84e313d1d675318373938c026a" name="tests/082.phpt" role="test" />
@ -111,15 +137,18 @@
<file md5sum="01c6e99e89d080be939d2145b9552aa4" name="tests/084.phpt" role="test" />
<file md5sum="0e6f002a83f987b35a3b0d50886ab509" name="tests/085.phpt" role="test" />
<file md5sum="ffc10aeb072866202046c0a0bcac281e" name="tests/086.phpt" role="test" />
<file md5sum="c7963f41a1d3bad67febe2a706abae5e" name="tests/087.phpt" role="test" />
<file md5sum="f7c4c471a332f66d058f53dae99e7304" name="tests/088.phpt" role="test" />
<file md5sum="82f9a41ec36be738c9824b7d70c09e4d" name="tests/089.phpt" role="test" />
<file md5sum="71203179b832143b7e5efc2aba9837fc" name="tests/087.phpt" role="test" />
<file md5sum="c3130e75e684fa42bcfdbdd5338ddaec" name="tests/087d.phpt" role="test" />
<file md5sum="72c67a293e47af26840d509baf26c81d" name="tests/088.phpt" role="test" />
<file md5sum="5f712f6c29c88a6116d90fd54de666ad" name="tests/088d.phpt" role="test" />
<file md5sum="fb70fa45d6c74bed8c5f9380143c4f42" name="tests/089.phpt" role="test" />
<file md5sum="d2c93179cef10dd2ca77bbbc42127585" name="tests/089d.phpt" role="test" />
</dir>
</contents>
<dependencies>
<required>
<php>
<min>5.2.0</min>
<min>5.1.0</min>
</php>
<pearinstaller>
<min>1.4.3</min>

View File

@ -3,7 +3,7 @@
Summary: PHP extension for interfacing with MessagePack
Name: php-msgpack
Version: 0.3.0
Version: 0.3.3
Release: 1%{?dist}
Source: php-msgpack-%{version}.tar.gz
License: New BSD License

View File

@ -2,7 +2,7 @@
#ifndef PHP_MSGPACK_H
#define PHP_MSGPACK_H
#define MSGPACK_EXTENSION_VERSION "0.3.1"
#define MSGPACK_EXTENSION_VERSION "0.3.3"
#include "ext/standard/php_smart_str.h"

View File

@ -2,8 +2,10 @@
Check for reference serialization
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,10 @@
Check for reference serialization
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
--FILE--
<?php

View File

@ -1,6 +1,10 @@
--TEST--
Object test
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

52
php/tests/012c.phpt Normal file
View File

@ -0,0 +1,52 @@
--TEST--
Object test
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test) {
$serialized = msgpack_serialize($variable);
$unserialized = msgpack_unserialize($serialized);
echo $type, PHP_EOL;
echo bin2hex($serialized), PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
$o = new Obj(1, 2, 3);
test('object', $o, false);
?>
--EXPECTF--
object
84c0a34f626aa16101a4002a006202a6004f626a006303
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
OK

View File

@ -1,6 +1,10 @@
--TEST--
Check for serialization handler
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

View File

@ -1,6 +1,10 @@
--TEST--
Check for serialization handler, ini-directive
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--INI--
session.serialize_handler=msgpack
--FILE--

62
php/tests/015d.phpt Normal file
View File

@ -0,0 +1,62 @@
--TEST--
Check for serialization handler
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.2 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
$output = '';
function open($path, $name) {
return true;
}
function close() {
return true;
}
function read($id) {
global $output;
return pack('H*', '81a3666f6f01');
}
function write($id, $data) {
global $output;
$output .= bin2hex($data). PHP_EOL;
return true;
}
function destroy($id) {
return true;
}
function gc($time) {
return true;
}
ini_set('session.serialize_handler', 'msgpack');
session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
session_start();
echo ++$_SESSION['foo'], PHP_EOL;
session_write_close();
echo $output;
var_dump($_SESSION);
?>
--EXPECT--
2
81a3666f6f02
array(1) {
["foo"]=>
int(2)
}

65
php/tests/015e.phpt Normal file
View File

@ -0,0 +1,65 @@
--TEST--
Check for serialization handler, broken
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
error_reporting(0);
$output = '';
function open($path, $name) {
return true;
}
function close() {
return true;
}
function read($id) {
global $output;
//broken data
return pack('H*', '81a36');
}
function write($id, $data) {
global $output;
$output .= bin2hex($data). PHP_EOL;
return true;
}
function destroy($id) {
return true;
}
function gc($time) {
return true;
}
ini_set('session.serialize_handler', 'msgpack');
session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
session_start();
echo ++$_SESSION['foo'], PHP_EOL;
session_write_close();
echo $output;
var_dump($_SESSION);
?>
--EXPECT--
1
82c001a3666f6f01
array(1) {
["foo"]=>
int(1)
}

65
php/tests/015f.phpt Normal file
View File

@ -0,0 +1,65 @@
--TEST--
Check for serialization handler, broken
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.2 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
error_reporting(0);
$output = '';
function open($path, $name) {
return true;
}
function close() {
return true;
}
function read($id) {
global $output;
//broken data
return pack('H*', '81a36');
}
function write($id, $data) {
global $output;
$output .= bin2hex($data). PHP_EOL;
return true;
}
function destroy($id) {
return true;
}
function gc($time) {
return true;
}
ini_set('session.serialize_handler', 'msgpack');
session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
session_start();
echo ++$_SESSION['foo'], PHP_EOL;
session_write_close();
echo $output;
var_dump($_SESSION);
?>
--EXPECT--
1
81a3666f6f01
array(1) {
["foo"]=>
int(1)
}

View File

@ -1,6 +1,10 @@
--TEST--
Object test, __sleep
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

64
php/tests/016c.phpt Normal file
View File

@ -0,0 +1,64 @@
--TEST--
Object test, __sleep
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test) {
$serialized = msgpack_serialize($variable);
$unserialized = msgpack_unserialize($serialized);
echo $type, PHP_EOL;
echo bin2hex($serialized), PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
class Obj {
public $a;
protected $b;
private $c;
var $d;
function __construct($a, $b, $c, $d) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
$this->d = $d;
}
function __sleep() {
return array('a', 'b', 'c');
}
# function __wakeup() {
# $this->d = $this->a + $this->b + $this->c;
# }
}
$o = new Obj(1, 2, 3, 4);
test('object', $o, true);
?>
--EXPECTF--
object
84c0a34f626aa16101a4002a006202a6004f626a006303
object(Obj)#%d (4) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
["d"]=>
NULL
}
OK

View File

@ -1,6 +1,10 @@
--TEST--
Object Serializable interface
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') < 0) {
echo "skip tests in PHP 5.1 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

View File

@ -1,11 +1,6 @@
--TEST--
Resource
--SKIPIF--
<?php
if (!function_exists("curl_init") && !class_exists("Sqlite3"))) {
echo "skip";
}
?>
--FILE--
<?php
if(!extension_loaded('msgpack')) {
@ -26,11 +21,10 @@ function test($type, $variable, $test) {
if (function_exists('curl_init')) {
$test = 'curl';
$res = curl_init('http://opensource.dynamoid.com');
} else if (class_exists('Sqlite3')) {
$test = 'sqlite';
$sqlite = new Sqlite3();
$res = $sqlite->open('db.txt');
$res = curl_init('http://php.net/');
} else {
$test = 'dir';
$res = opendir('/tmp');
}
test('resource', $res, false);
@ -39,11 +33,8 @@ switch ($test) {
case 'curl':
curl_close($res);
break;
case 'sqlite':
if (isset($sqlite)) {
$sqlite->close();
}
@unlink('db.txt');
default:
closedir($res);
break;
}
?>

View File

@ -2,8 +2,10 @@
Recursive objects
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,13 @@
Recursive objects
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php

170
php/tests/024c.phpt Normal file
View File

@ -0,0 +1,170 @@
--TEST--
Recursive objects
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test) {
$serialized = msgpack_serialize($variable);
$unserialized = msgpack_unserialize($serialized);
echo $type, PHP_EOL;
echo bin2hex($serialized), PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
class Obj2 {
public $aa;
protected $bb;
private $cc;
private $obj;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
$this->obj = new Obj($a, $b, $c);
}
}
class Obj3 {
private $objs;
function __construct($a, $b, $c) {
$this->objs = array();
for ($i = $a; $i < $c; $i += $b) {
$this->objs[] = new Obj($a, $i, $c);
}
}
}
class Obj4 {
private $a;
private $obj;
function __construct($a) {
$this->a = $a;
}
public function set($obj) {
$this->obj = $obj;
}
}
$o2 = new Obj2(1, 2, 3);
test('objectrec', $o2, false);
$o3 = new Obj3(0, 1, 4);
test('objectrecarr', $o3, false);
$o4 = new Obj4(100);
$o4->set($o4);
test('objectselfrec', $o4, true);
?>
--EXPECTF--
objectrec
88c0a44f626a32a26161c0a5002a006262c0a8004f626a32006363c0a9004f626a32006f626a84c0a34f626aa16101a4002a006202a6004f626a006303a16101a16202a16303
object(Obj2)#%d (7) {
["aa"]=>
NULL
["bb:protected"]=>
NULL
["cc:private"]=>
NULL
["obj:private"]=>
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
["a"]=>
int(1)
["b"]=>
int(2)
["c"]=>
int(3)
}
OK
objectrecarr
82c0a44f626a33aa004f626a33006f626a73840084c0a34f626aa16100a4002a006200a6004f626a0063040184c0a34f626aa16100a4002a006201a6004f626a0063040284c0a34f626aa16100a4002a006202a6004f626a0063040384c0a34f626aa16100a4002a006203a6004f626a006304
object(Obj3)#%d (1) {
["objs:private"]=>
array(4) {
[0]=>
object(Obj)#%d (3) {
["a"]=>
int(0)
["b:protected"]=>
int(0)
["c:private"]=>
int(4)
}
[1]=>
object(Obj)#%d (3) {
["a"]=>
int(0)
["b:protected"]=>
int(1)
["c:private"]=>
int(4)
}
[2]=>
object(Obj)#%d (3) {
["a"]=>
int(0)
["b:protected"]=>
int(2)
["c:private"]=>
int(4)
}
[3]=>
object(Obj)#%d (3) {
["a"]=>
int(0)
["b:protected"]=>
int(3)
["c:private"]=>
int(4)
}
}
}
OK
objectselfrec
83c0a44f626a34a7004f626a34006164a9004f626a34006f626a82c0020001
object(Obj4)#%d (2) {
["a:private"]=>
int(100)
["obj:private"]=>
object(Obj4)#%d (2) {
["a:private"]=>
int(100)
["obj:private"]=>
*RECURSION*
}
}
OK

View File

@ -1,6 +1,10 @@
--TEST--
Object test, array of objects with __sleep
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

123
php/tests/025c.phpt Normal file
View File

@ -0,0 +1,123 @@
--TEST--
Object test, array of objects with __sleep
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test) {
$serialized = msgpack_serialize($variable);
$unserialized = msgpack_unserialize($serialized);
var_dump($variable);
var_dump($unserialized);
}
class Obj {
public $a;
protected $b;
private $c;
var $d;
function __construct($a, $b, $c, $d) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
$this->d = $d;
}
function __sleep() {
return array('a', 'b', 'c');
}
# function __wakeup() {
# $this->d = $this->a + $this->b + $this->c;
# }
}
$array = array(
new Obj("aa", "bb", "cc", "dd"),
new Obj("ee", "ff", "gg", "hh"),
new Obj(1, 2, 3, 4),
);
test('array', $array, true);
?>
--EXPECTF--
array(3) {
[0]=>
object(Obj)#1 (4) {
["a"]=>
string(2) "aa"
["b:protected"]=>
string(2) "bb"
["c:private"]=>
string(2) "cc"
["d"]=>
string(2) "dd"
}
[1]=>
object(Obj)#2 (4) {
["a"]=>
string(2) "ee"
["b:protected"]=>
string(2) "ff"
["c:private"]=>
string(2) "gg"
["d"]=>
string(2) "hh"
}
[2]=>
object(Obj)#3 (4) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
["d"]=>
int(4)
}
}
array(3) {
[0]=>
object(Obj)#4 (4) {
["a"]=>
string(2) "aa"
["b:protected"]=>
string(2) "bb"
["c:private"]=>
string(2) "cc"
["d"]=>
NULL
}
[1]=>
object(Obj)#5 (4) {
["a"]=>
string(2) "ee"
["b:protected"]=>
string(2) "ff"
["c:private"]=>
string(2) "gg"
["d"]=>
NULL
}
[2]=>
object(Obj)#6 (4) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
["d"]=>
NULL
}
}

View File

@ -3,8 +3,10 @@ Cyclic array test
--INI--
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php
@ -43,7 +45,7 @@ var_dump($k);
?>
--EXPECT--
array
82a16182a162a163a164a165a16683c001a16182a162a163a164a165a16682c0020005
82a16182a162a163a164a165a16683c001a16182a162a163a164a165a16682c0020003
array(2) {
["a"]=>
array(2) {

View File

@ -3,8 +3,13 @@ Cyclic array test
--INI--
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.1.0') < 0) {
echo "skip tests in PHP 5.1 or newer";
}
--FILE--
<?php
@ -43,7 +48,7 @@ var_dump($k);
?>
--EXPECT--
array
82a16182a162a163a164a165a16683c001a16182a162a163a164a165a16682c0020005
82a16182a162a163a164a165a16683c001a16182a162a163a164a165a16682c0020003
array(2) {
["a"]=>
array(2) {

147
php/tests/026d.phpt Normal file
View File

@ -0,0 +1,147 @@
--TEST--
Cyclic array test
--INI--
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') >= 0) {
echo "skip tests in PHP 5.0 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test) {
$serialized = msgpack_serialize($variable);
$unserialized = msgpack_unserialize($serialized);
echo $type, PHP_EOL;
echo bin2hex($serialized), PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
);
$a['f'] = &$a;
test('array', $a, true);
$a = array("foo" => &$b);
$b = array(1, 2, $a);
var_dump($a);
var_dump($k = msgpack_unserialize(msgpack_serialize($a)));
$k["foo"][1] = "b";
var_dump($k);
?>
--EXPECT--
array
82a16182a162a163a164a165a16682a16182a162a163a164a165a16682a16182a162a163a164a165a166c0
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
NULL
}
}
}
OK
array(1) {
["foo"]=>
&array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
array(1) {
["foo"]=>
&array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
*RECURSION*
}
}
}
}
array(1) {
["foo"]=>
&array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
array(1) {
["foo"]=>
&array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
array(1) {
["foo"]=>
*RECURSION*
}
}
}
}
}
array(1) {
["foo"]=>
&array(3) {
[0]=>
int(1)
[1]=>
string(1) "b"
[2]=>
array(1) {
["foo"]=>
&array(3) {
[0]=>
int(1)
[1]=>
string(1) "b"
[2]=>
array(1) {
["foo"]=>
*RECURSION*
}
}
}
}
}

View File

@ -1,6 +1,10 @@
--TEST--
Check for serialization handler
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

77
php/tests/027d.phpt Normal file
View File

@ -0,0 +1,77 @@
--TEST--
Check for serialization handler
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.2 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
$output = '';
function open($path, $name) {
return true;
}
function close() {
return true;
}
function read($id) {
global $output;
$output .= "read" . PHP_EOL;
return pack('H*', '81a3666f6f01');
}
function write($id, $data) {
global $output;
$output .= "wrote: ";
$output .= bin2hex($data). PHP_EOL;
return true;
}
function destroy($id) {
return true;
}
function gc($time) {
return true;
}
class Foo {
}
class Bar {
}
ini_set('session.serialize_handler', 'msgpack');
session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
$db_object = new Foo();
$session_object = new Bar();
$v = session_start();
var_dump($v);
$_SESSION['test'] = "foobar";
session_write_close();
echo $output;
var_dump($_SESSION);
?>
--EXPECT--
bool(true)
read
wrote: 82a3666f6f01a474657374a6666f6f626172
array(2) {
["foo"]=>
int(1)
["test"]=>
string(6) "foobar"
}

View File

@ -2,8 +2,10 @@
Serialize object into session, full set
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php
@ -100,7 +102,7 @@ var_dump($_SESSION);
?>
--EXPECTF--
read
write: 84c001a36f6c6484c0a3466f6fa700466f6f00643184c0a3426172a2643182c0020002a70042617200643282c0020002a5002a00643382c0020002a5002a00643282c0020003a2643382c0020003a474657374a6666f6f626172a36e657784c0a3426172a2643184c0a3466f6fa700466f6f00643182c002000aa5002a00643282c002000aa2643382c002000aa70042617200643282c002000ba5002a00643382c002000b
write: 84c001a36f6c6484c0a3466f6fa700466f6f00643184c0a3426172a2643182c0020002a70042617200643282c0020002a5002a00643382c0020002a5002a00643282c0020003a2643382c0020003a474657374a6666f6f626172a36e657784c0a3426172a2643184c0a3466f6fa700466f6f00643182c0020009a5002a00643282c0020009a2643382c0020009a70042617200643282c002000aa5002a00643382c002000a
array(3) {
["old"]=>
object(Foo)#3 (3) {

View File

@ -2,8 +2,13 @@
Serialize object into session, full set
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php
@ -100,7 +105,7 @@ var_dump($_SESSION);
?>
--EXPECTF--
read
write: 84c001a36f6c6484c0a3466f6fa700466f6f00643184c0a3426172a2643182c0020002a70042617200643282c0020002a5002a00643382c0020002a5002a00643282c0020003a2643382c0020003a474657374a6666f6f626172a36e657784c0a3426172a2643184c0a3466f6fa700466f6f00643182c002000aa5002a00643282c002000aa2643382c002000aa70042617200643282c002000ba5002a00643382c002000b
write: 84c001a36f6c6484c0a3466f6fa700466f6f00643184c0a3426172a2643182c0020002a70042617200643282c0020002a5002a00643382c0020002a5002a00643282c0020003a2643382c0020003a474657374a6666f6f626172a36e657784c0a3426172a2643184c0a3466f6fa700466f6f00643182c0020009a5002a00643282c0020009a2643382c0020009a70042617200643282c002000aa5002a00643382c002000a
array(3) {
["old"]=>
object(Foo)#3 (3) {

672
php/tests/028c.phpt Normal file
View File

@ -0,0 +1,672 @@
--TEST--
Serialize object into session, full set
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') < 0 ||
version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
class Foo {
private static $s1 = array();
protected static $s2 = array();
public static $s3 = array();
private $d1;
protected $d2;
public $d3;
public function __construct($foo) {
$this->d1 = $foo;
$this->d2 = $foo;
$this->d3 = $foo;
}
}
class Bar {
private static $s1 = array();
protected static $s2 = array();
public static $s3 = array();
public $d1;
private $d2;
protected $d3;
public function __construct() {
}
public function set($foo) {
$this->d1 = $foo;
$this->d2 = $foo;
$this->d3 = $foo;
}
}
$output = '';
function open($path, $name) {
return true;
}
function close() {
return true;
}
function read($id) {
global $output;
$output .= "read" . PHP_EOL;
$a = new Bar();
$b = new Foo($a);
$a->set($b);
$session = array('old' => $b);
return msgpack_serialize($session);
}
function write($id, $data) {
global $output;
$output .= "write: ";
$output .= bin2hex($data) . PHP_EOL;
return true;
}
function destroy($id) {
return true;
}
function gc($time) {
return true;
}
ini_set('session.serialize_handler', 'msgpack');
session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
session_start();
$_SESSION['test'] = "foobar";
$a = new Bar();
$b = new Foo($a);
$a->set($b);
$_SESSION['new'] = $a;
session_write_close();
echo $output;
var_dump($_SESSION);
?>
--EXPECTF--
read
write: 83a36f6c6484c0a3466f6fa700466f6f00643184c0a3426172a2643182c0020002a70042617200643282c0020002a5002a00643382c0020002a5002a00643282c0020003a2643382c0020003a474657374a6666f6f626172a36e657784c0a3426172a2643184c0a3466f6fa700466f6f00643182c0020009a5002a00643282c0020009a2643382c0020009a70042617200643282c002000aa5002a00643382c002000a
array(3) {
["old"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d2:private"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d3:protected"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d2:private"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d3:protected"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d2:private"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d3:protected"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
}
}
["test"]=>
string(6) "foobar"
["new"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d2:protected"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d3"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d2:protected"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d3"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d2:protected"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d3"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
}
}
}

671
php/tests/028d.phpt Normal file
View File

@ -0,0 +1,671 @@
--TEST--
Serialize object into session, full set
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') >= 0) {
echo "skip tests in PHP 5.0 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
class Foo {
private static $s1 = array();
protected static $s2 = array();
public static $s3 = array();
private $d1;
protected $d2;
public $d3;
public function __construct($foo) {
$this->d1 = $foo;
$this->d2 = $foo;
$this->d3 = $foo;
}
}
class Bar {
private static $s1 = array();
protected static $s2 = array();
public static $s3 = array();
public $d1;
private $d2;
protected $d3;
public function __construct() {
}
public function set($foo) {
$this->d1 = $foo;
$this->d2 = $foo;
$this->d3 = $foo;
}
}
$output = '';
function open($path, $name) {
return true;
}
function close() {
return true;
}
function read($id) {
global $output;
$output .= "read" . PHP_EOL;
$a = new Bar();
$b = new Foo($a);
$a->set($b);
$session = array('old' => $b);
return msgpack_serialize($session);
}
function write($id, $data) {
global $output;
$output .= "write: ";
$output .= bin2hex($data) . PHP_EOL;
return true;
}
function destroy($id) {
return true;
}
function gc($time) {
return true;
}
ini_set('session.serialize_handler', 'msgpack');
session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
session_start();
$_SESSION['test'] = "foobar";
$a = new Bar();
$b = new Foo($a);
$a->set($b);
$_SESSION['new'] = $a;
session_write_close();
echo $output;
var_dump($_SESSION);
?>
--EXPECTF--
read
write: 83a36f6c6484c0a3466f6fa700466f6f00643184c0a3426172a2643182c0020002a70042617200643282c0020002a5002a00643382c0020002a5002a00643282c0020003a2643382c0020003a474657374a6666f6f626172a36e657784c0a3426172a2643184c0a3466f6fa700466f6f00643182c0020009a5002a00643282c0020009a2643382c0020009a70042617200643282c002000aa5002a00643382c002000a
array(3) {
["old"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d2:private"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d3:protected"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d2:private"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d3:protected"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d2:private"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
["d3:protected"]=>
object(Foo)#3 (3) {
["d1:private"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d2:protected"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
["d3"]=>
object(Bar)#4 (3) {
["d1"]=>
*RECURSION*
["d2:private"]=>
*RECURSION*
["d3:protected"]=>
*RECURSION*
}
}
}
}
["test"]=>
string(6) "foobar"
["new"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d2:protected"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d3"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d2:protected"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d3"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d2:protected"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
["d3"]=>
object(Bar)#5 (3) {
["d1"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d2:private"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
["d3:protected"]=>
object(Foo)#6 (3) {
["d1:private"]=>
*RECURSION*
["d2:protected"]=>
*RECURSION*
["d3"]=>
*RECURSION*
}
}
}
}
}

View File

@ -1,6 +1,10 @@
--TEST--
Object Serializable interface throws exceptions
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') < 0) {
echo "skip tests in PHP 5.1 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

View File

@ -1,5 +1,5 @@
--TEST--
b0rked random data test
broken random data test
--SKIPIF--
--FILE--
<?php

44
php/tests/040b.phpt Normal file
View File

@ -0,0 +1,44 @@
--TEST--
broken random data test : MessagePack class
--SKIPIF--
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
error_reporting(E_ERROR | E_PARSE);
function test() {
$serialized = msgpack_serialize(null);
$serialized = substr($serialized, 0, -1);
$length = mt_rand(1, 255);
for ($i = 0; $i < $length; ++$i) {
$serialized .= chr(mt_rand(0, 255));
}
// if returned null everything is OK
$msgpack = new MessagePack();
if (($unserialized = $msgpack->unpack($serialized)) === null) {
return true;
}
// whole data is read?
if ($serialized !== msgpack_serialize($unserialized)) {
return true;
}
echo bin2hex($serialized), "\n";
var_dump($unserialized);
return false;
}
mt_srand(0x4c05b583);
for ($i = 0; $i < 100; ++$i) {
if (!test()) break;
}
?>
--EXPECT--

53
php/tests/040c.phpt Normal file
View File

@ -0,0 +1,53 @@
--TEST--
broken random data test : MessagePackUnpacker::feed
--SKIPIF--
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
error_reporting(E_ERROR | E_PARSE);
function test() {
$serialized = msgpack_serialize(null);
$serialized = substr($serialized, 0, -1);
$length = mt_rand(1, 255);
for ($i = 0; $i < $length; ++$i) {
$serialized .= chr(mt_rand(0, 255));
}
// if returned null everything is OK
$unpacker = new MessagePackUnpacker();
$unpacker->feed($serialized);
if ($unpacker->execute())
{
if (($unserialized = $unpacker->data()) === null) {
return true;
}
$unpacker->reset();
}
else
{
return true;
}
// whole data is read?
if ($serialized !== msgpack_serialize($unserialized)) {
return true;
}
echo bin2hex($serialized), "\n";
var_dump($unserialized);
return false;
}
mt_srand(0x4c05b583);
for ($i = 0; $i < 100; ++$i) {
if (!test()) break;
}
?>
--EXPECT--

52
php/tests/040d.phpt Normal file
View File

@ -0,0 +1,52 @@
--TEST--
broken random data test : MessagePackUnpacker::execute
--SKIPIF--
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
error_reporting(E_ERROR | E_PARSE);
function test() {
$serialized = msgpack_serialize(null);
$serialized = substr($serialized, 0, -1);
$length = mt_rand(1, 255);
for ($i = 0; $i < $length; ++$i) {
$serialized .= chr(mt_rand(0, 255));
}
// if returned null everything is OK
$unpacker = new MessagePackUnpacker();
if ($unpacker->execute($serialized, $offset))
{
if (($unserialized = $unpacker->data()) === null) {
return true;
}
$unpacker->reset();
}
else
{
return true;
}
// whole data is read?
if ($serialized !== msgpack_serialize($unserialized)) {
return true;
}
echo bin2hex($serialized), "\n";
var_dump($unserialized);
return false;
}
mt_srand(0x4c05b583);
for ($i = 0; $i < 100; ++$i) {
if (!test()) break;
}
?>
--EXPECT--

View File

@ -2,8 +2,10 @@
Check for buffered streaming unserialization
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,13 @@
Check for buffered streaming unserialization
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php

319
php/tests/060c.phpt Normal file
View File

@ -0,0 +1,319 @@
--TEST--
Check for buffered streaming unserialization
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test = null) {
$serialized = msgpack_serialize($variable);
$unpacker = new MessagePackUnpacker();
$length = strlen($serialized);
for ($i = 0; $i < $length;) {
$len = rand(1, 10);
$str = substr($serialized, $i, $len);
$unpacker->feed($str);
if ($unpacker->execute())
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
}
$i += $len;
}
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('bool: true', true);
test('bool: false', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('array', array(), false);
test('array(1, 2, 3)', array(1, 2, 3), false);
test('array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), false);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), false);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
&array(1) {
[0]=>
string(3) "foo"
}
[1]=>
&array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
OK
array(2) {
[0]=>
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
object(Obj)#%d (3) {
["a"]=>
int(4)
["b:protected"]=>
int(5)
["c:private"]=>
int(6)
}
}
OK
array(2) {
[0]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
}
OK

View File

@ -2,8 +2,10 @@
Check for unbuffered streaming unserialization
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,13 @@
Check for unbuffered streaming unserialization
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php

324
php/tests/061c.phpt Normal file
View File

@ -0,0 +1,324 @@
--TEST--
Check for unbuffered streaming unserialization
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test = null) {
$serialized = msgpack_serialize($variable);
$unpacker = new MessagePackUnpacker();
$length = strlen($serialized);
$str = "";
$offset = 0;
for ($i = 0; $i < $length;) {
$len = rand(1, 10);
$str .= substr($serialized, $i, $len);
if ($unpacker->execute($str, $offset))
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
$str = "";
$offset = 0;
}
$i += $len;
}
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('boo:l true', true);
test('bool: true', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('empty: array', array(), false);
test('empty: array(1, 2, 3)', array(1, 2, 3), false);
test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), false);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), false);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
&array(1) {
[0]=>
string(3) "foo"
}
[1]=>
&array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
OK
array(2) {
[0]=>
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
object(Obj)#%d (3) {
["a"]=>
int(4)
["b:protected"]=>
int(5)
["c:private"]=>
int(6)
}
}
OK
array(2) {
[0]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
}
OK

View File

@ -2,8 +2,10 @@
Check for buffered streaming unserialization (single)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,13 @@
Check for buffered streaming unserialization (single)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php

321
php/tests/064c.phpt Normal file
View File

@ -0,0 +1,321 @@
--TEST--
Check for buffered streaming unserialization (single)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
$unpacker = new MessagePackUnpacker();
function test($type, $variable, $test = null) {
$serialized = msgpack_serialize($variable);
global $unpacker;
$length = strlen($serialized);
for ($i = 0; $i < $length;) {
$len = rand(1, 10);
$str = substr($serialized, $i, $len);
$unpacker->feed($str);
if ($unpacker->execute())
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
}
$i += $len;
}
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('bool: true', true);
test('bool: false', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('array', array(), false);
test('array(1, 2, 3)', array(1, 2, 3), false);
test('array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), false);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), false);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
&array(1) {
[0]=>
string(3) "foo"
}
[1]=>
&array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
OK
array(2) {
[0]=>
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
object(Obj)#%d (3) {
["a"]=>
int(4)
["b:protected"]=>
int(5)
["c:private"]=>
int(6)
}
}
OK
array(2) {
[0]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
}
OK

View File

@ -2,8 +2,10 @@
Check for unbuffered streaming unserialization (single)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,13 @@
Check for unbuffered streaming unserialization (single)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php

326
php/tests/065c.phpt Normal file
View File

@ -0,0 +1,326 @@
--TEST--
Check for unbuffered streaming unserialization (single)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
$unpacker = new MessagePackUnpacker();
function test($type, $variable, $test = null) {
$serialized = msgpack_serialize($variable);
global $unpacker;
$length = strlen($serialized);
$str = "";
$offset = 0;
for ($i = 0; $i < $length;) {
$len = rand(1, 10);
$str .= substr($serialized, $i, $len);
if ($unpacker->execute($str, $offset))
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
$str = "";
$offset = 0;
}
$i += $len;
}
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('boo:l true', true);
test('bool: true', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('empty: array', array(), false);
test('empty: array(1, 2, 3)', array(1, 2, 3), false);
test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), false);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), false);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
&array(1) {
[0]=>
string(3) "foo"
}
[1]=>
&array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
OK
array(2) {
[0]=>
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
object(Obj)#%d (3) {
["a"]=>
int(4)
["b:protected"]=>
int(5)
["c:private"]=>
int(6)
}
}
OK
array(2) {
[0]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
}
OK

View File

@ -2,8 +2,10 @@
Check for alias functions
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,13 @@
Check for alias functions
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php

303
php/tests/070c.phpt Normal file
View File

@ -0,0 +1,303 @@
--TEST--
Check for alias functions
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test = null) {
$serialized = msgpack_pack($variable);
$unserialized = msgpack_unpack($serialized);
var_dump($unserialized);
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('boo:l true', true);
test('bool: true', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('empty: array', array(), false);
test('empty: array(1, 2, 3)', array(1, 2, 3), false);
test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), false);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), false);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
&array(1) {
[0]=>
string(3) "foo"
}
[1]=>
&array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
OK
array(2) {
[0]=>
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
object(Obj)#%d (3) {
["a"]=>
int(4)
["b:protected"]=>
int(5)
["c:private"]=>
int(6)
}
}
OK
array(2) {
[0]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
}
OK

View File

@ -2,8 +2,10 @@
Check for class methods
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,13 @@
Check for class methods
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php

305
php/tests/071c.phpt Normal file
View File

@ -0,0 +1,305 @@
--TEST--
Check for class methods
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test = null) {
$msgpack = new MessagePack();
$serialized = $msgpack->pack($variable);
$unserialized = $msgpack->unpack($serialized);
var_dump($unserialized);
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('boo:l true', true);
test('bool: true', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('empty: array', array(), false);
test('empty: array(1, 2, 3)', array(1, 2, 3), false);
test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), false);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), false);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
&array(1) {
[0]=>
string(3) "foo"
}
[1]=>
&array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
OK
array(2) {
[0]=>
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
object(Obj)#%d (3) {
["a"]=>
int(4)
["b:protected"]=>
int(5)
["c:private"]=>
int(6)
}
}
OK
array(2) {
[0]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
}
OK

View File

@ -2,8 +2,10 @@
Check for class methods unpacker
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,13 @@
Check for class methods unpacker
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php

345
php/tests/072c.phpt Normal file
View File

@ -0,0 +1,345 @@
--TEST--
Check for class methods unpacker
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test = null) {
$msgpack = new MessagePack();
$serialized = $msgpack->pack($variable);
$unpacker = $msgpack->unpacker();
$length = strlen($serialized);
if (rand(0, 1))
{
for ($i = 0; $i < $length;) {
$len = rand(1, 10);
$str = substr($serialized, $i, $len);
$unpacker->feed($str);
if ($unpacker->execute())
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
}
$i += $len;
}
}
else
{
$str = "";
$offset = 0;
for ($i = 0; $i < $length;) {
$len = rand(1, 10);
$str .= substr($serialized, $i, $len);
if ($unpacker->execute($str, $offset))
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
$str = "";
$offset = 0;
}
$i += $len;
}
}
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('boo:l true', true);
test('bool: true', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('empty: array', array(), false);
test('empty: array(1, 2, 3)', array(1, 2, 3), false);
test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), false);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), false);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
&array(1) {
[0]=>
string(3) "foo"
}
[1]=>
&array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
OK
array(2) {
[0]=>
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
object(Obj)#%d (3) {
["a"]=>
int(4)
["b:protected"]=>
int(5)
["c:private"]=>
int(6)
}
}
OK
array(2) {
[0]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
}
OK

View File

@ -2,8 +2,10 @@
Check for class unpacker
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.2') <= 0) {
echo "skip tests in PHP 5.3.3 or newer";
if ((version_compare(PHP_VERSION, '5.2.13') <= 0) ||
(version_compare(PHP_VERSION, '5.3.0') >= 0 &&
version_compare(PHP_VERSION, '5.3.2') <= 0)) {
echo "skip tests in PHP 5.2.14/5.3.3 or newer";
}
--FILE--
<?php

View File

@ -2,8 +2,13 @@
Check for class unpacker
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.3.3') >= 0) {
echo "skip tests in PHP 5.3.2 or older";
if ((version_compare(PHP_VERSION, '5.3.0') < 0 &&
version_compare(PHP_VERSION, '5.2.14') >= 0) ||
(version_compare(PHP_VERSION, '5.3.3') >= 0)) {
echo "skip tests in PHP 5.2.13/5.3.2 or older";
}
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php

346
php/tests/073c.phpt Normal file
View File

@ -0,0 +1,346 @@
--TEST--
Check for class unpacker
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
echo "skip tests in PHP 5.1 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test = null) {
$msgpack = new MessagePack();
$serialized = $msgpack->pack($variable);
$unpacker = new MessagePackUnpacker();
$length = strlen($serialized);
if (rand(0, 1))
{
for ($i = 0; $i < $length;) {
$len = rand(1, 10);
$str = substr($serialized, $i, $len);
$unpacker->feed($str);
if ($unpacker->execute())
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
}
$i += $len;
}
}
else
{
$str = "";
$offset = 0;
for ($i = 0; $i < $length;) {
$len = rand(1, 10);
$str .= substr($serialized, $i, $len);
if ($unpacker->execute($str, $offset))
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
$str = "";
$offset = 0;
}
$i += $len;
}
}
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('boo:l true', true);
test('bool: true', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('empty: array', array(), false);
test('empty: array(1, 2, 3)', array(1, 2, 3), false);
test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), false);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), false);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), false);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
&array(1) {
[0]=>
string(3) "foo"
}
[1]=>
&array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
&array(1) {
[0]=>
*RECURSION*
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
OK
array(2) {
[0]=>
object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
object(Obj)#%d (3) {
["a"]=>
int(4)
["b:protected"]=>
int(5)
["c:private"]=>
int(6)
}
}
OK
array(2) {
[0]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
[1]=>
&object(Obj)#%d (3) {
["a"]=>
int(1)
["b:protected"]=>
int(2)
["c:private"]=>
int(3)
}
}
OK

View File

@ -1,6 +1,10 @@
--TEST--
disabled php only for class methods (set option)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') < 0) {
echo "skip tests in PHP 5.1 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

306
php/tests/087d.phpt Normal file
View File

@ -0,0 +1,306 @@
--TEST--
disabled php only for class methods (set option)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') >= 0) {
echo "skip tests in PHP 5.0 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test = null) {
$msgpack = new MessagePack();
$msgpack->setOption(MESSAGEPACK_OPT_PHPONLY, false);
$serialized = $msgpack->pack($variable);
$unserialized = $msgpack->unpack($serialized);
var_dump($unserialized);
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('boo:l true', true);
test('bool: true', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('empty: array', array(), false);
test('empty: array(1, 2, 3)', array(1, 2, 3), false);
test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), true);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), true);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
NULL
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(2) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
}
OK
array(2) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
}
OK

View File

@ -1,6 +1,10 @@
--TEST--
disabled php only for class methods unpacker (set option)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') < 0) {
echo "skip tests in PHP 5.1 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

349
php/tests/088d.phpt Normal file
View File

@ -0,0 +1,349 @@
--TEST--
disabled php only for class methods unpacker (set option)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') >= 0) {
echo "skip tests in PHP 5.1.0 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test = null)
{
$msgpack = new MessagePack();
$msgpack->setOption(MESSAGEPACK_OPT_PHPONLY, false);
$serialized = $msgpack->pack($variable);
$unpacker = $msgpack->unpacker();
$length = strlen($serialized);
if (rand(0, 1))
{
for ($i = 0; $i < $length;)
{
$len = rand(1, 10);
$str = substr($serialized, $i, $len);
$unpacker->feed($str);
if ($unpacker->execute())
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
}
$i += $len;
}
}
else
{
$str = "";
$offset = 0;
for ($i = 0; $i < $length;)
{
$len = rand(1, 10);
$str .= substr($serialized, $i, $len);
if ($unpacker->execute($str, $offset))
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
$str = "";
$offset = 0;
}
$i += $len;
}
}
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('boo:l true', true);
test('bool: true', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('empty: array', array(), false);
test('empty: array(1, 2, 3)', array(1, 2, 3), false);
test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), true);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), true);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
NULL
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(2) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
}
OK
array(2) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
}
OK

View File

@ -1,6 +1,10 @@
--TEST--
disabled php only for class unpacker (set option)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') < 0) {
echo "skip tests in PHP 5.1 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {

351
php/tests/089d.phpt Normal file
View File

@ -0,0 +1,351 @@
--TEST--
disabled php only for class unpacker (set option)
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.1.0') >= 0) {
echo "skip tests in PHP 5.0 or older";
}
--FILE--
<?php
if(!extension_loaded('msgpack')) {
dl('msgpack.' . PHP_SHLIB_SUFFIX);
}
function test($type, $variable, $test = null)
{
$msgpack = new MessagePack();
$msgpack->setOption(MESSAGEPACK_OPT_PHPONLY, false);
$serialized = $msgpack->pack($variable);
$unpacker = new MessagePackUnpacker();
$unpacker->setOption(MESSAGEPACK_OPT_PHPONLY, false);
$length = strlen($serialized);
if (rand(0, 1))
{
for ($i = 0; $i < $length;)
{
$len = rand(1, 10);
$str = substr($serialized, $i, $len);
$unpacker->feed($str);
if ($unpacker->execute())
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
}
$i += $len;
}
}
else
{
$str = "";
$offset = 0;
for ($i = 0; $i < $length;)
{
$len = rand(1, 10);
$str .= substr($serialized, $i, $len);
if ($unpacker->execute($str, $offset))
{
$unserialized = $unpacker->data();
var_dump($unserialized);
$unpacker->reset();
$str = "";
$offset = 0;
}
$i += $len;
}
}
if (!is_bool($test))
{
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
else
{
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
}
test('null', null);
test('boo:l true', true);
test('bool: true', false);
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
test('double: 123.456', 123.456);
test('empty: ""', "");
test('string: "foobar"', "foobar");
test('empty: array', array(), false);
test('empty: array(1, 2, 3)', array(1, 2, 3), false);
test('empty: array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)), false);
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"), false);
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2), false);
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"), false);
test('array("" => "empty")', array("" => "empty"), false);
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = array(null);
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
test('object', new Obj(1, 2, 3), true);
test('object', array(new Obj(1, 2, 3), new Obj(4, 5, 6)), true);
$o = new Obj(1, 2, 3);
test('object', array(&$o, &$o), true);
--EXPECTF--
NULL
OK
bool(true)
OK
bool(false)
OK
int(0)
OK
int(1)
OK
int(-1)
OK
int(1000)
OK
int(-1000)
OK
int(100000)
OK
int(-100000)
OK
float(123.456)
OK
string(0) ""
OK
string(6) "foobar"
OK
array(0) {
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array(1) {
[""]=>
string(5) "empty"
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
NULL
}
}
}
}
}
OK
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(2) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
}
OK
array(2) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
}
OK