1--TEST-- 2Bug GH-10747 (Private fields in serialized DateInterval objects throw) 3--FILE-- 4<?php 5class I extends DateInterval 6{ 7 private int $var1; 8 private $var2 = 2; 9 protected int $var3 = 3; 10 protected $var4; 11 12 function __construct($tz) 13 { 14 parent::__construct($tz); 15 $this->var1 = 1; 16 $this->var4 = 4; 17 } 18} 19 20$i = new I('P3D'); 21$s = serialize($i); 22$u = unserialize($s); 23 24var_dump($i, str_replace(chr(0), '!', $s), $u); 25?> 26--EXPECTF-- 27object(I)#1 (14) { 28 ["var1":"I":private]=> 29 int(1) 30 ["var2":"I":private]=> 31 int(2) 32 ["var3":protected]=> 33 int(3) 34 ["var4":protected]=> 35 int(4) 36 ["y"]=> 37 int(0) 38 ["m"]=> 39 int(0) 40 ["d"]=> 41 int(3) 42 ["h"]=> 43 int(0) 44 ["i"]=> 45 int(0) 46 ["s"]=> 47 int(0) 48 ["f"]=> 49 float(0) 50 ["invert"]=> 51 int(0) 52 ["days"]=> 53 bool(false) 54 ["from_string"]=> 55 bool(false) 56} 57string(224) "O:1:"I":14:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:3;s:1:"h";i:0;s:1:"i";i:0;s:1:"s";i:0;s:1:"f";d:0;s:6:"invert";i:0;s:4:"days";b:0;s:11:"from_string";b:0;s:7:"!I!var1";i:1;s:7:"!I!var2";i:2;s:7:"!*!var3";i:3;s:7:"!*!var4";i:4;}" 58object(I)#2 (14) { 59 ["var1":"I":private]=> 60 int(1) 61 ["var2":"I":private]=> 62 int(2) 63 ["var3":protected]=> 64 int(3) 65 ["var4":protected]=> 66 int(4) 67 ["y"]=> 68 int(0) 69 ["m"]=> 70 int(0) 71 ["d"]=> 72 int(3) 73 ["h"]=> 74 int(0) 75 ["i"]=> 76 int(0) 77 ["s"]=> 78 int(0) 79 ["f"]=> 80 float(0) 81 ["invert"]=> 82 int(0) 83 ["days"]=> 84 bool(false) 85 ["from_string"]=> 86 bool(false) 87} 88