3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace bed { class A { private $id=5; protected $b; public $c; public function __sleep() { return ['id']; } } class B extends A{ public function __sleep(){ return parent::__sleep(); } } class D extends A{ public function __sleep(){ return ["\0bed\A\0id"]; } } class CoolD extends A { private $d; protected $e; public $f; public function __sleep(){ $allProperties = []; $reflection = new \ReflectionClass($this); do{ foreach ($reflection->getProperties() as $prop) { $allProperties[($prop->isPrivate() ? "\0" . $prop->getDeclaringClass()->getName() . "\0" . $prop->getName() : $prop->getName())] = true; } }while($reflection = $reflection->getParentClass()); return array_keys($allProperties); } } class C extends A{ } // var_dump(serialize(new C)); - not working // var_dump(serialize(new B)); - not working var_dump(serialize(new D)); var_dump(serialize(new CoolD)); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZpPhR
function name:  (null)
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   INIT_NS_FCALL_BY_NAME                                    'bed%5Cvar_dump'
          1        INIT_NS_FCALL_BY_NAME                                    'bed%5Cserialize'
          2        NEW                                              $0      'bed%5CD'
          3        DO_FCALL                                      0          
          4        SEND_VAR_NO_REF_EX                                       $0
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR_NO_REF_EX                                       $2
          7        DO_FCALL                                      0          
   50     8        INIT_NS_FCALL_BY_NAME                                    'bed%5Cvar_dump'
          9        INIT_NS_FCALL_BY_NAME                                    'bed%5Cserialize'
         10        NEW                                              $4      'bed%5CCoolD'
         11        DO_FCALL                                      0          
         12        SEND_VAR_NO_REF_EX                                       $4
         13        DO_FCALL                                      0  $6      
         14        SEND_VAR_NO_REF_EX                                       $6
         15        DO_FCALL                                      0          
   51    16      > RETURN                                                   1

Class bed\A:
Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZpPhR
function name:  __sleep
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   <array>
   10     1*     > RETURN                                                   null

End of function __sleep

End of class bed\A.

Class bed\B:
Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZpPhR
function name:  __sleep
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_STATIC_METHOD_CALL                                  '__sleep'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   16     3*     > RETURN                                                   null

End of function __sleep

End of class bed\B.

Class bed\D:
Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZpPhR
function name:  __sleep
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E > > RETURN                                                   <array>
   22     1*     > RETURN                                                   null

End of function __sleep

End of class bed\D.

Class bed\CoolD:
Function __sleep:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 30
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 6
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
Branch analysis from position: 30
filename:       /in/ZpPhR
function name:  __sleep
number of ops:  40
compiled vars:  !0 = $allProperties, !1 = $reflection, !2 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ASSIGN                                                   !0, <array>
   32     1        NEW                                              $4      'ReflectionClass'
          2        FETCH_THIS                                       $5      
          3        SEND_VAR_EX                                              $5
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $4
   34     6    >   INIT_METHOD_CALL                                         !1, 'getProperties'
          7        DO_FCALL                                      0  $8      
          8      > FE_RESET_R                                       $9      $8, ->30
          9    > > FE_FETCH_R                                               $9, !2, ->30
   35    10    >   INIT_METHOD_CALL                                         !2, 'isPrivate'
         11        DO_FCALL                                      0  $10     
         12      > JMPZ                                                     $10, ->24
   36    13    >   INIT_METHOD_CALL                                         !2, 'getDeclaringClass'
         14        DO_FCALL                                      0  $11     
         15        INIT_METHOD_CALL                                         $11, 'getName'
         16        DO_FCALL                                      0  $12     
         17        CONCAT                                           ~13     '%00', $12
         18        CONCAT                                           ~14     ~13, '%00'
         19        INIT_METHOD_CALL                                         !2, 'getName'
         20        DO_FCALL                                      0  $15     
         21        CONCAT                                           ~16     ~14, $15
         22        QM_ASSIGN                                        ~17     ~16
         23      > JMP                                                      ->27
   37    24    >   INIT_METHOD_CALL                                         !2, 'getName'
         25        DO_FCALL                                      0  $18     
         26        QM_ASSIGN                                        ~17     $18
         27    >   ASSIGN_DIM                                               !0, ~17
         28        OP_DATA                                                  <true>
   34    29      > JMP                                                      ->9
         30    >   FE_FREE                                                  $9
   39    31        INIT_METHOD_CALL                                         !1, 'getParentClass'
         32        DO_FCALL                                      0  $20     
         33        ASSIGN                                           ~21     !1, $20
         34      > JMPNZ                                                    ~21, ->6
   40    35    >   INIT_NS_FCALL_BY_NAME                                    'bed%5Carray_keys'
         36        SEND_VAR_EX                                              !0
         37        DO_FCALL                                      0  $22     
         38      > RETURN                                                   $22
   41    39*     > RETURN                                                   null

End of function __sleep

End of class bed\CoolD.

Class bed\C:
Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZpPhR
function name:  __sleep
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   <array>
   10     1*     > RETURN                                                   null

End of function __sleep

End of class bed\C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.62 ms | 1021 KiB | 16 Q