3v4l.org

run code in 300+ PHP versions simultaneously
<?php class testClass_forSerialize implements Serializable{ public function serialize() { // use array instead of stdClass $ret = Array(); foreach($this as $k=>$v){ if ($v!==null) { $ret[$k] = $v; } } $serializedData = serialize($ret); if (unserialize($serializedData)===false) { var_dump($serializedData); throw new \Exception("Serialize failed"); } return $serializedData; } public function unserialize($data) { $dataObj = unserialize($data); foreach($dataObj as $k=>$v) { $this->{$k} = $v; } } } class testClass_forSerialize_02 extends \testClass_forSerialize{ public $list = Array(); public function __construct() { for ($i=0; $i<10; $i++) { $this->list[] = new \testClass_forSerialize(); } } } $obj = new \testClass_forSerialize_02(); $ser = serialize($obj); $obj2 = unserialize($ser);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hIJE9
function name:  (null)
number of ops:  14
compiled vars:  !0 = $obj, !1 = $ser, !2 = $obj2
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   ADD_INTERFACE                                            'testclass_forserialize'
  33     1        ADD_INTERFACE                                            'testclass_forserialize_02', 'testclass_forserialize'
  45     2        NEW                                              $3      :24
         3        DO_FCALL                                      0          
         4        QM_ASSIGN                                                !0
  47     5        INIT_FCALL                                               'serialize'
         6        SEND_VAR                                                 !0
         7        DO_ICALL                                         $6      
         8        QM_ASSIGN                                                !1
  48     9        INIT_FCALL                                               'unserialize'
        10        SEND_VAR                                                 !1
        11        DO_ICALL                                         $8      
        12        QM_ASSIGN                                                !2
        13      > RETURN                                                   1

Class testClass_forSerialize:
Function serialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/hIJE9
function name:  serialize
number of ops:  29
compiled vars:  !0 = $ret, !1 = $v, !2 = $k, !3 = $serializedData
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   6     0  E >   QM_ASSIGN                                                !0
   7     1        FETCH_THIS                                       ~5      
         2      > FE_RESET_R                                       $6      ~5, ->10
         3    > > FE_FETCH_R                                       ~7      $6, !1, ->10
         4    >   QM_ASSIGN                                                !2
   8     5        IS_EQUAL                                         ~9      !1, null
         6      > JMPZ                                                     ~9, ->9
   9     7    >   ASSIGN_ADD                                    0          !0, !2
         8        OP_DATA                                                  !1
   7     9    > > JMP                                                      ->3
        10    >   FE_FREE                                                  $6
  13    11        INIT_FCALL                                               'serialize'
        12        SEND_VAR                                                 !0
        13        DO_ICALL                                         $11     
        14        QM_ASSIGN                                                !3
  15    15        INIT_FCALL                                               'unserialize'
        16        SEND_VAR                                                 !3
        17        DO_ICALL                                         $13     
        18        IS_NOT_IDENTICAL                                 ~14     $13, <false>
        19      > JMPZ                                                     ~14, ->27
  16    20    >   INIT_FCALL                                               'var_dump'
        21        SEND_VAR                                                 !3
        22        DO_ICALL                                                 
  17    23        NEW                                              $16     :13
        24        SEND_VAL_EX                                              'Serialize+failed'
        25        DO_FCALL                                      0          
        26      > THROW                                         0          $16
  20    27    > > RETURN                                                   !3
  21    28*     > 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/hIJE9
function name:  unserialize
number of ops:  13
compiled vars:  !0 = $data, !1 = $dataObj, !2 = $v, !3 = $k
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  23     0  E >   RECV                                             !0      
  25     1        INIT_FCALL                                               'unserialize'
         2        SEND_VAR                                                 !0
         3        DO_ICALL                                         $4      
         4        QM_ASSIGN                                                !1
  26     5      > FE_RESET_R                                       $6      !1, ->11
         6    > > FE_FETCH_R                                       ~7      $6, !2, ->11
         7    >   QM_ASSIGN                                                !3
  27     8        ASSIGN_SUB                                    0          !3
         9        OP_DATA                                                  !2
  26    10      > JMP                                                      ->6
        11    >   FE_FREE                                                  $6
  29    12      > RETURN                                                   null

End of function unserialize

End of class testClass_forSerialize.

Class testClass_forSerialize_02:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 2
Branch analysis from position: 11
Branch analysis from position: 2
filename:       /in/hIJE9
function name:  __construct
number of ops:  12
compiled vars:  !0 = $i
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  38     0  E >   QM_ASSIGN                                                !0
         1      > JMP                                                      ->9
  39     2    >   NEW                                              $4      :17
         3        DO_FCALL                                      0          
         4        FETCH_OBJ_W                                      $2      'list'
         5        ASSIGN_ADD                                    0          $2
         6        OP_DATA                                                  $4
  38     7        POST_INC                                         ~6      !0
         8        FREE                                                     ~6
         9    >   IS_SMALLER_OR_EQUAL                              ~7      !0, 10
        10      > JMPNZ                                                    ~7, ->2
  41    11    > > RETURN                                                   null

End of function __construct

End of class testClass_forSerialize_02.

Generated using Vulcan Logic Dumper, using php 7.4.0