3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { private int $a = 1; 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 B extends A { private int $b = 2; } (new B())->doit();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MNbOi
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   NEW                                                  $0      'B'
          1        DO_FCALL                                          0          
          2        INIT_METHOD_CALL                                             $0, 'doit'
          3        DO_FCALL                                          0          
          4      > RETURN                                                       1

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

End of Dynamic Function 0

End of function doit

End of class A.

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

End of Dynamic Function 0

End of function doit

End of class B.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.35 ms | 1676 KiB | 15 Q