3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjectWithReferences { protected $var1; protected $var2; protected $var3; public function __construct() { $this->var1 = new StdClass(); $this->var2 = null; $this->var3 = $this->var1; } } class WrapperObject implements Serializable { static $tempstorage; protected $obj; public function setObject($obj) { $this->obj = $obj; } public function getObject() { if (is_string($this->obj)) { $this->obj = unserialize($this->obj); } return $this->obj; } public function save() { $archive = (object) [ 'object' => is_string($this->obj) ? $this->obj : serialize($this->obj), ]; static::$tempstorage = json_encode($archive); var_dump("Serialized:", static::$tempstorage); } public function load() { $archive = json_decode(static::$tempstorage); $this->obj = $archive->object; } public function serialize() { $this->save(false); return "wrapper!"; // Doesn't actually matter here. } public function unserialize($serialized) { $this->load(); } } $owr = new ObjectWithReferences(); $wrapper = new WrapperObject(); $wrapper->setObject($owr); $wrapper->save(); $wrapper->load(); var_dump($wrapper->getObject()); $serialized = serialize($wrapper); $wrapper = unserialize($serialized); var_dump($wrapper->getObject());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EcWl3
function name:  (null)
number of ops:  33
compiled vars:  !0 = $owr, !1 = $wrapper, !2 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                            'wrapperobject'
   59     1        NEW                                              $3      'ObjectWithReferences'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   60     4        NEW                                              $6      'WrapperObject'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   62     7        INIT_METHOD_CALL                                         !1, 'setObject'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   63    10        INIT_METHOD_CALL                                         !1, 'save'
         11        DO_FCALL                                      0          
   64    12        INIT_METHOD_CALL                                         !1, 'load'
         13        DO_FCALL                                      0          
   65    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !1, 'getObject'
         16        DO_FCALL                                      0  $12     
         17        SEND_VAR                                                 $12
         18        DO_ICALL                                                 
   67    19        INIT_FCALL                                               'serialize'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $14     
         22        ASSIGN                                                   !2, $14
   68    23        INIT_FCALL                                               'unserialize'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                         $16     
         26        ASSIGN                                                   !1, $16
   70    27        INIT_FCALL                                               'var_dump'
         28        INIT_METHOD_CALL                                         !1, 'getObject'
         29        DO_FCALL                                      0  $18     
         30        SEND_VAR                                                 $18
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Class ObjectWithReferences:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EcWl3
function name:  __construct
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   NEW                                              $1      'StdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'var1'
          3        OP_DATA                                                  $1
    9     4        ASSIGN_OBJ                                               'var2'
          5        OP_DATA                                                  null
   10     6        FETCH_OBJ_R                                      ~5      'var1'
          7        ASSIGN_OBJ                                               'var3'
          8        OP_DATA                                                  ~5
   11     9      > RETURN                                                   null

End of function __construct

End of class ObjectWithReferences.

Class WrapperObject:
Function setobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EcWl3
function name:  setObject
number of ops:  4
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        ASSIGN_OBJ                                               'obj'
          2        OP_DATA                                                  !0
   23     3      > RETURN                                                   null

End of function setobject

Function getobject:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/EcWl3
function name:  getObject
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   FETCH_OBJ_R                                      ~0      'obj'
          1        TYPE_CHECK                                   64          ~0
          2      > JMPZ                                                     ~1, ->9
   27     3    >   INIT_FCALL                                               'unserialize'
          4        FETCH_OBJ_R                                      ~3      'obj'
          5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
          7        ASSIGN_OBJ                                               'obj'
          8        OP_DATA                                                  $4
   30     9    >   FETCH_OBJ_R                                      ~5      'obj'
         10      > RETURN                                                   ~5
   31    11*     > RETURN                                                   null

End of function getobject

Function save:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EcWl3
function name:  save
number of ops:  25
compiled vars:  !0 = $archive
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   FETCH_OBJ_R                                      ~1      'obj'
          1        TYPE_CHECK                                   64          ~1
          2      > JMPZ                                                     ~2, ->6
          3    >   FETCH_OBJ_R                                      ~3      'obj'
          4        QM_ASSIGN                                        ~4      ~3
          5      > JMP                                                      ->11
          6    >   INIT_FCALL                                               'serialize'
          7        FETCH_OBJ_R                                      ~5      'obj'
          8        SEND_VAL                                                 ~5
          9        DO_ICALL                                         $6      
         10        QM_ASSIGN                                        ~4      $6
         11    >   INIT_ARRAY                                       ~7      ~4, 'object'
         12        CAST                                          8  ~8      ~7
   34    13        ASSIGN                                                   !0, ~8
   38    14        INIT_FCALL                                               'json_encode'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $11     
         17        ASSIGN_STATIC_PROP                                       'tempstorage'
         18        OP_DATA                                                  $11
   39    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAL                                                 'Serialized%3A'
         21        FETCH_STATIC_PROP_R          unknown             ~12     'tempstorage'
         22        SEND_VAL                                                 ~12
         23        DO_ICALL                                                 
   40    24      > RETURN                                                   null

End of function save

Function load:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EcWl3
function name:  load
number of ops:  9
compiled vars:  !0 = $archive
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   INIT_FCALL                                               'json_decode'
          1        FETCH_STATIC_PROP_R          global lock         ~1      'tempstorage'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   45     5        FETCH_OBJ_R                                      ~5      !0, 'object'
          6        ASSIGN_OBJ                                               'obj'
          7        OP_DATA                                                  ~5
   46     8      > RETURN                                                   null

End of function load

Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EcWl3
function name:  serialize
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   INIT_METHOD_CALL                                         'save'
          1        SEND_VAL_EX                                              <false>
          2        DO_FCALL                                      0          
   50     3      > RETURN                                                   'wrapper%21'
   51     4*     > RETURN                                                   null

End of function serialize

Function unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EcWl3
function name:  unserialize
number of ops:  4
compiled vars:  !0 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
   54     1        INIT_METHOD_CALL                                         'load'
          2        DO_FCALL                                      0          
   55     3      > RETURN                                                   null

End of function unserialize

End of class WrapperObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.32 ms | 1404 KiB | 23 Q