@@ -198,6 +198,7 @@ public function testInvalidDecode(): void
198198 {
199199 $ this ->expectException (RuntimeException::class);
200200 $ this ->expectExceptionMessage ('Data is not parsable with content-type: "application/json", error: "Syntax error" ' );
201+
201202 $ decoderType = new JsonTypeDecoder ();
202203 $ decoderType ->decode ('==== ' );
203204 }
@@ -206,7 +207,34 @@ public function testNotArrayDecode(): void
206207 {
207208 $ this ->expectException (RuntimeException::class);
208209 $ this ->expectExceptionMessage ('Data is not parsable with content-type: "application/json", error: "Not an object" ' );
210+
209211 $ decoderType = new JsonTypeDecoder ();
210212 $ decoderType ->decode ('null ' );
211213 }
214+
215+ public function testMaxNestedDecode (): void
216+ {
217+ $ data = [];
218+ for ($ i = 0 ; $ i < 510 ; ++$ i ) {
219+ $ data = ['data ' => $ data ];
220+ }
221+
222+ $ decoderType = new JsonTypeDecoder ();
223+
224+ self ::assertSame ('array ' , \gettype ($ decoderType ->decode (json_encode ($ data , 0 , 511 ))));
225+ }
226+
227+ public function testTomatchNestedDecode (): void
228+ {
229+ $ this ->expectException (RuntimeException::class);
230+ $ this ->expectExceptionMessage ('Data is not parsable with content-type: "application/json", error: "Maximum stack depth exceeded" ' );
231+
232+ $ data = [];
233+ for ($ i = 0 ; $ i < 511 ; ++$ i ) {
234+ $ data = ['data ' => $ data ];
235+ }
236+
237+ $ decoderType = new JsonTypeDecoder ();
238+ $ decoderType ->decode (json_encode ($ data , 0 , 512 ));
239+ }
212240}
0 commit comments