3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function method () { return function () { var_dump(__FUNCTION__, __METHOD__); };} } $reflection = new ReflectionMethod(new Foo(), 'method'); var_dump((new ReflectionFunction($reflection->getClosure()))->getClosureThis());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XgGKq
function name:  (null)
number of ops:  18
compiled vars:  !0 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $1      'ReflectionMethod'
          1        NEW                                              $2      'Foo'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $2
          4        SEND_VAL_EX                                              'method'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $1
    8     7        INIT_FCALL                                               'var_dump'
          8        NEW                                              $6      'ReflectionFunction'
          9        INIT_METHOD_CALL                                         !0, 'getClosure'
         10        DO_FCALL                                      0  $7      
         11        SEND_VAR_NO_REF_EX                                       $7
         12        DO_FCALL                                      0          
         13        INIT_METHOD_CALL                                         $6, 'getClosureThis'
         14        DO_FCALL                                      0  $9      
         15        SEND_VAR                                                 $9
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FXgGKq%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XgGKq
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 '%7Bclosure%7D'
          2        SEND_VAL                                                 '%7Bclosure%7D'
          3        DO_ICALL                                                 
          4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FXgGKq%3A4%240

Class Foo:
Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XgGKq
function name:  method
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FXgGKq%3A4%240'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function method

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.19 ms | 1396 KiB | 15 Q