3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo {private $a=1;} function test() { var_dump($this); } $closure = (new \ReflectionFunction('test'))->getClosure(); $object = new Foo; $closure = $closure->bindTo($object, get_class($object)); $closure();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YeDBj
function name:  (null)
number of ops:  18
compiled vars:  !0 = $closure, !1 = $object
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   NEW                                                  $2      'ReflectionFunction'
          1        SEND_VAL_EX                                                  'test'
          2        DO_FCALL                                          0          
          3        INIT_METHOD_CALL                                             $2, 'getClosure'
          4        DO_FCALL                                          0  $4      
          5        ASSIGN                                                       !0, $4
    9     6        NEW                                                  $6      'Foo'
          7        DO_FCALL                                          0          
          8        ASSIGN                                                       !1, $6
   10     9        INIT_METHOD_CALL                                             !0, 'bindTo'
         10        SEND_VAR_EX                                                  !1
         11        GET_CLASS                                            ~9      !1
         12        SEND_VAL_EX                                                  ~9
         13        DO_FCALL                                          0  $10     
         14        ASSIGN                                                       !0, $10
   11    15        INIT_DYNAMIC_CALL                                            !0
         16        DO_FCALL                                          0          
         17      > RETURN                                                       1

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

End of function test

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.37 ms | 2511 KiB | 14 Q