1--TEST--
2Object test
3--SKIPIF--
4<?php
5if (version_compare(PHP_VERSION, '5.2.0') < 0) {
6    echo "skip tests in PHP 5.2 or newer";
7}
8--FILE--
9<?php
10if(!extension_loaded('msgpack')) {
11    dl('msgpack.' . PHP_SHLIB_SUFFIX);
12}
13
14function test($type, $variable, $test) {
15    $serialized = msgpack_serialize($variable);
16    $unserialized = msgpack_unserialize($serialized);
17
18    echo $type, PHP_EOL;
19    echo bin2hex($serialized), PHP_EOL;
20    var_dump($unserialized);
21    echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
22}
23
24class Obj {
25    public $a;
26    protected $b;
27    private $c;
28
29    function __construct($a, $b, $c) {
30        $this->a = $a;
31        $this->b = $b;
32        $this->c = $c;
33    }
34}
35
36$o = new Obj(1, 2, 3);
37
38
39test('object', $o, false);
40?>
41--EXPECTF--
42object
4384c0a34f626aa16101a4002a006202a6004f626a006303
44object(Obj)#%d (3) {
45  ["a"]=>
46  int(1)
47  [%r"?b"?:protected"?%r]=>
48  int(2)
49  [%r"?c"?:("Obj":)?private"?%r]=>
50  int(3)
51}
52OK
53