3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjectWithReferences { protected $var1; protected $var2; public function __construct() { $this->var1 = new StdClass(); $this->var2 = $this->var1; } } class WrapperObject implements Serializable { static $tempstorage; protected $obj; public function setObject($obj) { $this->obj = $obj; } public function getObject() { return $this->obj; } public function serialize() { unserialize(serialize(new \StdClass)); return serialize($this->obj); } public function unserialize($serialized) { $this->obj = unserialize($serialized); } } $owr = new ObjectWithReferences(); $wrapper = new WrapperObject(); $wrapper->setObject($owr); var_dump($wrapper->getObject()); $wrapper = unserialize(serialize($wrapper)); var_dump($wrapper->getObject());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ltYEY
function name:  (null)
number of ops:  28
compiled vars:  !0 = $owr, !1 = $wrapper
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   DECLARE_CLASS                                            'wrapperobject'
   39     1        NEW                                              $2      'ObjectWithReferences'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   40     4        NEW                                              $5      'WrapperObject'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   42     7        INIT_METHOD_CALL                                         !1, 'setObject'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   43    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !1, 'getObject'
         12        DO_FCALL                                      0  $9      
         13        SEND_VAR                                                 $9
         14        DO_ICALL                                                 
   45    15        INIT_FCALL                                               'unserialize'
         16        INIT_FCALL                                               'serialize'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $11     
         19        SEND_VAR                                                 $11
         20        DO_ICALL                                         $12     
         21        ASSIGN                                                   !1, $12
   47    22        INIT_FCALL                                               'var_dump'
         23        INIT_METHOD_CALL                                         !1, 'getObject'
         24        DO_FCALL                                      0  $14     
         25        SEND_VAR                                                 $14
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Class ObjectWithReferences:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ltYEY
function name:  __construct
number of ops:  8
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        FETCH_OBJ_R                                      ~4      'var1'
          5        ASSIGN_OBJ                                               'var2'
          6        OP_DATA                                                  ~4
   10     7      > 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/ltYEY
function name:  setObject
number of ops:  4
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        ASSIGN_OBJ                                               'obj'
          2        OP_DATA                                                  !0
   22     3      > RETURN                                                   null

End of function setobject

Function getobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ltYEY
function name:  getObject
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~0      'obj'
          1      > RETURN                                                   ~0
   26     2*     > RETURN                                                   null

End of function getobject

Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ltYEY
function name:  serialize
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'unserialize'
          1        INIT_FCALL                                               'serialize'
          2        NEW                                              $0      'StdClass'
          3        DO_FCALL                                      0          
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   30     8        INIT_FCALL                                               'serialize'
          9        FETCH_OBJ_R                                      ~4      'obj'
         10        SEND_VAL                                                 ~4
         11        DO_ICALL                                         $5      
         12      > RETURN                                                   $5
   31    13*     > 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/ltYEY
function name:  unserialize
number of ops:  7
compiled vars:  !0 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN_OBJ                                               'obj'
          5        OP_DATA                                                  $2
   35     6      > RETURN                                                   null

End of function unserialize

End of class WrapperObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.27 ms | 1392 KiB | 19 Q