3v4l.org

run code in 300+ PHP versions simultaneously
<?php ########### SIMULATE DATABASE INSERTED DATA ############ $apple = new stdClass; $apple->id = 1; $apple->name = "Apple"; $banana = new stdClass; $banana->id = 2; $banana->name = "Banana"; $carrot = new stdClass; $carrot->id = 3; $carrot->name = "Carrot"; $dill = new stdClass; $dill->id = 4; $dill->name = "Dill"; $egg = new stdClass; $egg->id = 5; $egg->name = "Egg"; $fred = new stdClass; $fred->id = 6; $fred->name = "Fred"; $goat = new stdClass; $goat->id = 7; $goat->name = "Goat"; $harry = new stdClass; $harry->id = 8; $harry->name = "Harry"; $obj_array[] = $harry; $igloo = new stdClass; $igloo->id = 9; $igloo->name = "Igloo"; $jason = new stdClass; $jason->id = 10; $jason->name = "Jason"; $klaus = new stdClass; $klaus->id = 11; $klaus->name = "Klaus"; $apple->link = array($banana, $egg); $banana->link = array($carrot); $carrot->link = array($apple, $banana, $carrot); $dill->link = array($apple, $egg); $egg->link = array($fred); $fred->link = array($goat); $goat->link = array($goat, $harry); $igloo->link = array($banana, $egg); $jason->link = array($apple, $egg, $harry); $klaus->link = array($apple, $egg); ################### END OF DATABASE INSERTS ############## function processObjNetwork(stdClass $rootObj){ $linkedObjects = array(); $process = function(stdClass $obj) use(&$linkedObjects, &$process){ if(isset($linkedObjects[$obj->id])) return; else $linkedObjects[$obj->id] = $obj; if(empty($obj->link)) return; foreach($obj->link as $child) $process($child); }; $process($rootObj); return $linkedObjects; } $linkedObjects = processObjNetwork($apple); foreach($linkedObjects as $obj) echo "$obj->name \n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 123, Position 2 = 129
Branch analysis from position: 123
2 jumps found. (Code = 78) Position 1 = 124, Position 2 = 129
Branch analysis from position: 124
1 jumps found. (Code = 42) Position 1 = 123
Branch analysis from position: 123
Branch analysis from position: 129
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 129
filename:       /in/RioL7
function name:  (null)
number of ops:  131
compiled vars:  !0 = $apple, !1 = $banana, !2 = $carrot, !3 = $dill, !4 = $egg, !5 = $fred, !6 = $goat, !7 = $harry, !8 = $obj_array, !9 = $igloo, !10 = $jason, !11 = $klaus, !12 = $linkedObjects, !13 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $14     'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $14
    4     3        ASSIGN_OBJ                                               !0, 'id'
          4        OP_DATA                                                  1
    5     5        ASSIGN_OBJ                                               !0, 'name'
          6        OP_DATA                                                  'Apple'
    7     7        NEW                                              $19     'stdClass'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $19
    8    10        ASSIGN_OBJ                                               !1, 'id'
         11        OP_DATA                                                  2
    9    12        ASSIGN_OBJ                                               !1, 'name'
         13        OP_DATA                                                  'Banana'
   11    14        NEW                                              $24     'stdClass'
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $24
   12    17        ASSIGN_OBJ                                               !2, 'id'
         18        OP_DATA                                                  3
   13    19        ASSIGN_OBJ                                               !2, 'name'
         20        OP_DATA                                                  'Carrot'
   15    21        NEW                                              $29     'stdClass'
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !3, $29
   16    24        ASSIGN_OBJ                                               !3, 'id'
         25        OP_DATA                                                  4
   17    26        ASSIGN_OBJ                                               !3, 'name'
         27        OP_DATA                                                  'Dill'
   19    28        NEW                                              $34     'stdClass'
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !4, $34
   20    31        ASSIGN_OBJ                                               !4, 'id'
         32        OP_DATA                                                  5
   21    33        ASSIGN_OBJ                                               !4, 'name'
         34        OP_DATA                                                  'Egg'
   23    35        NEW                                              $39     'stdClass'
         36        DO_FCALL                                      0          
         37        ASSIGN                                                   !5, $39
   24    38        ASSIGN_OBJ                                               !5, 'id'
         39        OP_DATA                                                  6
   25    40        ASSIGN_OBJ                                               !5, 'name'
         41        OP_DATA                                                  'Fred'
   27    42        NEW                                              $44     'stdClass'
         43        DO_FCALL                                      0          
         44        ASSIGN                                                   !6, $44
   28    45        ASSIGN_OBJ                                               !6, 'id'
         46        OP_DATA                                                  7
   29    47        ASSIGN_OBJ                                               !6, 'name'
         48        OP_DATA                                                  'Goat'
   31    49        NEW                                              $49     'stdClass'
         50        DO_FCALL                                      0          
         51        ASSIGN                                                   !7, $49
   32    52        ASSIGN_OBJ                                               !7, 'id'
         53        OP_DATA                                                  8
   33    54        ASSIGN_OBJ                                               !7, 'name'
         55        OP_DATA                                                  'Harry'
   34    56        ASSIGN_DIM                                               !8
         57        OP_DATA                                                  !7
   36    58        NEW                                              $55     'stdClass'
         59        DO_FCALL                                      0          
         60        ASSIGN                                                   !9, $55
   37    61        ASSIGN_OBJ                                               !9, 'id'
         62        OP_DATA                                                  9
   38    63        ASSIGN_OBJ                                               !9, 'name'
         64        OP_DATA                                                  'Igloo'
   40    65        NEW                                              $60     'stdClass'
         66        DO_FCALL                                      0          
         67        ASSIGN                                                   !10, $60
   41    68        ASSIGN_OBJ                                               !10, 'id'
         69        OP_DATA                                                  10
   42    70        ASSIGN_OBJ                                               !10, 'name'
         71        OP_DATA                                                  'Jason'
   44    72        NEW                                              $65     'stdClass'
         73        DO_FCALL                                      0          
         74        ASSIGN                                                   !11, $65
   45    75        ASSIGN_OBJ                                               !11, 'id'
         76        OP_DATA                                                  11
   46    77        ASSIGN_OBJ                                               !11, 'name'
         78        OP_DATA                                                  'Klaus'
   48    79        INIT_ARRAY                                       ~71     !1
         80        ADD_ARRAY_ELEMENT                                ~71     !4
         81        ASSIGN_OBJ                                               !0, 'link'
         82        OP_DATA                                                  ~71
   49    83        INIT_ARRAY                                       ~73     !2
         84        ASSIGN_OBJ                                               !1, 'link'
         85        OP_DATA                                                  ~73
   50    86        INIT_ARRAY                                       ~75     !0
         87        ADD_ARRAY_ELEMENT                                ~75     !1
         88        ADD_ARRAY_ELEMENT                                ~75     !2
         89        ASSIGN_OBJ                                               !2, 'link'
         90        OP_DATA                                                  ~75
   51    91        INIT_ARRAY                                       ~77     !0
         92        ADD_ARRAY_ELEMENT                                ~77     !4
         93        ASSIGN_OBJ                                               !3, 'link'
         94        OP_DATA                                                  ~77
   52    95        INIT_ARRAY                                       ~79     !5
         96        ASSIGN_OBJ                                               !4, 'link'
         97        OP_DATA                                                  ~79
   53    98        INIT_ARRAY                                       ~81     !6
         99        ASSIGN_OBJ                                               !5, 'link'
        100        OP_DATA                                                  ~81
   54   101        INIT_ARRAY                                       ~83     !6
        102        ADD_ARRAY_ELEMENT                                ~83     !7
        103        ASSIGN_OBJ                                               !6, 'link'
        104        OP_DATA                                                  ~83
   55   105        INIT_ARRAY                                       ~85     !1
        106        ADD_ARRAY_ELEMENT                                ~85     !4
        107        ASSIGN_OBJ                                               !9, 'link'
        108        OP_DATA                                                  ~85
   56   109        INIT_ARRAY                                       ~87     !0
        110        ADD_ARRAY_ELEMENT                                ~87     !4
        111        ADD_ARRAY_ELEMENT                                ~87     !7
        112        ASSIGN_OBJ                                               !10, 'link'
        113        OP_DATA                                                  ~87
   57   114        INIT_ARRAY                                       ~89     !0
        115        ADD_ARRAY_ELEMENT                                ~89     !4
        116        ASSIGN_OBJ                                               !11, 'link'
        117        OP_DATA                                                  ~89
   75   118        INIT_FCALL                                               'processobjnetwork'
        119        SEND_VAR                                                 !0
        120        DO_FCALL                                      0  $90     
        121        ASSIGN                                                   !12, $90
   76   122      > FE_RESET_R                                       $92     !12, ->129
        123    > > FE_FETCH_R                                               $92, !13, ->129
        124    >   FETCH_OBJ_R                                      ~93     !13, 'name'
        125        NOP                                                      
        126        FAST_CONCAT                                      ~94     ~93, '+%0A'
        127        ECHO                                                     ~94
        128      > JMP                                                      ->123
        129    >   FE_FREE                                                  $92
        130      > RETURN                                                   1

