3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Widget implements Serializable { public $references = array(); public function serialize() { $vars = get_object_vars($this); $serialized = serialize($vars); return $serialized; } public function unserialize($serialized) { $array = unserialize($serialized); foreach($array as $k => $v) $this->$k = $v; } } class Placeholder { public $id; public function __construct($id) { $this->id = $id; } } $placeholder1 = new Placeholder(1); $placeholder2 = new Placeholder(2); $widgets = array(new Widget, new Widget, new Widget, new Widget); $widgets[0]->references[] = $placeholder1; $widgets[1]->references[] = $placeholder2; $widgets[2]->references[] = $placeholder1; $widgets[3]->references[] = $placeholder1; unserialize(serialize($widgets));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B07hH
function name:  (null)
number of ops:  45
compiled vars:  !0 = $placeholder1, !1 = $placeholder2, !2 = $widgets
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'widget'
   34     1        NEW                                              $3      'Placeholder'
          2        SEND_VAL_EX                                              1
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   35     5        NEW                                              $6      'Placeholder'
          6        SEND_VAL_EX                                              2
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $6
   37     9        NEW                                              $9      'Widget'
         10        DO_FCALL                                      0          
         11        INIT_ARRAY                                       ~11     $9
         12        NEW                                              $12     'Widget'
         13        DO_FCALL                                      0          
         14        ADD_ARRAY_ELEMENT                                ~11     $12
         15        NEW                                              $14     'Widget'
         16        DO_FCALL                                      0          
         17        ADD_ARRAY_ELEMENT                                ~11     $14
         18        NEW                                              $16     'Widget'
         19        DO_FCALL                                      0          
         20        ADD_ARRAY_ELEMENT                                ~11     $16
         21        ASSIGN                                                   !2, ~11
   39    22        FETCH_DIM_W                                      $19     !2, 0
         23        FETCH_OBJ_W                                      $20     $19, 'references'
         24        ASSIGN_DIM                                               $20
         25        OP_DATA                                                  !0
   40    26        FETCH_DIM_W                                      $22     !2, 1
         27        FETCH_OBJ_W                                      $23     $22, 'references'
         28        ASSIGN_DIM                                               $23
         29        OP_DATA                                                  !1
   41    30        FETCH_DIM_W                                      $25     !2, 2
         31        FETCH_OBJ_W                                      $26     $25, 'references'
         32        ASSIGN_DIM                                               $26
         33        OP_DATA                                                  !0
   42    34        FETCH_DIM_W                                      $28     !2, 3
         35        FETCH_OBJ_W                                      $29     $28, 'references'
         36        ASSIGN_DIM                                               $29
         37        OP_DATA                                                  !0
   44    38        INIT_FCALL                                               'unserialize'
         39        INIT_FCALL                                               'serialize'
         40        SEND_VAR                                                 !2
         41        DO_ICALL                                         $31     
         42        SEND_VAR                                                 $31
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Class Widget:
Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B07hH
function name:  serialize
number of ops:  11
compiled vars:  !0 = $vars, !1 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'get_object_vars'
          1        FETCH_THIS                                       ~2      
          2        SEND_VAL                                                 ~2
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
   10     5        INIT_FCALL                                               'serialize'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !1, $5
   12     9      > RETURN                                                   !1
   13    10*     > RETURN                                                   null

End of function serialize

Function unserialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/B07hH
function name:  unserialize
number of ops:  13
compiled vars:  !0 = $serialized, !1 = $array, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   19     5      > FE_RESET_R                                       $6      !1, ->11
          6    > > FE_FETCH_R                                       ~7      $6, !2, ->11
          7    >   ASSIGN                                                   !3, ~7
   20     8        ASSIGN_OBJ                                               !3
          9        OP_DATA                                                  !2
   19    10      > JMP                                                      ->6
         11    >   FE_FREE                                                  $6
   21    12      > RETURN                                                   null

End of function unserialize

End of class Widget.

Class Placeholder:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B07hH
function name:  __construct
number of ops:  4
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  !0
   31     3      > RETURN                                                   null

End of function __construct

End of class Placeholder.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.29 ms | 1392 KiB | 19 Q