1--TEST--
2__serialize() mechanism (001): Basics
3--FILE--
4<?php
5
6class Test {
7    public $prop;
8    public $prop2;
9    public function __serialize() {
10        return ["value" => $this->prop, 42 => $this->prop2];
11    }
12    public function __unserialize(array $data) {
13        $this->prop = $data["value"];
14        $this->prop2 = $data[42];
15    }
16}
17
18$test = new Test;
19$test->prop = "foobar";
20$test->prop2 = "barfoo";
21var_dump($s = serialize($test));
22var_dump(unserialize($s));
23
24?>
25--EXPECT--
26string(58) "O:4:"Test":2:{s:5:"value";s:6:"foobar";i:42;s:6:"barfoo";}"
27object(Test)#2 (2) {
28  ["prop"]=>
29  string(6) "foobar"
30  ["prop2"]=>
31  string(6) "barfoo"
32}
33