3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SerializableClass implements Serializable { public $sharedProp; public function __construct($prop) { $this->sharedProp = $prop; } public function __set($key, $value) { $this->$key = $value; } public function serialize() { return serialize(get_object_vars($this)); } public function unserialize($data) { $ar = unserialize($data); if ($ar === false) { return; } foreach ($ar as $k => $v) { $this->__set($k, $v); } } } spl_autoload_register(function($class) { $testPropertyObj = new stdClass(); $testPropertyObj->name = 'test'; $array = [ 'obj1' => new SerializableClass($testPropertyObj), 'obj2' => new SerializableClass($testPropertyObj), ]; var_dump(unserialize(serialize($array))); class X {} }); unserialize('O:1:"X":0:{}');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cZqVf
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'serializableclass'
   29     1        INIT_FCALL                                               'spl_autoload_register'
          2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FcZqVf%3A29%241'
   38     3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
   40     5        INIT_FCALL                                               'unserialize'
          6        SEND_VAL                                                 'O%3A1%3A%22X%22%3A0%3A%7B%7D'
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FcZqVf%3A29%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cZqVf
function name:  {closure}
number of ops:  26
compiled vars:  !0 = $class, !1 = $testPropertyObj, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        NEW                                              $3      'stdClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   31     4        ASSIGN_OBJ                                               !1, 'name'
          5        OP_DATA                                                  'test'
   33     6        NEW                                              $7      'SerializableClass'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        INIT_ARRAY                                       ~9      $7, 'obj1'
   34    10        NEW                                              $10     'SerializableClass'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
         13        ADD_ARRAY_ELEMENT                                ~9      $10, 'obj2'
   32    14        ASSIGN                                                   !2, ~9
   36    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'unserialize'
         17        INIT_FCALL                                               'serialize'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $13     
         20        SEND_VAR                                                 $13
         21        DO_ICALL                                         $14     
         22        SEND_VAR                                                 $14
         23        DO_ICALL                                                 
   37    24        DECLARE_CLASS                                            'x'
   38    25      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FcZqVf%3A29%241

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

End of function __construct

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cZqVf
function name:  __set
number of ops:  5
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        ASSIGN_OBJ                                               !0
          3        OP_DATA                                                  !1
   12     4      > RETURN                                                   null

End of function __set

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

End of function serialize

Function unserialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/cZqVf
function name:  unserialize
number of ops:  18
compiled vars:  !0 = $data, !1 = $ar, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   20     5        TYPE_CHECK                                    4          !1
          6      > JMPZ                                                     ~6, ->8
   21     7    > > RETURN                                                   null
   23     8    > > FE_RESET_R                                       $7      !1, ->16
          9    > > FE_FETCH_R                                       ~8      $7, !2, ->16
         10    >   ASSIGN                                                   !3, ~8
   24    11        INIT_METHOD_CALL                                         '__set'
         12        SEND_VAR_EX                                              !3
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
   23    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $7
   26    17      > RETURN                                                   null

End of function unserialize

End of class SerializableClass.

Class X: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.67 ms | 1408 KiB | 23 Q