File: bug013.phpt

package info (click to toggle)
php-msgpack 1%3A3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,224 kB
  • sloc: ansic: 3,925; xml: 458; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 838 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--TEST--
Bug #13 (ensure that __get/__set aren't called when packing/unpacking)
--SKIPIF--
<?php
if (!extension_loaded("msgpack")) {
   echo "skip";
}
--FILE--
<?php

#[AllowDynamicProperties()]
class magicClass {
    public function __set($name, $value) {
        echo 'Called __set' . PHP_EOL;
        $this->$name = $value;
    }
    public function __get($name) {
        echo 'Called __get' . PHP_EOL;
        return $this->$name;
    }
}

$magicInstance = new \magicClass;
$magicInstance->val = 5;
var_dump($magicInstance);

$packed = msgpack_pack($magicInstance);
var_dump(bin2hex($packed));
$unpacked = msgpack_unpack($packed);
var_dump($unpacked);

?>
--EXPECTF--
Called __set
object(magicClass)#%d (1) {
  ["val"]=>
  int(5)
}
string(36) "82c0aa6d61676963436c617373a376616c05"
object(magicClass)#%d (1) {
  ["val"]=>
  int(5)
}