3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fn = function () { return get_called_class(); }; var_dump((new ReflectionFunction($fn))->getClosureScopeClass()); class C { private static $test = 'In class C'; public static function s_fn() { $fn1 = function () { var_dump(D::$test); }; $fn2 = function () { var_dump(static::$test); }; var_dump($fn1()); var_dump($fn2()); } } class D extends C { private static $test = 'In class D'; } D::s_fn();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EVhHP
function name:  (null)
number of ops:  13
compiled vars:  !0 = $fn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEVhHP%3A2%240'
          1        ASSIGN                                                   !0, ~1
    3     2        INIT_FCALL                                               'var_dump'
          3        NEW                                              $3      'ReflectionFunction'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $3, 'getClosureScopeClass'
          7        DO_FCALL                                      0  $5      
          8        SEND_VAR                                                 $5
          9        DO_ICALL                                                 
   20    10        INIT_STATIC_METHOD_CALL                                  'D', 's_fn'
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FEVhHP%3A2%240

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

End of function %00%7Bclosure%7D%2Fin%2FEVhHP%3A9%241

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

End of function %00%7Bclosure%7D%2Fin%2FEVhHP%3A10%242

Class C:
Function s_fn:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EVhHP
function name:  s_fn
number of ops:  15
compiled vars:  !0 = $fn1, !1 = $fn2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEVhHP%3A9%241'
          1        ASSIGN                                                   !0, ~2
   10     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEVhHP%3A10%242'
          3        ASSIGN                                                   !1, ~4
   11     4        INIT_FCALL                                               'var_dump'
          5        INIT_DYNAMIC_CALL                                        !0
          6        DO_FCALL                                      0  $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                                 
   12     9        INIT_FCALL                                               'var_dump'
         10        INIT_DYNAMIC_CALL                                        !1
         11        DO_FCALL                                      0  $8      
         12        SEND_VAR                                                 $8
         13        DO_ICALL                                                 
   13    14      > RETURN                                                   null

End of function s_fn

End of class C.

Class D:
Function s_fn:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EVhHP
function name:  s_fn
number of ops:  15
compiled vars:  !0 = $fn1, !1 = $fn2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEVhHP%3A9%241'
          1        ASSIGN                                                   !0, ~2
   10     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEVhHP%3A10%242'
          3        ASSIGN                                                   !1, ~4
   11     4        INIT_FCALL                                               'var_dump'
          5        INIT_DYNAMIC_CALL                                        !0
          6        DO_FCALL                                      0  $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                                 
   12     9        INIT_FCALL                                               'var_dump'
         10        INIT_DYNAMIC_CALL                                        !1
         11        DO_FCALL                                      0  $8      
         12        SEND_VAR                                                 $8
         13        DO_ICALL                                                 
   13    14      > RETURN                                                   null

End of function s_fn

End of class D.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.6 ms | 1400 KiB | 15 Q