3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private function myPrivate() { return true; } } class Bar extends Foo {} $obj = new Bar; $reflMethod = new \ReflectionMethod($obj, 'myPrivate'); $reflMethod->setAccessible(true); $return = $reflMethod->invoke($obj); var_dump($return);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8YcIk
function name:  (null)
number of ops:  19
compiled vars:  !0 = $obj, !1 = $reflMethod, !2 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $3      'Bar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   13     3        NEW                                              $6      'ReflectionMethod'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAL_EX                                              'myPrivate'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   14     8        INIT_METHOD_CALL                                         !1, 'setAccessible'
          9        SEND_VAL_EX                                              <true>
         10        DO_FCALL                                      0          
   15    11        INIT_METHOD_CALL                                         !1, 'invoke'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !2, $10
   17    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Class Foo:
Function myprivate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8YcIk
function name:  myPrivate
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   <true>
    6     1*     > RETURN                                                   null

End of function myprivate

End of class Foo.

Class Bar:
Function myprivate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8YcIk
function name:  myPrivate
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   <true>
    6     1*     > RETURN                                                   null

End of function myprivate

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.01 ms | 1444 KiB | 14 Q