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 { private $obj; public function __construct($obj) { $this->obj = $obj; } public function getObject() { return $this->obj; } public function serialize() { unserialize(serialize(new \StdClass)); // this fucks up things return serialize($this->obj); } public function unserialize($serialized) { $this->obj = unserialize($serialized); } } $wrapper = new WrapperObject(new ObjectWithReferences()); 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/UCNin
function name:  (null)
number of ops:  25
compiled vars:  !0 = $wrapper
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   DECLARE_CLASS                                            'wrapperobject'
   37     1        NEW                                              $1      'WrapperObject'
          2        NEW                                              $2      'ObjectWithReferences'
          3        DO_FCALL                                      0          
          4        SEND_VAR_NO_REF_EX                                       $2
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $1
   39     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !0, 'getObject'
          9        DO_FCALL                                      0  $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                                 
   41    12        INIT_FCALL                                               'unserialize'
         13        INIT_FCALL                                               'serialize'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $8      
         16        SEND_VAR                                                 $8
         17        DO_ICALL                                         $9      
         18        ASSIGN                                                   !0, $9
   43    19        INIT_FCALL                                               'var_dump'
         20        INIT_METHOD_CALL                                         !0, 'getObject'
         21        DO_FCALL                                      0  $11     
         22        SEND_VAR                                                 $11
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

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

End of function __construct

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

End of function unserialize

End of class WrapperObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.63 ms | 1392 KiB | 19 Q