Function processobjnetwork:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RioL7
function name:  processObjNetwork
number of ops:  11
compiled vars:  !0 = $rootObj, !1 = $linkedObjects, !2 = $process
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   RECV                                             !0      
   62     1        ASSIGN                                                   !1, <array>
   63     2        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          3        BIND_LEXICAL                                             ~4, !1
          4        BIND_LEXICAL                                             ~4, !2
          5        ASSIGN                                                   !2, ~4
   71     6        INIT_DYNAMIC_CALL                                        !2
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   72     9      > RETURN                                                   !1
   73    10*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/RioL7
function name:  {closure}
number of ops:  23
compiled vars:  !0 = $obj, !1 = $linkedObjects, !2 = $process, !3 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   64     3        FETCH_OBJ_R                                      ~4      !0, 'id'
          4        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~4
          5      > JMPZ                                                     ~5, ->8
          6    > > RETURN                                                   null
          7*       JMP                                                      ->11
   65     8    >   FETCH_OBJ_R                                      ~6      !0, 'id'
          9        ASSIGN_DIM                                               !1, ~6
         10        OP_DATA                                                  !0
   67    11        ISSET_ISEMPTY_PROP_OBJ                                   !0, 'link'
         12      > JMPZ                                                     ~8, ->14
         13    > > RETURN                                                   null
   69    14    >   FETCH_OBJ_R                                      ~9      !0, 'link'
         15      > FE_RESET_R                                       $10     ~9, ->21
         16    > > FE_FETCH_R                                               $10, !3, ->21
         17    >   INIT_DYNAMIC_CALL                                        !2
         18        SEND_VAR_EX                                              !3
         19        DO_FCALL                                      0          
         20      > JMP                                                      ->16
         21    >   FE_FREE                                                  $10
   70    22      > RETURN                                                   null

End of Dynamic Function 0

End of function processobjnetwork

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.11 ms | 1440 KiB | 14 Q