1--TEST-- 2Object test, __wakeup 3--SKIPIF-- 4--FILE-- 5<?php 6if(!extension_loaded('msgpack')) { 7 dl('msgpack.' . PHP_SHLIB_SUFFIX); 8} 9 10function test($type, $variable, $test) { 11 $serialized = msgpack_serialize($variable); 12 $unserialized = msgpack_unserialize($serialized); 13 14 echo $type, PHP_EOL; 15 echo bin2hex($serialized), PHP_EOL; 16 var_dump($unserialized); 17 echo $test || $unserialized->b == 3 ? 'OK' : 'ERROR', PHP_EOL; 18} 19 20class Obj { 21 var $a; 22 var $b; 23 24 function __construct($a, $b) { 25 $this->a = $a; 26 $this->b = $b; 27 } 28 29 function __wakeup() { 30 $this->b = $this->a * 3; 31 } 32} 33 34$o = new Obj(1, 2); 35 36 37test('object', $o, false); 38?> 39--EXPECTF-- 40object 4183c0a34f626aa16101a16202 42object(Obj)#%d (2) { 43 ["a"]=> 44 int(1) 45 ["b"]=> 46 int(3) 47} 48OK 49