3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Role { } class Foo implements Serializable { private $var1; public function __construct() { $this->var1 = array(new Role()); } public function serialize() { return serialize(array($this->var1)); } public function unserialize($serialized) { list($this->var1) = unserialize($serialized); } } class Bar extends Foo { private $var2; public function __construct() { parent::__construct(); $this->var2 = new \stdClass(); } public function serialize() { return serialize(array($this->var2, parent::serialize())); } public function unserialize($serialized) { list($this->var2, $parentStr) = unserialize($serialized); parent::unserialize($parentStr); } } $foo = new Bar; var_dump(unserialize(serialize($foo)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/64GT7
function name:  (null)
number of ops:  15
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'foo'
   24     1        DECLARE_CLASS                                            'bar', 'foo'
   45     2        NEW                                              $1      'Bar'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   47     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               'unserialize'
          7        INIT_FCALL                                               'serialize'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                         $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Class Role: [no user functions]
Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/64GT7
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $1      'Role'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~3      $1
          3        ASSIGN_OBJ                                               'var1'
          4        OP_DATA                                                  ~3
   13     5      > RETURN                                                   null

End of function __construct

Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/64GT7
function name:  serialize
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'serialize'
          1        FETCH_OBJ_R                                      ~0      'var1'
          2        INIT_ARRAY                                       ~1      ~0
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5      > RETURN                                                   $2
   17     6*     > 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/64GT7
function name:  unserialize
number of ops:  9
compiled vars:  !0 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        FETCH_LIST_R                                     $2      $1, 0
          5        ASSIGN_OBJ                                               'var1'
          6        OP_DATA                                                  $2
          7        FREE                                                     $1
   21     8      > RETURN                                                   null

End of function unserialize

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/64GT7
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_STATIC_METHOD_CALL                                  
          1        DO_FCALL                                      0          
   31     2        NEW                                              $2      'stdClass'
          3        DO_FCALL                                      0          
          4        ASSIGN_OBJ                                               'var2'
          5        OP_DATA                                                  $2
   32     6      > RETURN                                                   null

End of function __construct

Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/64GT7
function name:  serialize
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_FCALL                                               'serialize'
          1        FETCH_OBJ_R                                      ~0      'var2'
          2        INIT_ARRAY                                       ~1      ~0
          3        INIT_STATIC_METHOD_CALL                                  'serialize'
          4        DO_FCALL                                      0  $2      
          5        ADD_ARRAY_ELEMENT                                ~1      $2
          6        SEND_VAL                                                 ~1
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   36     9*     > 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/64GT7
function name:  unserialize
number of ops:  14
compiled vars:  !0 = $serialized, !1 = $parentStr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   39     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        FETCH_LIST_R                                     $3      $2, 0
          5        ASSIGN_OBJ                                               'var2'
          6        OP_DATA                                                  $3
          7        FETCH_LIST_R                                     $5      $2, 1
          8        ASSIGN                                                   !1, $5
          9        FREE                                                     $2
   41    10        INIT_STATIC_METHOD_CALL                                  'unserialize'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
   42    13      > RETURN                                                   null

End of function unserialize

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.21 ms | 1396 KiB | 19 Q