3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Main implements \JsonSerializable { private $objA=[], $objB=[]; public function start() { for ($i = 0; $i < 10; $i++) { $objB=$this->getObjBandAddToStack($i); $this->objA[]=new ClassA($objB); } } private function getObjBandAddToStack($i) { if(isset($this->objB[$i/2])) { $objB=$this->objB[$i/2]; } else { $objB=new ClassB(); $this->objB[$i]=$objB; } return $objB; } public function jsonSerialize(){ return [ 'objA' => $this->objA, 'objB' => $this->objB, ]; } } class ClassA implements \JsonSerializable { private $objB; public function __construct(ClassB $objB) { $this->objB=$objB; $objB->joinGroup($this); } public function jsonSerialize(){ return [ 'objB' => $this->objB, ]; } } class ClassB implements \JsonSerializable { private $objAgroup=[]; public function joinGroup($objA) { $this->objAgroup[]=$objA; } public function jsonSerialize(){ return [ 'objAgroup' => $this->objAgroup, ]; } } $main=new Main(); $main->start(); var_dump(json_encode($main)); var_dump(json_last_error()); var_dump(json_last_error_msg());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B6LVu
function name:  (null)
number of ops:  25
compiled vars:  !0 = $main
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'main'
   33     1        DECLARE_CLASS                                            'classa'
   49     2        DECLARE_CLASS                                            'classb'
   64     3        NEW                                              $1      'Main'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   65     6        INIT_METHOD_CALL                                         !0, 'start'
          7        DO_FCALL                                      0          
   66     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'json_encode'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
   67    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'json_last_error'
         16        DO_ICALL                                         $7      
         17        SEND_VAR                                                 $7
         18        DO_ICALL                                                 
   68    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL                                               'json_last_error_msg'
         21        DO_ICALL                                         $9      
         22        SEND_VAR                                                 $9
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Class Main:
Function start:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 2
Branch analysis from position: 15
Branch analysis from position: 2
filename:       /in/B6LVu
function name:  start
number of ops:  16
compiled vars:  !0 = $i, !1 = $objB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->13
    9     2    >   INIT_METHOD_CALL                                         'getObjBandAddToStack'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   10     6        NEW                                              $7      'ClassA'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        FETCH_OBJ_W                                      $5      'objA'
         10        ASSIGN_DIM                                               $5
         11        OP_DATA                                                  $7
    8    12        PRE_INC                                                  !0
         13    >   IS_SMALLER                                               !0, 10
         14      > JMPNZ                                                    ~10, ->2
   12    15    > > RETURN                                                   null

End of function start

Function getobjbandaddtostack:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B6LVu
function name:  getObjBandAddToStack
number of ops:  18
compiled vars:  !0 = $i, !1 = $objB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        DIV                                              ~3      !0, 2
          2        FETCH_OBJ_IS                                     ~2      'objB'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~2, ~3
          4      > JMPZ                                                     ~4, ->10
   16     5    >   DIV                                              ~6      !0, 2
          6        FETCH_OBJ_R                                      ~5      'objB'
          7        FETCH_DIM_R                                      ~7      ~5, ~6
          8        ASSIGN                                                   !1, ~7
   15     9      > JMP                                                      ->16
   19    10    >   NEW                                              $9      'ClassB'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $9
   20    13        FETCH_OBJ_W                                      $12     'objB'
         14        ASSIGN_DIM                                               $12, !0
         15        OP_DATA                                                  !1
   22    16    > > RETURN                                                   !1
   23    17*     > RETURN                                                   null

End of function getobjbandaddtostack

Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B6LVu
function name:  jsonSerialize
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_OBJ_R                                      ~0      'objA'
          1        INIT_ARRAY                                       ~1      ~0, 'objA'
   28     2        FETCH_OBJ_R                                      ~2      'objB'
          3        ADD_ARRAY_ELEMENT                                ~1      ~2, 'objB'
          4      > RETURN                                                   ~1
   30     5*     > RETURN                                                   null

End of function jsonserialize

End of class Main.

Class ClassA:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B6LVu
function name:  __construct
number of ops:  8
compiled vars:  !0 = $objB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   38     1        ASSIGN_OBJ                                               'objB'
          2        OP_DATA                                                  !0
   39     3        INIT_METHOD_CALL                                         !0, 'joinGroup'
          4        FETCH_THIS                                       $2      
          5        SEND_VAR_EX                                              $2
          6        DO_FCALL                                      0          
   40     7      > RETURN                                                   null

End of function __construct

Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B6LVu
function name:  jsonSerialize
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   FETCH_OBJ_R                                      ~0      'objB'
          1        INIT_ARRAY                                       ~1      ~0, 'objB'
          2      > RETURN                                                   ~1
   46     3*     > RETURN                                                   null

End of function jsonserialize

End of class ClassA.

Class ClassB:
Function joingroup:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B6LVu
function name:  joinGroup
number of ops:  5
compiled vars:  !0 = $objA
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
   54     1        FETCH_OBJ_W                                      $1      'objAgroup'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   55     4      > RETURN                                                   null

End of function joingroup

Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B6LVu
function name:  jsonSerialize
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   FETCH_OBJ_R                                      ~0      'objAgroup'
          1        INIT_ARRAY                                       ~1      ~0, 'objAgroup'
          2      > RETURN                                                   ~1
   61     3*     > RETURN                                                   null

End of function jsonserialize

End of class ClassB.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.67 ms | 1022 KiB | 17 Q