File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ public function getUriRetriever()
102102 public function resolve ($ schema , $ sourceUri = null )
103103 {
104104 if (self ::$ depth > self ::$ maxDepth ) {
105+ self ::$ depth = 0 ;
105106 throw new JsonDecodingException (JSON_ERROR_DEPTH );
106107 }
107108 ++self ::$ depth ;
Original file line number Diff line number Diff line change 99
1010namespace JsonSchema \Tests ;
1111
12+ use JsonSchema \Exception \JsonDecodingException ;
13+
1214/**
1315 * @group RefResolver
1416 */
@@ -355,4 +357,27 @@ public function testMaxDepthExceeded()
355357
356358 $ resolver ->resolve ($ jsonSchema );
357359 }
360+
361+ public function testDepthRestoration ()
362+ {
363+ // stub schema
364+ $ jsonSchema = new \stdClass ;
365+ $ jsonSchema ->id = 'stub ' ;
366+ $ jsonSchema ->additionalItems = new \stdClass ();
367+ $ jsonSchema ->additionalItems ->additionalItems = 'stub ' ;
368+
369+ // stub resolver
370+ \JsonSchema \RefResolver::$ maxDepth = 1 ;
371+ $ resolver = new \JsonSchema \RefResolver ();
372+
373+ try {
374+ $ resolver ->resolve ($ jsonSchema );
375+ } catch (JsonDecodingException $ e ) {
376+
377+ }
378+
379+ $ reflection = new \ReflectionProperty ('\JsonSchema\RefResolver ' , 'depth ' );
380+ $ reflection ->setAccessible (true );
381+ $ this ->assertEquals (0 , $ reflection ->getValue ());
382+ }
358383}
You can’t perform that action at this time.
0 commit comments