3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a implements \Serializable { /** @var b */ private $b; /** @var */ private $v; public function __construct($v, b $b) { $this->b = $b; $this->v = $v; } /** * {@inheritdoc} */ public function serialize() { return serialize([$this->v, $this->b]); } /** * {@inheritdoc} */ public function unserialize($serialized) { list($this->v, $this->b) = unserialize($serialized); } /** * @return b */ public function getB() { return $this->b; } } class b { private $b; public function __construct($b) { $this->b = $b; } } $b = new b('test'); $t = serialize([['field1' => new a(1, $b), 'field2' => new a(2, $b)]]); $t = serialize([1, $t]); list($sss, $uns) = unserialize($t); $uns = unserialize($uns); var_dump($uns); var_dump($uns[0]['field1']->getB() === $uns[0]['field2']->getB());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3T71
function name:  (null)
number of ops:  54
compiled vars:  !0 = $b, !1 = $t, !2 = $sss, !3 = $uns
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'a'
   53     1        NEW                                              $4      'b'
          2        SEND_VAL_EX                                              'test'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $4
   55     5        INIT_FCALL                                               'serialize'
          6        NEW                                              $7      'a'
          7        SEND_VAL_EX                                              1
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
         10        INIT_ARRAY                                       ~9      $7, 'field1'
         11        NEW                                              $10     'a'
         12        SEND_VAL_EX                                              2
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
         15        ADD_ARRAY_ELEMENT                                ~9      $10, 'field2'
         16        INIT_ARRAY                                       ~12     ~9
         17        SEND_VAL                                                 ~12
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !1, $13
   56    20        INIT_FCALL                                               'serialize'
         21        INIT_ARRAY                                       ~15     1
         22        ADD_ARRAY_ELEMENT                                ~15     !1
         23        SEND_VAL                                                 ~15
         24        DO_ICALL                                         $16     
         25        ASSIGN                                                   !1, $16
   58    26        INIT_FCALL                                               'unserialize'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $18     
         29        FETCH_LIST_R                                     $19     $18, 0
         30        ASSIGN                                                   !2, $19
         31        FETCH_LIST_R                                     $21     $18, 1
         32        ASSIGN                                                   !3, $21
         33        FREE                                                     $18
   59    34        INIT_FCALL                                               'unserialize'
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                         $23     
         37        ASSIGN                                                   !3, $23
   61    38        INIT_FCALL                                               'var_dump'
         39        SEND_VAR                                                 !3
         40        DO_ICALL                                                 
   62    41        INIT_FCALL                                               'var_dump'
         42        FETCH_DIM_R                                      ~26     !3, 0
         43        FETCH_DIM_R                                      ~27     ~26, 'field1'
         44        INIT_METHOD_CALL                                         ~27, 'getB'
         45        DO_FCALL                                      0  $28     
         46        FETCH_DIM_R                                      ~29     !3, 0
         47        FETCH_DIM_R                                      ~30     ~29, 'field2'
         48        INIT_METHOD_CALL                                         ~30, 'getB'
         49        DO_FCALL                                      0  $31     
         50        IS_IDENTICAL                                     ~32     $28, $31
         51        SEND_VAL                                                 ~32
         52        DO_ICALL                                                 
         53      > RETURN                                                   1

Class a:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3T71
function name:  __construct
number of ops:  7
compiled vars:  !0 = $v, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        ASSIGN_OBJ                                               'b'
          3        OP_DATA                                                  !1
   14     4        ASSIGN_OBJ                                               'v'
          5        OP_DATA                                                  !0
   15     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/g3T71
function name:  serialize
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'serialize'
          1        FETCH_OBJ_R                                      ~0      'v'
          2        INIT_ARRAY                                       ~1      ~0
          3        FETCH_OBJ_R                                      ~2      'b'
          4        ADD_ARRAY_ELEMENT                                ~1      ~2
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
   22     8*     > 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/g3T71
function name:  unserialize
number of ops:  12
compiled vars:  !0 = $serialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1        INIT_FCALL                                               'unserialize'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        FETCH_LIST_R                                     $2      $1, 0
          5        ASSIGN_OBJ                                               'v'
          6        OP_DATA                                                  $2
          7        FETCH_LIST_R                                     $4      $1, 1
          8        ASSIGN_OBJ                                               'b'
          9        OP_DATA                                                  $4
         10        FREE                                                     $1
   30    11      > RETURN                                                   null

End of function unserialize

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

End of function getb

End of class a.

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

End of function __construct

End of class b.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.44 ms | 1404 KiB | 19 Q