3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait dumper { public function doIt() { print "get_object_vars()\n"; print_r(get_object_vars($this)); $closure = \Closure::bind(static function ($class) { return get_object_vars($class); }, NULL, $this); $vars = $closure($this); print "\n\nClosure\n"; print_r($vars); } } class A { use dumper; private int $a = 1; } class B extends A { } class C extends B { use dumper; private int $a = 2; } print "Class A\n"; (new A())->doit(); print "\n\nClass B\n"; (new B())->doit(); print "\n\nClass C\n"; (new C())->doit();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3eoXc
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_CLASS                                            'a'
   26     1        DECLARE_CLASS                                            'b', 'a'
   29     2        DECLARE_CLASS                                            'c', 'b'
   37     3        ECHO                                                     'Class+A%0A'
   38     4        NEW                                              $0      'A'
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $0, 'doit'
          7        DO_FCALL                                      0          
   40     8        ECHO                                                     '%0A%0AClass+B%0A'
   41     9        NEW                                              $3      'B'
         10        DO_FCALL                                      0          
         11        INIT_METHOD_CALL                                         $3, 'doit'
         12        DO_FCALL                                      0          
   42    13        ECHO                                                     '%0A%0AClass+C%0A'
   43    14        NEW                                              $6      'C'
         15        DO_FCALL                                      0          
         16        INIT_METHOD_CALL                                         $6, 'doit'
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Class dumper:
Function doit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3eoXc
function name:  doIt
number of ops:  26
compiled vars:  !0 = $closure, !1 = $vars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     'get_object_vars%28%29%0A'
    6     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'get_object_vars'
          3        FETCH_THIS                                       ~2      
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
    9     8        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          9        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   11    10        SEND_VAL                                                 ~5
         11        SEND_VAL                                                 null
         12        FETCH_THIS                                       ~6      
         13        SEND_VAL                                                 ~6
    9    14        DO_FCALL                                      0  $7      
         15        ASSIGN                                                   !0, $7
   13    16        INIT_DYNAMIC_CALL                                        !0
         17        FETCH_THIS                                       $9      
         18        SEND_VAR_EX                                              $9
         19        DO_FCALL                                      0  $10     
         20        ASSIGN                                                   !1, $10
   14    21        ECHO                                                     '%0A%0AClosure%0A'
   15    22        INIT_FCALL                                               'print_r'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
   16    25      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3eoXc
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'get_object_vars'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   11     5*     > RETURN                                                   null

End of Dynamic Function 0

End of function doit

End of class dumper.

Class A: [no user functions]
Class B: [no user functions]
Class C: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.27 ms | 1465 KiB | 15 Q