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 >   DECLARE_CLASS                                            'testclass_forserialize'
   33     1        DECLARE_CLASS                                            'testclass_forserialize_02', 'testclass_forserialize'
   45     2        NEW                                              $3      'testClass_forSerialize_02'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   47     5        INIT_FCALL                                               'serialize'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !1, $6
   48     9        INIT_FCALL                                               'unserialize'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !2, $8
         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 >   ASSIGN                                                   !0, <array>
    7     1        FETCH_THIS                                       ~5      
          2      > FE_RESET_R                                       $6      ~5, ->10
          3    > > FE_FETCH_R                                       ~7      $6, !1, ->10
          4    >   ASSIGN                                                   !2, ~7
    8     5        TYPE_CHECK                                  1020          !1
          6      > JMPZ                                                     ~9, ->9
    9     7    >   ASSIGN_DIM                                               !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        ASSIGN                                                   !3, $11
   15    15        INIT_FCALL                                               'unserialize'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $13     
         18        TYPE_CHECK                                    4          $13
         19      > JMPZ                                                     ~14, ->27
   16    20    >   INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                                 
   17    23        NEW                                              $16     'Exception'
         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        ASSIGN                                                   !1, $4
   26     5      > FE_RESET_R                                       $6      !1, ->11
          6    > > FE_FETCH_R                                       ~7      $6, !2, ->11
          7    >   ASSIGN                                                   !3, ~7
   27     8        ASSIGN_OBJ                                               !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 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 2
Branch analysis from position: 10
Branch analysis from position: 2
filename:       /in/hIJE9
function name:  __construct
number of ops:  11
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->8
   39     2    >   NEW                                              $4      'testClass_forSerialize'
          3        DO_FCALL                                      0          
          4        FETCH_OBJ_W                                      $2      'list'
          5        ASSIGN_DIM                                               $2
          6        OP_DATA                                                  $4
   38     7        PRE_INC                                                  !0
          8    >   IS_SMALLER                                               !0, 10
          9      > JMPNZ                                                    ~7, ->2
   41    10    > > RETURN                                                   null

End of function __construct

End of class testClass_forSerialize_02.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.05 ms | 1409 KiB | 19 Q