xref: /PHP-7.0/ext/date/tests/bug73091.phpt (revision 1b29e448)
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 (15) {
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  ["weekday"]=>
31  int(-1)
32  ["weekday_behavior"]=>
33  int(-1)
34  ["first_last_day_of"]=>
35  int(-1)
36  ["invert"]=>
37  int(0)
38  ["special_type"]=>
39  int(0)
40  ["special_amount"]=>
41  int(-1)
42  ["have_weekday_relative"]=>
43  int(0)
44  ["have_special_relative"]=>
45  int(0)
46}
47