3v4l.org

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

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

End of function %00%7Bclosure%7D%2Fin%2F5ic5D%3A8%240

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

End of function bar

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

End of function getclosure

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.96 ms | 1396 KiB | 15 Q