1717namespace MessagePack \Tests ;
1818
1919use MessagePack \Type \Ext ;
20+ use MessagePack \Type \Timestamp ;
2021
2122class DataProvider
2223{
24+ /**
25+ * @return array<string, array{mixed, string}>
26+ */
2327 public static function provideData () : array
2428 {
2529 return array_merge (
@@ -31,10 +35,14 @@ public static function provideData() : array
3135 self ::provideBinData (),
3236 self ::provideArrayData (),
3337 self ::provideMapData (),
34- self ::provideExtData ()
38+ self ::provideExtData (),
39+ self ::provideExtTimestampData ()
3540 );
3641 }
3742
43+ /**
44+ * @return array<string, array{mixed, string}>
45+ */
3846 public static function provideUnpackData () : array
3947 {
4048 return array_merge (
@@ -46,17 +54,24 @@ public static function provideUnpackData() : array
4654 self ::provideBinData (),
4755 self ::provideArrayData (),
4856 self ::provideMapUnpackData (),
49- self ::provideExtData ()
57+ self ::provideExtData (),
58+ self ::provideExtTimestampData ()
5059 );
5160 }
5261
62+ /**
63+ * @return array<string, array{null, string}>
64+ */
5365 public static function provideNilData () : array
5466 {
5567 return [
5668 'nil ' => [null , "\xc0" ],
5769 ];
5870 }
5971
72+ /**
73+ * @return array<string, array{bool, string}>
74+ */
6075 public static function provideBoolData () : array
6176 {
6277 return [
@@ -65,6 +80,9 @@ public static function provideBoolData() : array
6580 ];
6681 }
6782
83+ /**
84+ * @return array<string, array{int, string}>
85+ */
6886 public static function provideIntData () : array
6987 {
7088 return [
@@ -112,6 +130,9 @@ public static function provideIntData() : array
112130 ];
113131 }
114132
133+ /**
134+ * @return array<string, array{int, string}>
135+ */
115136 public static function provideIntUnpackData () : array
116137 {
117138 return array_merge (self ::provideIntData (), [
@@ -129,6 +150,9 @@ public static function provideIntUnpackData() : array
129150 ]);
130151 }
131152
153+ /**
154+ * @return array<string, array{float, string}>
155+ */
132156 public static function provideFloat32Data () : array
133157 {
134158 return [
@@ -137,6 +161,9 @@ public static function provideFloat32Data() : array
137161 ];
138162 }
139163
164+ /**
165+ * @return array<string, array{float, string}>
166+ */
140167 public static function provideFloat64Data () : array
141168 {
142169 return [
@@ -146,6 +173,9 @@ public static function provideFloat64Data() : array
146173 ];
147174 }
148175
176+ /**
177+ * @return array<string, array{float, string}>
178+ */
149179 public static function provideFloatUnpackData () : array
150180 {
151181 return array_merge (
@@ -154,6 +184,9 @@ public static function provideFloatUnpackData() : array
154184 );
155185 }
156186
187+ /**
188+ * @return array<string, array{string, string}>
189+ */
157190 public static function provideStrData () : array
158191 {
159192 return [
@@ -174,6 +207,9 @@ public static function provideStrData() : array
174207 ];
175208 }
176209
210+ /**
211+ * @return array<string, array{string, string}>
212+ */
177213 public static function provideBinData () : array
178214 {
179215 return [
@@ -185,6 +221,9 @@ public static function provideBinData() : array
185221 ];
186222 }
187223
224+ /**
225+ * @return array<string, {array<int, mixed>, string}>
226+ */
188227 public static function provideArrayData () : array
189228 {
190229 return [
@@ -198,6 +237,9 @@ public static function provideArrayData() : array
198237 ];
199238 }
200239
240+ /**
241+ * @return array<string, {array, string}>
242+ */
201243 public static function provideMapData () : array
202244 {
203245 return [
@@ -212,6 +254,9 @@ public static function provideMapData() : array
212254 ];
213255 }
214256
257+ /**
258+ * @return array<string, {array, string}>
259+ */
215260 public static function provideMapUnpackData () : array
216261 {
217262 return array_merge (self ::provideMapData (), [
@@ -221,6 +266,9 @@ public static function provideMapUnpackData() : array
221266 ]);
222267 }
223268
269+ /**
270+ * @return array<string, array{Ext, string}>
271+ */
224272 public static function provideExtData () : array
225273 {
226274 return [
@@ -235,6 +283,28 @@ public static function provideExtData() : array
235283 ];
236284 }
237285
286+ /**
287+ * @return array<string, array{Timestamp, string}>
288+ */
289+ public static function provideExtTimestampData () : array
290+ {
291+ return [
292+ '32-bit timestamp #1 ' => [new Timestamp (0 ), "\xd6\xff\x00\x00\x00\x00" ],
293+ '32-bit timestamp #2 ' => [new Timestamp (0xffffffff ), "\xd6\xff\xff\xff\xff\xff" ],
294+
295+ '64-bit timestamp #1 ' => [new Timestamp (0 , 1 ), "\xd7\xff\x00\x00\x00\x04\x00\x00\x00\x00" ],
296+ '64-bit timestamp #2 ' => [new Timestamp (0xffffffff + 1 ), "\xd7\xff\x00\x00\x00\x01\x00\x00\x00\x00" ],
297+ '64-bit timestamp #3 ' => [new Timestamp (0x3ffffffff , 999999999 ), "\xd7\xff\xee\x6b\x27\xff\xff\xff\xff\xff" ],
298+
299+ '96-bit timestamp #1 ' => [new Timestamp (PHP_INT_MIN ), "\xc7\x0c\xff\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00" ],
300+ '96-bit timestamp #2 ' => [new Timestamp (0x3ffffffff + 1 , 0 ), "\xc7\x0c\xff\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00" ],
301+ '96-bit timestamp #3 ' => [new Timestamp (PHP_INT_MAX , 999999999 ), "\xc7\x0c\xff\x3b\x9a\xc9\xff\x7f\xff\xff\xff\xff\xff\xff\xff" ],
302+ ];
303+ }
304+
305+ /**
306+ * @return list<string>
307+ */
238308 public static function getSlowTestNames () : array
239309 {
240310 return [
@@ -245,6 +315,9 @@ public static function getSlowTestNames() : array
245315 ];
246316 }
247317
318+ /**
319+ * @return list<string>
320+ */
248321 public static function getPeclIncompatibleTestNames () : array
249322 {
250323 return [
@@ -265,6 +338,14 @@ public static function getPeclIncompatibleTestNames() : array
265338 '8-bit ext ' ,
266339 '16-bit ext ' ,
267340 '32-bit ext ' ,
341+ '32-bit timestamp #1 ' ,
342+ '32-bit timestamp #2 ' ,
343+ '64-bit timestamp #1 ' ,
344+ '64-bit timestamp #2 ' ,
345+ '64-bit timestamp #3 ' ,
346+ '96-bit timestamp #1 ' ,
347+ '96-bit timestamp #2 ' ,
348+ '96-bit timestamp #3 ' ,
268349 ];
269350 }
270351}
0 commit comments