3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $schema = <<<'HERE' { "properties": { "foo": {"$ref": "#"} }, "additionalProperties": false } HERE; $schema = json_decode($schema); // unset the ref unset($schema->properties->foo); // replace it with a closure that returns the schema when accessed. $schema->properties->foo = function () use ($schema) { return $schema; }; // If you find a closure, it's a lazy proxy. Execute it to get the value. $ref = $schema->properties->foo; $referencedValue = $ref(); // You would stop recursing if 1.) you run out of nested data or 2.) you reach the max depth. var_dump($referencedValue->properties);
based on 19sPU
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/MA7ND
function name:  (null)
number of ops:  22
compiled vars:  !0 = $schema, !1 = $ref, !2 = $referencedValue
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   9     0  E >   ASSIGN                                                   !0, '%7B%0A++++%22properties%22%3A+%7B%0A++++++++%22foo%22%3A+%7B%22%24ref%22%3A+%22%23%22%7D%0A++++%7D%2C%0A++++%22additionalProperties%22%3A+false%0A%7D'
  12     1        INIT_FCALL                                               'json_decode'
         2        SEND_VAR                                                 !0
         3        DO_ICALL                                         $4      
         4        ASSIGN                                                   !0, $4
  15     5        FETCH_OBJ_UNSET                                  $6      !0, 'properties'
         6        UNSET_OBJ                                                $6, 'foo'
  17     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMA7ND0x7f3cd987315e'
         8        FETCH_OBJ_W                                      $7      !0, 'properties'
         9        ASSIGN_OBJ                                               $7, 'foo'
        10        OP_DATA                                                  ~9
  20    11        FETCH_OBJ_R                                      $10     !0, 'properties'
        12        FETCH_OBJ_R                                      $11     $10, 'foo'
        13        ASSIGN                                                   !1, $11
  21    14        INIT_DYNAMIC_CALL                                        !1
        15        DO_FCALL                                      0  $13     
        16        ASSIGN                                                   !2, $13
  23    17        INIT_FCALL                                               'var_dump'
        18        FETCH_OBJ_R                                      $15     !2, 'properties'
        19        SEND_VAR                                                 $15
        20        DO_ICALL                                                 
        21      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FMA7ND0x7f3cd987315e:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/MA7ND
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $schema
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  17     0  E >   FETCH_R                      static              $1      'schema'
         1        ASSIGN                                                   !0, $1
         2      > RETURN                                                   !0
         3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMA7ND0x7f3cd987315e

Generated using Vulcan Logic Dumper, using php 7.1.0