xref: /PHP-8.0/ext/date/tests/bug73091.phpt (revision 866adb12)
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 (16) {
16  ["days"]=>
17  int(-1)
18  ["y"]=>
19  int(-1)
20  ["m"]=>
21  int(-1)
22  ["d"]=>
23  int(-1)
24  ["h"]=>
25  int(-1)
26  ["i"]=>
27  int(-1)
28  ["s"]=>
29  int(-1)
30  ["f"]=>
31  float(0)
32  ["weekday"]=>
33  int(-1)
34  ["weekday_behavior"]=>
35  int(-1)
36  ["first_last_day_of"]=>
37  int(-1)
38  ["invert"]=>
39  int(0)
40  ["special_type"]=>
41  int(0)
42  ["special_amount"]=>
43  int(-1)
44  ["have_weekday_relative"]=>
45  int(0)
46  ["have_special_relative"]=>
47  int(0)
48}
49