3v4l.org

run code in 300+ PHP versions simultaneously
<?php $f = function() {}; $rf = new reflectionFunction($f); //var_dump($rf->getClosureThis()); var_dump($rf->getClosureScopeClass()); class foo { public function getNotStaticClosure() { return function() {}; } public static function getStaticClosure() { return function() {}; } } $foo = new foo(); $f = $foo->getNotStaticClosure(); $rf = new reflectionFunction($f); //var_dump($rf->getClosureThis()); var_dump($rf->getClosureScopeClass()); $f = foo::getStaticClosure(); $rf = new reflectionFunction($f); //var_dump($rf->getClosureThis()); var_dump($rf->getClosureScopeClass());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PsDQK
function name:  (null)
number of ops:  39
compiled vars:  !0 = $f, !1 = $rf, !2 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FPsDQK%3A3%240'
          1        ASSIGN                                                   !0, ~3
    4     2        NEW                                              $5      'reflectionFunction'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
    6     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !1, 'getClosureScopeClass'
          8        DO_FCALL                                      0  $8      
          9        SEND_VAR                                                 $8
         10        DO_ICALL                                                 
   22    11        NEW                                              $10     'foo'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !2, $10
   23    14        INIT_METHOD_CALL                                         !2, 'getNotStaticClosure'
         15        DO_FCALL                                      0  $13     
         16        ASSIGN                                                   !0, $13
   24    17        NEW                                              $15     'reflectionFunction'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !1, $15
   26    21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !1, 'getClosureScopeClass'
         23        DO_FCALL                                      0  $18     
         24        SEND_VAR                                                 $18
         25        DO_ICALL                                                 
   28    26        INIT_STATIC_METHOD_CALL                                  'foo', 'getStaticClosure'
         27        DO_FCALL                                      0  $20     
         28        ASSIGN                                                   !0, $20
   29    29        NEW                                              $22     'reflectionFunction'
         30        SEND_VAR_EX                                              !0
         31        DO_FCALL                                      0          
         32        ASSIGN                                                   !1, $22
   31    33        INIT_FCALL                                               'var_dump'
         34        INIT_METHOD_CALL                                         !1, 'getClosureScopeClass'
         35        DO_FCALL                                      0  $25     
         36        SEND_VAR                                                 $25
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FPsDQK%3A3%240

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

End of function %00%7Bclosure%7D%2Fin%2FPsDQK%3A13%241

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

End of function %00%7Bclosure%7D%2Fin%2FPsDQK%3A18%242

Class foo:
Function getnotstaticclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PsDQK
function name:  getNotStaticClosure
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FPsDQK%3A13%241'
          1      > RETURN                                                   ~0
   14     2*     > RETURN                                                   null

End of function getnotstaticclosure

Function getstaticclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PsDQK
function name:  getStaticClosure
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FPsDQK%3A18%242'
          1      > RETURN                                                   ~0
   19     2*     > RETURN                                                   null

End of function getstaticclosure

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.31 ms | 1400 KiB | 15 Q