3v4l.org

run code in 300+ PHP versions simultaneously
<?php class testClass_forSerialize implements Serializable { public function serialize() { static $count = 0; static $objectHashes = []; $ret = new \stdClass(); $serializedData = serialize($ret); $objectHash = spl_object_hash($ret); echo "loop $count: ObjectHash $objectHash Received: ".$serializedData."\n"; if (array_key_exists($objectHash, $objectHashes) == true) { echo "Object hash already exists - serialize is going to be sad.\n"; } $objectHashes[$objectHash] = $count; if (@unserialize($serializedData) === false) { printf( "borked, serialize of %s returned %s which could not be unserialized.\n", var_export($ret, true), $serializedData ); exit(0); } echo "loop $count: Returning '$serializedData'\n"; $count++; return $serializedData; } public function unserialize($data) { throw new \Exception("not relevant"); } } $list = []; for ($i=0; $i<2; $i++) { $list[] = new \testClass_forSerialize(); } $ser = serialize($list);
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 = 4
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 4
Branch analysis from position: 11
Branch analysis from position: 4
filename:       /in/9ttkq
function name:  (null)
number of ops:  16
compiled vars:  !0 = $list, !1 = $i, !2 = $ser
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'testclass_forserialize'
   38     1        ASSIGN                                                   !0, <array>
   39     2        ASSIGN                                                   !1, 0
          3      > JMP                                                      ->9
   40     4    >   NEW                                              $6      'testClass_forSerialize'
          5        DO_FCALL                                      0          
          6        ASSIGN_DIM                                               !0
          7        OP_DATA                                                  $6
   39     8        PRE_INC                                                  !1
          9    >   IS_SMALLER                                               !1, 2
         10      > JMPNZ                                                    ~9, ->4
   43    11    >   INIT_FCALL                                               'serialize'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !2, $10
         15      > RETURN                                                   1

Class testClass_forSerialize:
Function serialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 44
Branch analysis from position: 34
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/9ttkq
function name:  serialize
number of ops:  53
compiled vars:  !0 = $count, !1 = $objectHashes, !2 = $ret, !3 = $serializedData, !4 = $objectHash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                              !0
    6     1        BIND_STATIC                                              !1
    7     2        NEW                                              $5      'stdClass'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $5
    8     5        INIT_FCALL                                               'serialize'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !3, $8
   10     9        INIT_FCALL                                               'spl_object_hash'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !4, $10
   11    13        ROPE_INIT                                     5  ~13     'loop+'
         14        ROPE_ADD                                      1  ~13     ~13, !0
         15        ROPE_ADD                                      2  ~13     ~13, '%3A+ObjectHash+'
         16        ROPE_ADD                                      3  ~13     ~13, !4
         17        ROPE_END                                      4  ~12     ~13, '+Received%3A+'
         18        CONCAT                                           ~16     ~12, !3
         19        CONCAT                                           ~17     ~16, '%0A'
         20        ECHO                                                     ~17
   12    21        ARRAY_KEY_EXISTS                                 ~18     !4, !1
         22        BOOL                                             ~19     ~18
         23      > JMPZ                                                     ~19, ->25
   13    24    >   ECHO                                                     'Object+hash+already+exists+-+serialize+is+going+to+be+sad.%0A'
   16    25    >   ASSIGN_DIM                                               !1, !4
         26        OP_DATA                                                  !0
   18    27        BEGIN_SILENCE                                    ~21     
         28        INIT_FCALL                                               'unserialize'
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                         $22     
         31        END_SILENCE                                              ~21
         32        TYPE_CHECK                                    4          $22
         33      > JMPZ                                                     ~23, ->44
   19    34    >   INIT_FCALL                                               'printf'
   20    35        SEND_VAL                                                 'borked%2C+serialize+of+%25s+returned+%25s+which+could+not+be+unserialized.%0A'
   21    36        INIT_FCALL                                               'var_export'
         37        SEND_VAR                                                 !2
         38        SEND_VAL                                                 <true>
         39        DO_ICALL                                         $24     
         40        SEND_VAR                                                 $24
   22    41        SEND_VAR                                                 !3
         42        DO_ICALL                                                 
   24    43      > EXIT                                                     0
   27    44    >   ROPE_INIT                                     5  ~27     'loop+'
         45        ROPE_ADD                                      1  ~27     ~27, !0
         46        ROPE_ADD                                      2  ~27     ~27, '%3A+Returning+%27'
         47        ROPE_ADD                                      3  ~27     ~27, !3
         48        ROPE_END                                      4  ~26     ~27, '%27%0A'
         49        ECHO                                                     ~26
   28    50        PRE_INC                                                  !0
   29    51      > RETURN                                                   !3
   30    52*     > RETURN                                                   null

End of function serialize

Function unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/9ttkq
function name:  unserialize
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1        NEW                                              $1      'Exception'
          2        SEND_VAL_EX                                              'not+relevant'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $1
   34     5*     > RETURN                                                   null

End of function unserialize

End of class testClass_forSerialize.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
201.2 ms | 1404 KiB | 23 Q