3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait DependencySerializationTrait { public function __sleep() { return array_keys(get_object_vars($this)); } } abstract class Base { use DependencySerializationTrait; } class Test extends Base { private $something; public function __construct() { $this->something = 'test'; } public function getSomething() { return $this->something ?? 'NULLSAD'; } } class TestV2 { private $something; public function __construct() { $this->something = 'yay!'; } public function getSomething() { return $this->something ?? 'NULLSAD'; } public function __sleep() { return array_keys(get_object_vars($this)); } } $foo = new Test(); $blob = serialize($foo); $un_foo = unserialize($blob); echo $un_foo->getSomething(); echo "\n"; $bar = new TestV2(); $blob = serialize($bar); $un_bar = unserialize($blob); echo $un_bar->getSomething();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PGJUB
function name:  (null)
number of ops:  32
compiled vars:  !0 = $foo, !1 = $blob, !2 = $un_foo, !3 = $bar, !4 = $un_bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'base'
   12     1        DECLARE_CLASS                                            'test', 'base'
   41     2        NEW                                              $5      'Test'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $5
   42     5        INIT_FCALL                                               'serialize'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !1, $8
   43     9        INIT_FCALL                                               'unserialize'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !2, $10
   44    13        INIT_METHOD_CALL                                         !2, 'getSomething'
         14        DO_FCALL                                      0  $12     
         15        ECHO                                                     $12
   46    16        ECHO                                                     '%0A'
   48    17        NEW                                              $13     'TestV2'
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !3, $13
   49    20        INIT_FCALL                                               'serialize'
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                         $16     
         23        ASSIGN                                                   !1, $16
   50    24        INIT_FCALL                                               'unserialize'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $18     
         27        ASSIGN                                                   !4, $18
   51    28        INIT_METHOD_CALL                                         !4, 'getSomething'
         29        DO_FCALL                                      0  $20     
         30        ECHO                                                     $20
         31      > RETURN                                                   1

Class DependencySerializationTrait:
Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PGJUB
function name:  __sleep
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'array_keys'
          1        INIT_FCALL                                               'get_object_vars'
          2        FETCH_THIS                                       ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    5     8*     > RETURN                                                   null

End of function __sleep

End of class DependencySerializationTrait.

Class Base: [no user functions]
Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PGJUB
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN_OBJ                                               'something'
          1        OP_DATA                                                  'test'
   18     2      > RETURN                                                   null

End of function __construct

Function getsomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PGJUB
function name:  getSomething
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_OBJ_IS                                     ~0      'something'
          1        COALESCE                                         ~1      ~0
          2        QM_ASSIGN                                        ~1      'NULLSAD'
          3      > RETURN                                                   ~1
   22     4*     > RETURN                                                   null

End of function getsomething

End of class Test.

Class TestV2:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PGJUB
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN_OBJ                                               'something'
          1        OP_DATA                                                  'yay%21'
   30     2      > RETURN                                                   null

End of function __construct

Function getsomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PGJUB
function name:  getSomething
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   FETCH_OBJ_IS                                     ~0      'something'
          1        COALESCE                                         ~1      ~0
          2        QM_ASSIGN                                        ~1      'NULLSAD'
          3      > RETURN                                                   ~1
   34     4*     > RETURN                                                   null

End of function getsomething

Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PGJUB
function name:  __sleep
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'array_keys'
          1        INIT_FCALL                                               'get_object_vars'
          2        FETCH_THIS                                       ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
   38     8*     > RETURN                                                   null

End of function __sleep

End of class TestV2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.65 ms | 1022 KiB | 17 Q