xref: /PHP-8.3/ext/date/tests/bug73091.phpt (revision c8a6a8ab)
1--TEST--
2Bug #73091 (Unserializing DateInterval object may lead to __toString invocation)
3--FILE--
4<?php
5class foo {
6    function __toString() {
7        var_dump(0);
8        return 'may be a bug';
9    }
10}
11
12var_dump(unserialize('O:12:"DateInterval":1:{s:4:"days";O:3:"foo":0:{}}'));
13?>
14--EXPECTF--
15object(DateInterval)#%d (%d) {
16  ["y"]=>
17  int(-1)
18  ["m"]=>
19  int(-1)
20  ["d"]=>
21  int(-1)
22  ["h"]=>
23  int(-1)
24  ["i"]=>
25  int(-1)
26  ["s"]=>
27  int(-1)
28  ["f"]=>
29  float(0)
30  ["invert"]=>
31  int(0)
32  ["days"]=>
33  int(-1)
34  ["from_string"]=>
35  bool(false)
36}
37